Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何更改bash提示符以显示以前的工作目录?_Bash_Shell_Command Line_Prompt_Working Directory - Fatal编程技术网

如何更改bash提示符以显示以前的工作目录?

如何更改bash提示符以显示以前的工作目录?,bash,shell,command-line,prompt,working-directory,Bash,Shell,Command Line,Prompt,Working Directory,在我的~/.bashrc中 PS1='\w > ' 其中显示了当前的工作目录。 但我也想看看前一个。 像这样的 ~/Desktop () > ~/Desktop () > cd ../ ~ (/home/abgaryan/Desktop) > 您可以使用$OLDPWD: PS1='\w ($OLDPWD) > ' $PWD而不是\w应该为您执行此操作 您可以运行以下命令进行动态测试:export PS1=“$PWD” 可能已经知道了,但是确保我是新发布的:

在我的~/.bashrc中

PS1='\w > '
其中显示了当前的工作目录。 但我也想看看前一个。 像这样的

~/Desktop () > 
~/Desktop () > cd ../
~ (/home/abgaryan/Desktop) > 

您可以使用
$OLDPWD

PS1='\w ($OLDPWD) > '

$PWD而不是\w应该为您执行此操作

您可以运行以下命令进行动态测试:export PS1=“$PWD”


可能已经知道了,但是确保我是新发布的:-)

不起作用(我已经检查过了)。它总是显示相同的路径。您可以运行
env-ibash--norc
来获得一个干净的shell,然后将这篇文章中的行复制粘贴(而不是重新键入或调整)到该shell中吗?当您执行
cd/tmp
后接
cd/usr
时,它应该显示
/usr(/tmp)>
您可以在.bashrc中设置该命令并尝试运行它吗。提前谢谢。谢谢,现在好了$PWD将显示当前的一个。想看看之前的声音,你可能会做一些提示命令功能。edit:link:PROMPT_命令用于端子标题。但是我从前面的回复中得到了答案。谢谢伟大的我所说的一切都无关紧要,但如果有人在这件事上发生了。。。。PROMPT_命令在显示提示之前运行。。。。。(编辑该死的输入按钮)。。因此,如果您设置PROMPT_COMMAND=“date”,您的promt将如下所示:Mon Apr 26 23:32:50 UTC 2021[user]@[terminal]:~$really power really。。只需将提示命令设置为所需,将PS1设置为nothing即可。。