diff options
| author | nsfisis <nsfisis@gmail.com> | 2021-02-16 01:38:27 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2021-02-16 01:38:33 +0900 |
| commit | d92788c97604de578e8392552c1ef6c81dd5cbba (patch) | |
| tree | 292af99419db407b5c50ad0aae4d02321fbb6a1e | |
| parent | d0542c7a033c45d1760c17557bf5a582263af5f6 (diff) | |
| download | dotfiles-d92788c97604de578e8392552c1ef6c81dd5cbba.tar.gz dotfiles-d92788c97604de578e8392552c1ef6c81dd5cbba.tar.zst dotfiles-d92788c97604de578e8392552c1ef6c81dd5cbba.zip | |
Update .zshrc: add key bindings (^J, ^O and ^G)
| -rw-r--r-- | .zshrc | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -216,6 +216,33 @@ WORDCHARS="$WORDCHARS|:" # C-u To delete input from the cursor position to the beginning of the line bindkey "^U" backward-kill-line +# C-j To go to the parent directory. +function __cd_parent_dir() { + pushd .. > /dev/null + zle reset-prompt +} +zle -N __cd_parent_dir +bindkey "^J" __cd_parent_dir + +# C-o To go to the previous directory. +function __cd_prev_dir() { + popd > /dev/null + zle reset-prompt +} +zle -N __cd_prev_dir +bindkey "^O" __cd_prev_dir + +# C-g To go to the project root. +function __cd_project_root_dir() { + if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]]; then + pushd $(git rev-parse --show-toplevel) > /dev/null + zle reset-prompt + fi +} +zle -N __cd_project_root_dir +bindkey "^G" __cd_project_root_dir + + zmodload zsh/complist |
