
zsh可以設定提示為整個路徑嗎除了目前目錄?即~/a/b/c/
只是~/a/b/
?
我試著~/a/b/c
透過左右提示得到這個結果:
c/: | ~/a/b/
與我目前的重複相反c
:
c/: | ~/a/b/c/
c
如果目錄名稱很長,重複會浪費空間。
在裡面手動的我發現了我想要的以外的所有內容:
%-1~
- 路徑的第一個元素%1~
- 路徑的最後一個元素
而不是除了最後一個之外的所有
如何做呢?
答案1
# Before printing each prompt string, apply substitutions to it.
setopt promptsubst
# $PWD is always equal to the present working dir.
# :h chops off the last item of the path.
# (D) substitutes the start of the path with a named dir, such as ~, if possible.
# Note that this string is in 'single quotes'!
RPS1='${(D)PWD:h}'
噠噠!
文件: