aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2021-02-16 01:38:27 +0900
committernsfisis <nsfisis@gmail.com>2021-02-16 01:38:33 +0900
commitd92788c97604de578e8392552c1ef6c81dd5cbba (patch)
tree292af99419db407b5c50ad0aae4d02321fbb6a1e
parentd0542c7a033c45d1760c17557bf5a582263af5f6 (diff)
downloaddotfiles-d92788c97604de578e8392552c1ef6c81dd5cbba.tar.gz
dotfiles-d92788c97604de578e8392552c1ef6c81dd5cbba.tar.zst
dotfiles-d92788c97604de578e8392552c1ef6c81dd5cbba.zip
Update .zshrc: add key bindings (^J, ^O and ^G)
-rw-r--r--.zshrc27
1 files changed, 27 insertions, 0 deletions
diff --git a/.zshrc b/.zshrc
index c82dda1..0436ad1 100644
--- a/.zshrc
+++ b/.zshrc
@@ -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