如何實現按zsh
進入shift+tab
父目錄並在 cmd 行開頭更新/列印新目錄?
目前的情況/行為:
~ % # pressing shift tab
~ % # (it did change to parent dir, but it does not show that)
我想:
~ % # pressing shift tab
/home % # change to AND print 'new' directory
我使用這個程式碼片段:
function parent_dir { cd .. }
zle -N parent_dir
bindkey '^[[Z' parent_dir
答案1
您需要重新繪製提示,這可以透過reset-prompt
zle 小工具完成。
因此,只需將您的parent_dir
功能擴展為
function parent_dir {
cd ..
zle reset-prompt
}