Browse Source

zsh: add Alt-H keybinding for invoking h directory history alias

Brennen Bearnes 2 months ago
parent
commit
ea7c8b67a7
2 changed files with 14 additions and 4 deletions
  1. 2
    2
      home/.sh_common
  2. 12
    2
      home/.zshrc

+ 2
- 2
home/.sh_common View File

@@ -91,9 +91,9 @@ alias ct='cd `todaydir`'
91 91
 # I want here, but for the moment it's nice.  See: https://p1k3.com/2016/5/17/
92 92
 h () {
93 93
   if [ ! -z "$@" ]; then
94
-    cd $(tail -3000 ~/.directory_history | tac | unsorted-unique | fzf --no-sort --height=50% -q $@);
94
+    cd $(tail -3000 ~/.directory_history | tac | unsorted-unique | fzf --no-sort --height=50% -q $@)
95 95
   else
96
-    cd $(tail -3000 ~/.directory_history | tac | unsorted-unique | fzf --no-sort --height=50%);
96
+    cd $(tail -3000 ~/.directory_history | tac | unsorted-unique | fzf --no-sort --height=50%)
97 97
   fi
98 98
 }
99 99
 

+ 12
- 2
home/.zshrc View File

@@ -44,6 +44,8 @@ compinit
44 44
 
45 45
 # keybindings {{{
46 46
 
47
+  # You can get bindkey strings with Ctrl-v followed by your key sequence.
48
+
47 49
   # https://wiki.archlinux.org/index.php/Zsh#History_search
48 50
   # Search up/down for matching thing on arrows - you can still use ctrl-n /
49 51
   # ctrl-p to move up and down in the overall command history:
@@ -55,14 +57,14 @@ compinit
55 57
 
56 58
   # https://wiki.archlinux.org/index.php/Zsh#File_manager_key_binds
57 59
   # Alt-Left for previous directory and Alt-Up for parent
58
-  cd_undo_key() {
60
+  cd_undo_key () {
59 61
     echo
60 62
     popd
61 63
     zle reset-prompt
62 64
     ls
63 65
     zle reset-prompt
64 66
   }
65
-  cd_parent_key() {
67
+  cd_parent_key () {
66 68
     echo
67 69
     pushd ..
68 70
     zle reset-prompt
@@ -74,6 +76,14 @@ compinit
74 76
   bindkey '^[[1;3A' cd_parent_key
75 77
   bindkey '^[[1;3D' cd_undo_key
76 78
 
79
+  # Invoke h history function from .sh_common:
80
+  invoke_h () {
81
+    h
82
+    zle reset-prompt
83
+  }
84
+  zle -N invoke_h
85
+  bindkey '^[H' invoke_h
86
+
77 87
   # fzf fuzzyfinder for use with Alt-c, Ctrl-r, Ctrl-t:
78 88
   [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
79 89
 

Loading…
Cancel
Save