From 215e43aa8ab4c660c0edb59ee4d8b3daceb456b5 Mon Sep 17 00:00:00 2001 From: Giuseppe Landolfi Date: Tue, 23 Jan 2018 04:18:45 +0100 Subject: Add support for Mac to dirhistory plugin (#6533) Add shortcuts for mac keyboards as an alternative to alt+left abd alt+right: mac users can now use opt+left and opt+right. --- plugins/dirhistory/dirhistory.plugin.zsh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins/dirhistory') diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index 0209981e3..8138872bc 100644 --- a/plugins/dirhistory/dirhistory.plugin.zsh +++ b/plugins/dirhistory/dirhistory.plugin.zsh @@ -119,6 +119,8 @@ zle -N dirhistory_zle_dirhistory_back # xterm in normal mode 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 # Putty: bindkey "\e\e[D" dirhistory_zle_dirhistory_back # GNU screen: @@ -127,6 +129,7 @@ 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 bindkey "\e\e[C" dirhistory_zle_dirhistory_future bindkey "\eO3C" dirhistory_zle_dirhistory_future -- cgit v1.2.3-70-g09d2 From 7bb7ce62d3a78859aa15151ecc46df5adc9cf049 Mon Sep 17 00:00:00 2001 From: Francisco Zuviría Date: Sun, 22 Apr 2018 22:34:26 -0300 Subject: On branch fzuviria.plugin.dirhistory.new-feature.navigate-history Changes to be committed: modified: dirhistory/dirhistory.plugin.zsh New Feature: 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 --- plugins/dirhistory/dirhistory.plugin.zsh | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'plugins/dirhistory') diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index 8138872bc..05839e35a 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=() @@ -134,3 +138,49 @@ 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 .. +} + +# Move down in hierarchy +function dirhistory_down() { + cd "`find . -mindepth 1 -maxdepth 1 -type d | sort -n | head -n 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 -- cgit v1.2.3-70-g09d2 From 18f7ca577a41807f0c99fc9d00e1572d96d7c6cb Mon Sep 17 00:00:00 2001 From: Francisco Zuviría Date: Tue, 8 May 2018 12:55:59 -0300 Subject: Adhere to coding style outlined in wiki --- plugins/dirhistory/dirhistory.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/dirhistory') diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index 05839e35a..6867086ca 100644 --- a/plugins/dirhistory/dirhistory.plugin.zsh +++ b/plugins/dirhistory/dirhistory.plugin.zsh @@ -144,12 +144,12 @@ bindkey "\eO3C" dirhistory_zle_dirhistory_future # Move up in hierarchy function dirhistory_up() { - cd .. + cd .. || return 1 } # Move down in hierarchy function dirhistory_down() { - cd "`find . -mindepth 1 -maxdepth 1 -type d | sort -n | head -n 1`" + cd "$(find . -mindepth 1 -maxdepth 1 -type d | sort -n | head -n 1)" || return 1 } -- cgit v1.2.3-70-g09d2 From 8ebf2a678507b28cf107858b316f5e874ef73d0f Mon Sep 17 00:00:00 2001 From: Giuseppe Landolfi Date: Sun, 13 May 2018 01:53:45 +0200 Subject: Fine-tune dirhistory plugin mappings for Mac (#6580) See https://github.com/robbyrussell/oh-my-zsh/pull/6533#issuecomment-360878060 --- plugins/dirhistory/dirhistory.plugin.zsh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'plugins/dirhistory') diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index 8138872bc..283dace29 100644 --- a/plugins/dirhistory/dirhistory.plugin.zsh +++ b/plugins/dirhistory/dirhistory.plugin.zsh @@ -120,7 +120,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,7 +131,9 @@ 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 -- cgit v1.2.3-70-g09d2 From 228d7d1041e4f275e792390614b96bebc10759c0 Mon Sep 17 00:00:00 2001 From: MasterOfTheTiger Date: Fri, 5 Oct 2018 15:02:47 -0700 Subject: dirhistory: add README (#7239) --- plugins/dirhistory/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 plugins/dirhistory/README.md (limited to 'plugins/dirhistory') diff --git a/plugins/dirhistory/README.md b/plugins/dirhistory/README.md new file mode 100644 index 000000000..511f2be17 --- /dev/null +++ b/plugins/dirhistory/README.md @@ -0,0 +1,17 @@ +# Dirhistory plugin + +This plugin adds keyboard shortcuts for navigating directory history and hierarchy. + +To use it, add `dirhistory` to the plugins array in your zshrc file: + +```zsh +plugins=(... dirhistory) +``` +## Keyboard Shortcuts + +| Shortcut | Description | +|-----------------------------------|-----------------------------------------------------------| +| alt + left | Go to previous directory | +| alt + right | Undo alt + left | +| alt + up | Move into the parent directory | +| alt + down | Move into the first child directory by alphabetical order | -- cgit v1.2.3-70-g09d2