mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-03-06 03:10:35 +01:00
位于分支 ran9er
新文件: H_alias_cmd.zsh 新文件: H_alias_path.zsh 新文件: H_eval.zsh 新文件: H_helper.zsh 新文件: H_keys.zsh
This commit is contained in:
parent
1b7a3ea99a
commit
f067e49ebb
5 changed files with 108 additions and 0 deletions
55
lib/H_keys.zsh
Normal file
55
lib/H_keys.zsh
Normal 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"
|
||||
#}}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue