Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
即使我cd进入符号链接,是否可以让我的 shell 显示完整的当前工作目录?我目前的PS1阅读
cd
PS1
PS1=" [ \w ] => "
但是,当我 cd 进入链接目录时,它会显示(例如)[ ~/LINKEDDIR ]而不是对我更有用的东西,例如[ /var/etc/bin/the/actual/path ].
[ ~/LINKEDDIR ]
[ /var/etc/bin/the/actual/path ]
有没有办法改变它?
\w您必须pwd直接调用该实用程序并使用其-P选项来完全展开任何符号链接,而不是使用转义序列。以下应该可以工作(注意单引号,以便在每次显示提示时执行命令替换,而不是在PS1定义时只执行一次)。
\w
pwd
-P
PS1='\n[ $(pwd -P) ]\n=> '