zsh 使用 Shift Tab 移到父目錄

zsh 使用 Shift Tab 移到父目錄

如何實現按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-promptzle 小工具完成。

因此,只需將您的parent_dir功能擴展為

function parent_dir {
  cd ..
  zle reset-prompt
}

相關內容