Major zsh overhaul. Check commands before aliasing, afci won't clobber a git dir

This commit is contained in:
Austen Adler 2016-09-28 12:54:47 -04:00
parent e1c9de5840
commit 813b963e77
No known key found for this signature in database
GPG Key ID: 7ECEE590CCDFE3F1

View File

@ -18,6 +18,13 @@ setopt APPEND_HISTORY SHARE_HISTORY HISTIGNOREALLDUPS
export DISABLE_AUTO_TITLE=true export DISABLE_AUTO_TITLE=true
export EDITOR='vim' export EDITOR='vim'
export FZF_COMPLETION_OPTS='--no-mouse -m -1 -x' export FZF_COMPLETION_OPTS='--no-mouse -m -1 -x'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.cache/zsh
# Check if a command exists
ex(){
command -v "$1" >/dev/null
return $?
}
# For pasting in commands that start with $ # For pasting in commands that start with $
$ () { $ () {
$* $*
@ -95,14 +102,22 @@ run(){
gcc -Wall -std=c99 "${1:r}.c" -o "${1:r}" && (echo "Running..." >&2;./"${1:r}") gcc -Wall -std=c99 "${1:r}.c" -o "${1:r}" && (echo "Running..." >&2;./"${1:r}")
} }
alias nmrestart='nmcli radio wifi off;nmcli radio wifi on' alias nmrestart='nmcli radio wifi off;nmcli radio wifi on'
alias mtr='mtr -t' if ex mtr; then
alias tg='telegram-cli -NWA' alias mtr='mtr -t'
fi
if ex telegram-cli; then
alias tg='telegram-cli -NWA'
fi
alias perm='stat -c "%a %n"' alias perm='stat -c "%a %n"'
alias afci='git x ./autoformat.sh;git add --all;git commit -m "Autoformatted"' alias afci='git x ./autoformat.sh;git commit -am "Autoformatted"'
alias eix="eix -F" if ex eix; then
alias eix="eix -F"
fi
alias mouse1="xmodmap <(echo pointer = 1 2 3)" alias mouse1="xmodmap <(echo pointer = 1 2 3)"
alias mouse2="xmodmap <(echo pointer = 3 2 1)" alias mouse2="xmodmap <(echo pointer = 3 2 1)"
alias ocp="ocp -vs0 -dcurses" if ex ocp; then
alias ocp="ocp -vs0 -dcurses"
fi
alias con='git x php app/console' alias con='git x php app/console'
alias srm='shred -uzv' alias srm='shred -uzv'
alias disphost='export DISPLAY=:0.0' alias disphost='export DISPLAY=:0.0'
@ -110,20 +125,27 @@ alias ll='ls -AlhF'
alias la='ls -A' alias la='ls -A'
alias l='ls -CF' alias l='ls -CF'
alias logout='sudo pkill -u $USER' alias logout='sudo pkill -u $USER'
alias tmux='tmux -2' if ex tmux; then
alias tmux='tmux -2'
fi
alias less='less -R' alias less='less -R'
alias tree='tree -C' if ex tree; then
alias skim="(head -5; tail -5) <" alias tree='tree -C'
alias cp='rsync --partial -ha --info=progress2 "$@"' fi
alias resource='. ~/.zshrc' alias resource='. ~/.zshrc'
if [ "$(uname)" != "Darwin" ]; then if [ "$(uname)" != "Darwin" ]; then
# Not Mac # Not Mac
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$(readlink -e ~/bin)" export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:~/bin"
alias ls='ls --color=always -F' alias ls='ls --color=always -F'
alias matlab='matlab -glnx86' alias matlab='matlab -glnx86'
alias where="readlink -m" alias where="readlink -m"
else else
# It is a mac # It is a mac
# Prepend macports directories in /opt/local
if ex greadlink; then
alias readlink='greadlink'
alias where="greadlink -m"
fi
export PATH="/opt/local/sbin:/opt/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:~/bin" export PATH="/opt/local/sbin:/opt/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:~/bin"
fi fi
if test -f /etc/gentoo-release; then if test -f /etc/gentoo-release; then
@ -192,22 +214,40 @@ alias ............='k ../../../../../../../../../../..'
alias .............='k ../../../../../../../../../../../..' alias .............='k ../../../../../../../../../../../..'
alias ..............='k ../../../../../../../../../../../../..' alias ..............='k ../../../../../../../../../../../../..'
alias ...............='k ../../../../../../../../../../../../../..' alias ...............='k ../../../../../../../../../../../../../..'
alias ytdl="youtube-dl $@ -x --audio-format mp3 --audio-quality 0 -c -o '%(title)s.%(ext)s'" if ex youtube-dl; then
alias tux="wemux" alias ytdl="youtube-dl $@ -x --audio-format mp3 --audio-quality 0 -c -o '%(title)s.%(ext)s'"
alias g="git" fi
if ex wemux; then
alias tux="wemux"
elif ex tmux; then
alias tux="tmux a || tmux"
fi
if ex git; then
alias g="git"
fi
alias stdns="sudo sh -c 'echo nameserver 8.8.8.8 > /etc/resolv.conf'" alias stdns="sudo sh -c 'echo nameserver 8.8.8.8 > /etc/resolv.conf'"
alias fvim="vim -u NONE +\"so ~/.vim/plugged/flappyvird-vim/plugin/flappyvird.vim\" +\"so ~/.vim/plugged/flappyvird-vim/autoload/flappyvird.vim\" +\":FlappyVird\" +\":q\"" alias fvim="vim -u NONE +\"so ~/.vim/plugged/flappyvird-vim/plugin/flappyvird.vim\" +\"so ~/.vim/plugged/flappyvird-vim/autoload/flappyvird.vim\" +\":FlappyVird\" +\":q\""
alias fk='k `fzf --no-mouse -m -1 -x`' alias fk='k `fzf --no-mouse -m -1 -x`'
alias susp="sudo true&&((slock;sleep 2;nmcli radio wifi off;nmcli radio wifi on)&echo mem | sudo tee /sys/power/state >/dev/null)" alias susp="sudo true&&((slock;sleep 2;nmcli radio wifi off;nmcli radio wifi on)&echo mem | sudo tee /sys/power/state >/dev/null)"
alias s='sudo -Hu' if ex sudo; then
alias s='sudo -Hu'
fi
alias -g PA='2>&1 | paste' alias -g PA='2>&1 | paste'
alias -g c='rsync --partial -ha --info=progress2 "$@"' if ex rsync; then
alias -g cfat='rsync --partial -hrlc --info=progress2 "$@"' alias -g c='rsync --partial -ha --info=progress2 "$@"'
alias -g cfat='rsync --partial -hrlc --info=progress2 "$@"'
alias cp='rsync --partial -ha --info=progress2 "$@"'
fi
alias -g nify=" > /dev/null 2>&1 &" alias -g nify=" > /dev/null 2>&1 &"
alias -g nifyd=" > /dev/null 2>&1 & disown" alias -g nifyd=" > /dev/null 2>&1 & disown"
alias -g L="2>&1|less" alias -g L="2>&1|less"
alias -g G='|& ag' if ex ag; then
alias -g GA='|& ag --pager less' alias -g G='|& ag'
elif ex egrep; then
alias -g G='|& egrep'
elif ex grep; then
alias -g G='|& grep'
fi
timer() { timer() {
for i in {1.."$1"}; do for i in {1.."$1"}; do
sleep 1 sleep 1
@ -482,10 +522,13 @@ k(){
vim "$@" vim "$@"
fi fi
} }
(( $+TMUX )) && unset zle_bracketed_paste if (( $+TMUX )) || [[ "$TERM" = "screen-256color" ]] || [[ "$TERM" = "screen.xterm-256color" ]]; then
unset zle_bracketed_paste
fi
#(( $+TMUX )) && unset zle_bracketed_paste
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
if command -v fasd 2>&1 >/dev/null; then if ex fasd; then
eval "$(fasd --init auto)" eval "$(fasd --init auto)"
fi fi