Skip to content

Instantly share code, notes, and snippets.

@yuryshulaev
Last active December 19, 2017 11:28
Show Gist options
  • Save yuryshulaev/518d46f0dc0bfe83dfcb to your computer and use it in GitHub Desktop.
Save yuryshulaev/518d46f0dc0bfe83dfcb to your computer and use it in GitHub Desktop.
.zshrc with parent directory traversal shortcuts (Ctrl+Up — pushd .., Ctrl+Down — popd)
cd_parent_dir() {
[[ $(dirs | cut -f 1 -d ' ') != $(readlink -f `pwd`/..) ]] && pushd -q ..
zle reset-prompt
# print -Pn "\e]0;%~\a" # Tab title
}
cd_back() {
[[ $(dirs -v | wc -l) -ne 1 ]] && popd -q
zle reset-prompt
# print -Pn "\e]0;%~\a" # Tab title
}
bindkey '^[[1;5D' emacs-backward-word
bindkey '^[[1;5C' emacs-forward-word
zle -N cd_parent_dir
bindkey "^[[1;5A" cd_parent_dir
zle -N cd_back
bindkey "^[[1;5B" cd_back
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment