I have a key binding to go up by one directory (very useful):
# C-M-u: up-directory
up-directory() {
builtin cd .. && zle reset-prompt
}
zle -N up-directory
bindkey '\e\C-u' up-directory
It works well, except that the prompt is not really reset.
Example, starting in a Git repo (~/.dotfiles
):
After C-M-u
, I get:
So, I'm well one level up (into ~
), but the Git info is still there, while not valid anymore -- I'm not in a Git repo anymore…
How to fix this?
You probably need to execute the
precmds
before resetting the prompt.fzf's zsh integration does this:
So, try something like this: