mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-20 03:02:29 +01:00
the modification include those:
about Tab:
when current line is blank, type TAB, string “cd " will be put in the line, and the menu of "cd" 's candidates appeared.
when current line is "cd "(notice that there is two space), in other words, type TAB SPACE in a blank line, it will be replace with "cd ~", and the menu of named directory's candidates appeared.
when current line is "cd --", it will be replace with "cd +"---- i consider that it was not quite utility
about Enter:
when current line is blank, type ENTER, it will put ls in the line, then performance ENTER. so you can just type ENTER instead l, s, ENTER.
when current line is cd ....., type ENTER, the line will replace this to cd ../../../../, then performance ENTER, whether there was how many "."
for example:
you can type TAB . . . ENTER, it will performance cd ../../
about C-w:
when current line is blank, type C-w to uplevel path
else backward delete word
This commit is contained in:
parent
1b7a3ea99a
commit
34a1cf821f
1 changed files with 70 additions and 0 deletions
70
plugins/virtual-insert/virtual-insert.plugin.zsh
Normal file
70
plugins/virtual-insert/virtual-insert.plugin.zsh
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
zle -N user-complete
|
||||
bindkey "\t" user-complete
|
||||
|
||||
zle -N user-ret
|
||||
bindkey "\r" user-ret
|
||||
|
||||
zle -N user-del
|
||||
bindkey "^W" user-del
|
||||
|
||||
cdpath=".."
|
||||
|
||||
user-complete()
|
||||
{
|
||||
case $BUFFER in
|
||||
"" )
|
||||
BUFFER="cd "
|
||||
zle end-of-line
|
||||
zle expand-or-complete
|
||||
;;
|
||||
cd\ \ * )
|
||||
BUFFER=${BUFFER/\ \ /\ ~}
|
||||
zle end-of-line
|
||||
zle expand-or-complete
|
||||
;;
|
||||
" " )
|
||||
BUFFER="z "
|
||||
zle end-of-line
|
||||
zle expand-or-complete
|
||||
;;
|
||||
"cd --" )
|
||||
BUFFER="cd +"
|
||||
zle end-of-line
|
||||
zle expand-or-complete
|
||||
;;
|
||||
"cd +-" )
|
||||
BUFFER="cd -"
|
||||
zle end-of-line
|
||||
zle expand-or-complete
|
||||
;;
|
||||
* )
|
||||
zle expand-or-complete
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
user-del()
|
||||
{
|
||||
if [[ $BUFFER = "" ]] ; then
|
||||
BUFFER="cd .."
|
||||
zle end-of-line
|
||||
zle accept-line
|
||||
else
|
||||
zle backward-kill-word
|
||||
fi
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue