aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2021-05-30 21:41:49 +0900
committernsfisis <nsfisis@gmail.com>2021-05-30 21:41:49 +0900
commit98be04b9ddb9ce3b0a8c41c74cb57460f1d872eb (patch)
treeb17b59f42ac6994782a06ccd8d336ee71bd446b4
parent33d1e3dca1531757b768a23777620a212804f529 (diff)
downloaddotfiles-98be04b9ddb9ce3b0a8c41c74cb57460f1d872eb.tar.gz
dotfiles-98be04b9ddb9ce3b0a8c41c74cb57460f1d872eb.tar.zst
dotfiles-98be04b9ddb9ce3b0a8c41c74cb57460f1d872eb.zip
Update .zshrc: improve __cd_* cmd
-rw-r--r--.zshrc6
1 files changed, 6 insertions, 0 deletions
diff --git a/.zshrc b/.zshrc
index 78e1678..eb2fb3f 100644
--- a/.zshrc
+++ b/.zshrc
@@ -218,6 +218,8 @@ bindkey "^U" backward-kill-line
# C-j To go to the parent directory.
function __cd_parent_dir() {
+ [ -e $BUFFER ] || return
+
pushd .. > /dev/null
zle reset-prompt
}
@@ -226,6 +228,8 @@ bindkey "^J" __cd_parent_dir
# C-o To go to the previous directory.
function __cd_prev_dir() {
+ [ -e $BUFFER ] || return
+
popd > /dev/null
zle reset-prompt
}
@@ -234,6 +238,8 @@ bindkey "^O" __cd_prev_dir
# C-g To go to the project root.
function __cd_project_root_dir() {
+ [ -e $BUFFER ] || return
+
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]]; then
pushd $(git rev-parse --show-toplevel) > /dev/null
zle reset-prompt