在MacOS X上更改VSCode集成外壳程序的提示符 [英] Changing the VSCode integrated shell's prompt on MacOS X
问题描述
我刚刚注意到VScode,因为它在OSX上默认使用Bash,外壳的默认提示符为 bash-3.2 $
;因此,我看不到当前的工作目录.这意味着必须经常键入"pwd"和"ls",这很繁琐.
Having just installed VScode I have noticed as it uses Bash by default on OSX, with the shell's default prompt of bash-3.2$
; consequently, I cannot see the current working directory. It means having to type 'pwd' and 'ls' quite frequently which is obvious quite tedious.
我尝试将设置中的默认外壳更改为
I have tried changing the default shell in the settings to
"terminal.integrated.shell.osx": "/Applications/Utilities/Terminal.app"
或
"terminal.integrated.shell.osx": "/Applications/iTerm.app"
这似乎不起作用,我在这里犯了一个错误吗?
This doesn't seem to work, have I made a mistake here?
我还想知道我是否仅限于bash,是否可以将其配置为显示工作目录,而不是简单地显示 bash-3.2 $
吗?
I would also like to know if I am limited to bash, can I configure it to display the working directory instead of simply bash-3.2$
?
请参见 VSCode集成终端默认外观的屏幕截图预先感谢!
推荐答案
您可以通过如下定义 PS1
来设置包含当前工作目录的提示:
You can set your prompt to contain the current working directory by defining PS1
as follows:
PS1="\w $"
$
只是一些视觉上的糖.您可以通过各种方式显示提示.将定义放入您的〜/.bashrc
或〜/.profile
中,以便在登录时进行设置.
The $
is just some visual sugar. There all manner of things you can have your prompt display. Put the definition in your ~/.bashrc
or ~/.profile
for it to be set when you login.
查看控制提示有关详细信息,请参见GNU Bash手册.
Check out the Controlling the Prompt section of the GNU Bash manual for details.
如果您不习惯于编辑 bash
初始化文件,则可以使用 Visual Studio Code
进行操作,方法是转到 View-> Command Palette .code>并执行以下命令(仅一次):
If you are not accustomed to editing your bash
init files you can do it with Visual Studio Code
by going to View->Command Palette
and execute the following command (one-time only):
Install 'Code' command in path
然后打开集成终端并输入以下内容:
Then open the integrated terminal and type the following:
code ~/.bashrc
然后将 PS1
定义添加到该文件的底部.
Then add the PS1
definition to the bottom of that file.
这篇关于在MacOS X上更改VSCode集成外壳程序的提示符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!