bash .bash_profile PS1 显示当前目录文件夹和 $ MAC osx
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28136724/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.bash_profile PS1 to show current directory folder and a $ MAC osx
提问by thedanotto
In my .bash_profile I currently have
在我的 .bash_profile 我目前有
PS1="$ "
which in my terminal returns '$ '
在我的终端中返回 '$'
I want to show the current folder as well.
我也想显示当前文件夹。
if I run the command, pwd /Users/Me/Sites/
如果我运行命令,密码 /Users/Me/Sites/
I would want my bash prompt to return 'Sites$'
我希望我的 bash 提示返回 'Sites$'
Thanks for all your help.
感谢你的帮助。
回答by Mikolaj
try this:
尝试这个:
PS1='\[3[01;32m\]\u@\h\[3[01;34m\] [\w]\[3[00m\]'
回答by Mark Shust at M.academy
Note that if you don't want brackets or colors surrounding the current directory, you can use the simpler:
请注意,如果您不希望当前目录周围有括号或颜色,则可以使用更简单的:
export PS1="\W$ "