Using zsh, i would like to add a shortcut to go in parent directory. Easy peasy to do that
cdup() {
builtin cd ..
}
zle -N cdup
bindkey "your_favorite_key_code" cdup
But this does not redraw the prompt, anybody knows how to do it?
Binding shortcuts to do pushd/popd could be an idea too, to be honest i got those ideas from the "fish shell".
I've recently implemented the exact same thing. The best solution I can come up with is the following
cdup() {
cd ..
zle reset-prompt
}
The zle reset-prompt
is the bit that gets it to redraw the prompt.
Edit:
My previous version of the answer had a printf '\n'
in the answer. This was necessary if the prompt was a multi-line prompt. However zsh apparently has tons of issues with mutli-lines prompts, so I dropped it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With