zshrc: Clean up a little
This commit is contained in:
parent
9c142c87b6
commit
1fca49fa40
1 changed files with 57 additions and 46 deletions
69
zshrc
69
zshrc
|
@ -59,8 +59,20 @@ compinit -C
|
|||
# Ignore case on completion
|
||||
zstyle ':completion:*' matcher-list 'm:{A-Z}={a-z} m:{a-z}={A-Z}'
|
||||
|
||||
__has_command() {
|
||||
for i in $@; do
|
||||
which $i &>/dev/null && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
__find_command() {
|
||||
which "$1" &>/dev/null && echo "$1" || echo "$2"
|
||||
for i in $@; do
|
||||
if __has_command $i; then
|
||||
echo $i
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
if [ -n "$grep" -o -n "$grep_color" ]; then
|
||||
|
@ -198,8 +210,8 @@ do
|
|||
alias -s "$ext=extr"
|
||||
done
|
||||
|
||||
[ "$EDITOR" = vim ] && alias vi=vim
|
||||
which gpg2 &>/dev/null && alias gpg=gpg2
|
||||
__has_command vim && alias vi=vim
|
||||
__has_command gpg2 && alias gpg=gpg2
|
||||
|
||||
make() {
|
||||
case "$PWD" in
|
||||
|
@ -213,22 +225,23 @@ make() {
|
|||
esac
|
||||
}
|
||||
|
||||
alias tmux="tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf"
|
||||
__has_command tmux && alias tmux="tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf"
|
||||
|
||||
if which fossil &>/dev/null; then
|
||||
if ! __has_command colordiff; then
|
||||
colordiff() {
|
||||
red="$(tput setaf 1)"
|
||||
green="$(tput setaf 2)"
|
||||
reset="$(tput sgr0)"
|
||||
sed "s/^+.*$/$green&$reset/" | sed "s/^-.*$/$red&$reset/"
|
||||
}
|
||||
fi
|
||||
|
||||
if __has_command fossil; then
|
||||
alias fl="fossil"
|
||||
alias flc="fossil changes --differ"
|
||||
|
||||
fld() {
|
||||
if which colordiff &>/dev/null; then
|
||||
fossil diff -N "$@" | colordiff | less -FRX
|
||||
else
|
||||
red="$(tput setaf 1)"
|
||||
green="$(tput setaf 2)"
|
||||
reset="$(tput sgr0)"
|
||||
fossil diff -N "$@" | sed "s/^+.*$/$green&$reset/" |
|
||||
sed "s/^-.*$/$red&$reset/" | less -FRX
|
||||
fi
|
||||
}
|
||||
|
||||
flgrep() {
|
||||
|
@ -299,38 +312,35 @@ if which fossil &>/dev/null; then
|
|||
}
|
||||
fi
|
||||
|
||||
if which cvs &>/dev/null; then
|
||||
if __has_command cvs; then
|
||||
cvsd() {
|
||||
if which colordiff &>/dev/null; then
|
||||
cvs diff -uN "$@" | colordiff | less -FRX
|
||||
else
|
||||
red="$(tput setaf 1)"
|
||||
green="$(tput setaf 2)"
|
||||
reset="$(tput sgr0)"
|
||||
cvs diff -uN "$@" | sed "s/^+.*$/$green&$reset/" |
|
||||
sed "s/^-.*$/$red&$reset/" | less -FRX
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
# pkgsrc does not like MAKEFLAGS including -j
|
||||
which pkg_chk &>/dev/null && alias pkg_chk="MAKEFLAGS= pkg_chk"
|
||||
which pkg_rolling-replace &>/dev/null &&
|
||||
__has_command pkg_chk &&
|
||||
alias pkg_chk="MAKEFLAGS= pkg_chk"
|
||||
__has_command pkg_rolling-replace &&
|
||||
alias pkg_rolling-replace="MAKEFLAGS= pkg_rolling-replace"
|
||||
which url2pkg &>/dev/null && alias url2pkg="MAKEFLAGS= url2pkg"
|
||||
__has_command url2pkg &&
|
||||
alias url2pkg="MAKEFLAGS= url2pkg"
|
||||
|
||||
# mpv does not like locales that use , as decimal point.
|
||||
alias mpv="LC_ALL=C mpv"
|
||||
__has_command mpv && alias mpv="LC_ALL=C mpv"
|
||||
|
||||
if __has_command gpg gpg2; then
|
||||
alias gpg-ssh="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh ssh"
|
||||
alias gpg-ssh-add="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh ssh-add"
|
||||
alias gpg-sftp="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh sftp"
|
||||
fi
|
||||
|
||||
if __has_command cryptopassphrase; then
|
||||
pwnk() {
|
||||
local clipboard
|
||||
if which pbcopy &>/dev/null; then
|
||||
if __has_command pbcopy; then
|
||||
clipboard=pbcopy
|
||||
elif which xclip &>/dev/null; then
|
||||
elif __has_command xclip; then
|
||||
clipboard=xclip
|
||||
else
|
||||
echo "No clipboard handler found!"
|
||||
|
@ -341,6 +351,7 @@ pwnk() {
|
|||
}
|
||||
alias pw="pwnk -k ~/.cryptopassphrase.key"
|
||||
alias pws="pwnk -k ~/.cryptopassphrase-server.key"
|
||||
fi
|
||||
|
||||
ixio() { curl -F 'f:1=<-' ix.io }
|
||||
0x0st() { curl -F'file=@-' https://0x0.st }
|
||||
|
@ -397,7 +408,7 @@ cross() {
|
|||
fi
|
||||
;;
|
||||
ios | iossim)
|
||||
if ! which xcrun &>/dev/null; then
|
||||
if ! __has_command xcrun; then
|
||||
echo -n "Can only cross-compile for iOS " 1>&2
|
||||
echo "on a Mac with Xcode!" 1>&2
|
||||
return 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue