diff options
| author | Tuowen Zhao <ztuowen@gmail.com> | 2018-05-20 13:00:53 -0600 | 
|---|---|---|
| committer | Tuowen Zhao <ztuowen@gmail.com> | 2018-05-20 13:00:53 -0600 | 
| commit | db38c7c3b2921783d955912262f87ee7dd8cd31b (patch) | |
| tree | 19711b0495e8472fdfb85643c2c7ec7c5a5229c3 /plugins/dirhistory | |
| parent | 1481f7aa67df42bdf45953231637194ac200d240 (diff) | |
| parent | a600ab4b8578ca0a8e6c6dae0373033b9d8c201c (diff) | |
| download | zsh-db38c7c3b2921783d955912262f87ee7dd8cd31b.tar.gz zsh-db38c7c3b2921783d955912262f87ee7dd8cd31b.tar.bz2 zsh-db38c7c3b2921783d955912262f87ee7dd8cd31b.zip | |
Merge branch 'master' of https://github.com/robbyrussell/oh-my-zsh
Diffstat (limited to 'plugins/dirhistory')
| -rw-r--r-- | plugins/dirhistory/dirhistory.plugin.zsh | 58 | 
1 files changed, 56 insertions, 2 deletions
| diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index 8138872bc..239915e48 100644 --- a/plugins/dirhistory/dirhistory.plugin.zsh +++ b/plugins/dirhistory/dirhistory.plugin.zsh @@ -2,6 +2,10 @@  #   Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories   #   that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT.  #  +#   Navigate directory hierarchy using ALT-UP and ALT-DOWN. (mac keybindings not yet implemented) +#   ALT-UP moves to higher hierarchy (cd ..) +#   ALT-DOWN moves into the first directory found in alphabetical order +#  dirhistory_past=($PWD)  dirhistory_future=() @@ -120,7 +124,9 @@ zle -N dirhistory_zle_dirhistory_back  bindkey "\e[3D" dirhistory_zle_dirhistory_back  bindkey "\e[1;3D" dirhistory_zle_dirhistory_back  # Mac teminal (alt+left/right) -bindkey "^[b" dirhistory_zle_dirhistory_back +if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then +  bindkey "^[b" dirhistory_zle_dirhistory_back +fi  # Putty:  bindkey "\e\e[D" dirhistory_zle_dirhistory_back  # GNU screen: @@ -129,8 +135,56 @@ bindkey "\eO3D" dirhistory_zle_dirhistory_back  zle -N dirhistory_zle_dirhistory_future  bindkey "\e[3C" dirhistory_zle_dirhistory_future  bindkey "\e[1;3C" dirhistory_zle_dirhistory_future -bindkey "^[f" dirhistory_zle_dirhistory_future +if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then +  bindkey "^[f" dirhistory_zle_dirhistory_future +fi  bindkey "\e\e[C" dirhistory_zle_dirhistory_future  bindkey "\eO3C" dirhistory_zle_dirhistory_future +#  +# HIERARCHY Implemented in this section, in case someone wants to split it to another plugin if it clashes bindings +#  + +# Move up in hierarchy +function dirhistory_up() { +  cd .. || return 1 +} + +# Move down in hierarchy +function dirhistory_down() { +  cd "$(find . -mindepth 1 -maxdepth 1 -type d | sort -n | head -n 1)" || return 1 +} + + +# Bind keys to hierarchy navigation +function dirhistory_zle_dirhistory_up() { +  zle kill-buffer   # Erase current line in buffer +  dirhistory_up +  zle accept-line +} + +function dirhistory_zle_dirhistory_down() { +  zle kill-buffer   # Erase current line in buffer +  dirhistory_down +  zle accept-line +} + +zle -N dirhistory_zle_dirhistory_up +# xterm in normal mode +bindkey "\e[3A" dirhistory_zle_dirhistory_up +bindkey "\e[1;3A" dirhistory_zle_dirhistory_up +# Mac teminal (alt+up) +    #bindkey "^[?" dirhistory_zle_dirhistory_up #dont know it +# Putty: +bindkey "\e\e[A" dirhistory_zle_dirhistory_up +# GNU screen: +bindkey "\eO3A" dirhistory_zle_dirhistory_up + +zle -N dirhistory_zle_dirhistory_down +bindkey "\e[3B" dirhistory_zle_dirhistory_down +bindkey "\e[1;3B" dirhistory_zle_dirhistory_down +# Mac teminal (alt+down) +    #bindkey "^[?" dirhistory_zle_dirhistory_down #dont know it +bindkey "\e\e[B" dirhistory_zle_dirhistory_down +bindkey "\eO3B" dirhistory_zle_dirhistory_down | 
