這是由AUTO_NAME_DIRS
選項(默認情況下未啓用)引起的:
AUTO_NAME_DIRS
Any parameter that is set to the absolute name of a directory
immediately becomes a name for that directory, that will be used
by the `%~' and related prompt sequences, and will be available
when completion is performed on a word starting with `~'.
(Otherwise, the parameter must be used in the form `~param' first.)
換句話說,啓用AUTO_NAME_DIRS
只要你這樣做 project=/path/to/my/project
,~project
成爲/path/to/my/project
的縮寫。 這可讓您執行cd ~project
或ls -lh ~project
作爲該目錄的快捷方式。
如果你只是不喜歡在你的提示被顯示爲~project
的目錄,你可以 在您的及時更換%~
與%d
始終顯示的完整路徑。
如果您完全不想要這種行爲,請在您的配置中執行unsetopt AUTO_NAME_DIRS
。
如果您希望保留該選項,但在腳本中禁用該選項,那麼它不會使result
爲名稱dir,而是在腳本的頂部執行emulate -LR zsh
。這會在腳本運行時將所有選項暫時重置爲其默認值。最好的做法是始終在腳本中使用emulate -LR zsh
以防止發生這種奇怪的事情。事實上,這比做unhash -d result
來修復它更好。
目錄「show」在哪裏? –
你是什麼意思? – altschuler
不,我在問*你*你*的意思。 –