summaryrefslogtreecommitdiff
path: root/plugins/dirhistory/dirhistory.plugin.zsh
diff options
context:
space:
mode:
authorFrancisco Zuviría <FranciscodeZuviria@fusap.com.ar>2018-04-22 22:34:26 -0300
committerFrancisco Zuviría <FranciscodeZuviria@fusap.com.ar>2018-04-22 22:34:26 -0300
commit7bb7ce62d3a78859aa15151ecc46df5adc9cf049 (patch)
treec4aa7a31f0f1cc33951397fa43e6c73fe67a0839 /plugins/dirhistory/dirhistory.plugin.zsh
parent604f580f0546aefd6aef00b1a1943d68f4cebae6 (diff)
downloadzsh-7bb7ce62d3a78859aa15151ecc46df5adc9cf049.tar.gz
zsh-7bb7ce62d3a78859aa15151ecc46df5adc9cf049.tar.bz2
zsh-7bb7ce62d3a78859aa15151ecc46df5adc9cf049.zip
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
Diffstat (limited to 'plugins/dirhistory/dirhistory.plugin.zsh')
-rw-r--r--plugins/dirhistory/dirhistory.plugin.zsh50
1 files changed, 50 insertions, 0 deletions
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