mirror of
https://github.com/mqttr/dotfiles.git
synced 2025-12-15 12:25:51 -06:00
257 lines
6.4 KiB
Bash
Executable File
257 lines
6.4 KiB
Bash
Executable File
#############################
|
|
#
|
|
# Matthew's zshrc
|
|
#
|
|
#############################
|
|
if [ -e "$HOME/.profile" ]; then
|
|
source "$HOME/.profile"
|
|
fi
|
|
|
|
|
|
#############################
|
|
# Global Variables
|
|
source "$HOME/.cargo/env"
|
|
export PATH="$PATH:$HOME/.local/bin"
|
|
export projects="/media/shared/Projects/"
|
|
export classes=$(eza --absolute -1 $HOME/Documents/Classes 2>/dev/null | sort -t_ -k 1,1 -k 2,2r | tail -n 1)
|
|
export steam_loc="$HOME/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/compatdata"
|
|
|
|
export EDITOR="/usr/bin/nvim"
|
|
export GOPATH="$HOME/.go"
|
|
|
|
# Theme
|
|
ZSH_THEME="xiong-chiamiov"
|
|
|
|
plugins=(
|
|
zsh-autosuggestions
|
|
common-aliases
|
|
# ripgrep
|
|
zoxide
|
|
qrcode
|
|
pip
|
|
rust
|
|
# git
|
|
# sudo
|
|
zsh-syntax-highlighting
|
|
)
|
|
# Path to your oh-my-zsh installation.
|
|
export ZSH="$HOME/.oh-my-zsh"
|
|
# source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
|
source $ZSH/oh-my-zsh.sh
|
|
|
|
|
|
################################################################################
|
|
# Colours
|
|
|
|
# Syntax Color Definition
|
|
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
|
|
|
|
typeset -A ZSH_HIGHLIGHT_STYLES
|
|
|
|
# ZSH_HIGHLIGHT_STYLES[command]=fg=white,bold
|
|
# ZSH_HIGHLIGHT_STYLES[alias]='fg=magenta,bold'
|
|
|
|
ZSH_HIGHLIGHT_STYLES[default]=none
|
|
ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=009
|
|
ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=009,standout
|
|
ZSH_HIGHLIGHT_STYLES[alias]=fg=cyan,bold
|
|
ZSH_HIGHLIGHT_STYLES[builtin]=fg=cyan,bold
|
|
ZSH_HIGHLIGHT_STYLES[function]=fg=cyan,bold
|
|
ZSH_HIGHLIGHT_STYLES[command]=fg=white,bold
|
|
ZSH_HIGHLIGHT_STYLES[precommand]=fg=white,underline
|
|
ZSH_HIGHLIGHT_STYLES[commandseparator]=none
|
|
ZSH_HIGHLIGHT_STYLES[hashed-command]=fg=009
|
|
ZSH_HIGHLIGHT_STYLES[path]=fg=214,underline
|
|
ZSH_HIGHLIGHT_STYLES[globbing]=fg=063
|
|
ZSH_HIGHLIGHT_STYLES[history-expansion]=fg=white,underline
|
|
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=none
|
|
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=none
|
|
ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=none
|
|
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]=fg=063
|
|
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=fg=063
|
|
ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]=fg=009
|
|
ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=009
|
|
ZSH_HIGHLIGHT_STYLES[assign]=none
|
|
|
|
|
|
# Generated using https://dom111.github.io/grep-colors
|
|
GREP_COLORS='sl=49;39:cx=49;39:mt=49;31;1:fn=49;32:ln=49;33:bn=49;33:se=1;36'
|
|
|
|
# and https://geoff.greer.fm/lscolors/
|
|
LS_COLORS='di=36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43'
|
|
LSCOLORS=gxfxcxdxbxegedabagacad
|
|
|
|
export GREP_COLORS LS_COLORS LSCOLORS
|
|
|
|
LESS_TERMCAP_mb=$'\E[01;31m'
|
|
LESS_TERMCAP_md=$'\E[01;38;5;74m'
|
|
LESS_TERMCAP_me=$'\E[0m'
|
|
LESS_TERMCAP_se=$'\E[0m'
|
|
LESS_TERMCAP_so=$'\E[38;5;246m'
|
|
LESS_TERMCAP_ue=$'\E[0m'
|
|
LESS_TERMCAP_us=$'\E[04;38;5;146m'
|
|
export LESS_TERMCAP_mb LESS_TERMCAP_md LESS_TERMCAP_me LESS_TERMCAP_se
|
|
export LESS_TERMCAP_so LESS_TERMCAP_ue LESS_TERMCAP_us
|
|
|
|
###############################################################################
|
|
# Custom Additions
|
|
|
|
eval "$(zoxide init zsh --cmd cd)"
|
|
eval "$(fzf --zsh)"
|
|
eval "$(oh-my-posh init zsh --config $HOME/.config/ohmyposh/ohmyposh.toml 2>/dev/null)"
|
|
|
|
alias update-grub='sudo grub2-mkconfig -o /boot/grub2/grub.cfg'
|
|
|
|
alias cat="bat"
|
|
alias rg="rg"
|
|
alias rgc="rg --color=always"
|
|
alias grepc="grep --color=always"
|
|
|
|
alias ls='eza --color=always'
|
|
alias l='eza --color=always -1'
|
|
alias la='eza --color=always -alh'
|
|
alias ll='eza --color=always -lh'
|
|
|
|
alias py='python3'
|
|
|
|
alias open='xdg-open'
|
|
alias o='kitten icat'
|
|
|
|
# xclip is for x11
|
|
alias c='wl-copy'
|
|
alias v='wl-paste'
|
|
|
|
alias codium='flatpak run com.vscodium.codium'
|
|
alias bw='flatpak run --command=bw com.bitwarden.desktop'
|
|
|
|
###############################################################################
|
|
#
|
|
|
|
if command -v tmux &> /dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] && [[ ! "$TERM" =~ tmux ]] && [ -z "$TMUX" ] && [ -z "$NVIM" ] && { [ -z "$SSH_CLIENT" ] || [ -z "$SSH_TTY" ]} ; then
|
|
tmux a -t default || exec tmux new -s default && exit;
|
|
fi
|
|
|
|
###############################################################################
|
|
# Custom Functions
|
|
|
|
fuck () {
|
|
TF_PYTHONIOENCODING=$PYTHONIOENCODING;
|
|
export TF_SHELL=zsh;
|
|
export TF_ALIAS=fuck;
|
|
TF_SHELL_ALIASES=$(alias);
|
|
export TF_SHELL_ALIASES;
|
|
TF_HISTORY="$(fc -ln -10)";
|
|
export TF_HISTORY;
|
|
export PYTHONIOENCODING=utf-8;
|
|
TF_CMD=$(
|
|
thefuck THEFUCK_ARGUMENT_PLACEHOLDER $@
|
|
) && eval $TF_CMD;
|
|
unset TF_HISTORY;
|
|
export PYTHONIOENCODING=$TF_PYTHONIOENCODING;
|
|
test -n "$TF_CMD" && print -s $TF_CMD
|
|
}
|
|
|
|
function extract()
|
|
{
|
|
if [ -f $1 ] ; then
|
|
case $1 in
|
|
*.tar.bz2)
|
|
tar xvjf $1
|
|
;;
|
|
*.tar.gz)
|
|
tar xvzf $1
|
|
;;
|
|
*.bz2)
|
|
bunzip2 $1
|
|
;;
|
|
*.rar)
|
|
unrar x $1
|
|
;;
|
|
*.gz)
|
|
gunzip $1
|
|
;;
|
|
*.tar)
|
|
tar xvf $1
|
|
;;
|
|
*.tbz2)
|
|
tar xvjf $1
|
|
;;
|
|
*.tgz)
|
|
tar xvzf $1
|
|
;;
|
|
*.zip)
|
|
unzip $1
|
|
;;
|
|
*.xz)
|
|
unxz $1
|
|
;;
|
|
*.Z)
|
|
uncompress $1
|
|
;;
|
|
*.7z)
|
|
7z x $1
|
|
;;
|
|
*)
|
|
echo "'$1' cannot be extracted via extract"
|
|
;;
|
|
esac
|
|
else
|
|
echo "'$1' is not a valid file"
|
|
fi
|
|
}
|
|
|
|
forget () {
|
|
print "Forgetting last line with '$@'. Please reload shell after completion."
|
|
|
|
temp=$(mktemp)
|
|
|
|
sed -e '$ d' ~/.zsh_history | tac | awk "!/$@/ || f++" | tac > $temp
|
|
print "Difference between .zsh_history and new .zsh_history"
|
|
diff ~/.zsh_history $temp
|
|
|
|
mv $temp ~/.zsh_history
|
|
|
|
if [ -f $temp ]; then
|
|
rm -f $temp
|
|
fi
|
|
}
|
|
|
|
forgetall () {
|
|
print "Forgetting all lines with '$@'. Please reload shell after completion."
|
|
|
|
temp=$(mktemp)
|
|
sed "/$@/d" ~/.zsh_history > $temp
|
|
print "Difference between .zsh_history and new .zsh_history"
|
|
diff ~/.zsh_history $temp
|
|
mv $temp ~/.zsh_history
|
|
|
|
if [ -f $temp ]; then
|
|
rm -f $temp
|
|
fi
|
|
}
|
|
|
|
# fzf cd
|
|
fcd() {
|
|
file=$(fzf)
|
|
if [[ -n "$file" ]]; then
|
|
parent=$(dirname $file)
|
|
cd $parent
|
|
print "Moved to \"$parent\""
|
|
fi
|
|
}
|
|
|
|
tcd() {
|
|
DIR=$(mktemp -d 2>/dev/null)
|
|
if [[ -e "$DIR" ]]; then
|
|
cd $DIR
|
|
print "Moved to \"$DIR\""
|
|
else
|
|
print "\"$DIR\" failed to be created"
|
|
fi
|
|
}
|
|
|
|
ttcd() {
|
|
cd /tmp
|
|
tcd
|
|
}
|