如何将终端提示更改为仅当前目录? [英] How to change the terminal prompt to just current directory?

查看:78
本文介绍了如何将终端提示更改为仅当前目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Macbook Pro,我想将其更改为当前目录,并在Terminal中将其更改为美元符号.我已经看过这些 资源来尝试解决此问题

I am using a Macbook Pro, and I wanted to change it to the current directory and a dollar sign prompt in Terminal. I've already looked at these resources to try and solve this issue.

我尝试修改〜/.bashrc文件并保存它,但是似乎没有用.

I tried modifying the ~/.bashrc file and saving it but it did not seem to work.

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
export PS1="\W$ "

最后一行是我添加的用于更改提示的内容.

The last line is what I added to change the prompt.

推荐答案

此操作应在.bash_profile(而不是.bashrc)中完成.

This should be done in .bash_profile, not .bashrc.

nano ~/.bash_profile

添加包含以下内容的行:

Add a line containing this:

export PS1="\W\$ "

.bashrc仅在启动子shell时执行. bash登录shell使用以下初始化脚本:

.bashrc is ONLY excuted when starting a sub-shell. bash login shell uses the following initialization scripts:

.bash_profile
.bash_login
.profile

这篇关于如何将终端提示更改为仅当前目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆