位于分支 ran9er

新文件:       H_alias_cmd.zsh
	新文件:       H_alias_path.zsh
	新文件:       H_eval.zsh
	新文件:       H_helper.zsh
	新文件:       H_keys.zsh
This commit is contained in:
ran9er 2014-08-20 13:03:35 +08:00
commit f067e49ebb
5 changed files with 108 additions and 0 deletions

11
lib/H_alias_cmd.zsh Normal file
View file

@ -0,0 +1,11 @@
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
alias ls='ls -F --color=auto'
alias ll='ls -l'
alias grep='grep --color=auto'
alias ee='emacsclient -t'
alias history='history -fi'
alias diff='diff -u'
alias v='vim'
alias s='subl'

15
lib/H_alias_path.zsh Normal file
View file

@ -0,0 +1,15 @@
function exist-path () {
for p in $* ; do
[[ -e $p ]] && echo $p && return;
done
}
######
hash -d WWW=$(exist-path /home/lighttpd/html ~/ROR/)
hash -d MNT=$(exist-path /{mnt,media}/$USER /{mnt,media})
hash -d PKG=$(exist-path /var/cache/{pacman/pkg,apt/archives})
hash -d E="/etc/env.d"
hash -d C="/etc/conf.d"
hash -d I=$(exist-path /etc/{init.d,rc.d})
hash -d X="/etc/X11"
hash -d BK=$(exist-path /home/$USER/{config_bak,iff})
hash -d HIST="$HISTDIR"

15
lib/H_eval.zsh Normal file
View file

@ -0,0 +1,15 @@
eval-echo() {
LBUFFER="${LBUFFER}echo \$(( "
RBUFFER=" ))$RBUFFER"
}
zle -N eval-echo
# F1
bindkey "^[[11~" eval-echo
eval-ruby() {
LBUFFER="${LBUFFER}ruby -e \"p "
RBUFFER=" \"$RBUFFER"
}
zle -N eval-ruby
# F2
bindkey "^[[12~" eval-echo

12
lib/H_helper.zsh Normal file
View file

@ -0,0 +1,12 @@
sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history
[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
zle end-of-line
}
zle -N sudo-command-line
# [Esc] [Esc]
bindkey "\e\e" sudo-command-line
#[Esc][h] man
alias run-help >&/dev/null && unalias run-help
autoload run-help

55
lib/H_keys.zsh Normal file
View file

@ -0,0 +1,55 @@
##空行(光标在行首)补全 "cd " {{{
user-complete(){
case $BUFFER in
"" ) # 空行填入 "cd "
BUFFER="cd "
zle end-of-line
zle expand-or-complete
;;
cd\ \ * ) # TAB + 空格 替换为 "cd ~"
BUFFER=${BUFFER/\ \ /\ ~}
zle end-of-line
zle expand-or-complete
;;
" " )
BUFFER="z "
zle end-of-line
;;
"cd --" ) # "cd --" 替换为 "cd +"
BUFFER="cd +"
zle end-of-line
zle expand-or-complete
;;
"cd +-" ) # "cd +-" 替换为 "cd -"
BUFFER="cd -"
zle end-of-line
zle expand-or-complete
;;
* )
zle expand-or-complete
;;
esac
}
zle -N user-complete
bindkey "\t" user-complete
user-ret(){
if [[ $BUFFER = "" ]] ;then
BUFFER="ls"
zle end-of-line
zle accept-line
elif [[ $BUFFER =~ "^cd\ \.\.\.+$" ]] ;then
BUFFER=${${BUFFER//\./\.\.\/}/\.\.\//}
zle end-of-line
zle accept-line
else
zle accept-line
fi
}
zle -N user-ret
bindkey "\r" user-ret
#显示 path-directories ,避免候选项唯一时直接选中
cdpath="/home"
#}}}