iTerm 2 名称长度
我是 OSX 新手,已经下载了 iTerm 2,但我的命令行名称过长。
它看起来像 my-name-Macbook-pro:~ myname$
并且我希望它看起来像 ~myname$
有没有一种简单的方法来缩短这个名称,我已经尽可能多地用谷歌搜索,但找不到一个简单的解决方案。
I am new to OSX and have downloaded iTerm 2 and my name for the command line is superfluously long.
It looks like my-name-Macbook-pro:~ myname$
and I want it to look like ~myname$
Is there an easy way to shorten this name, I have googled as much as I can but can't find an easy solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这与 OSX 或 iterm2 无关。 OSX 默认使用 bash shell,您只需正确设置提示符即可。
提示由变量
PS1
设置。请参阅这篇文章了解如何设置bash 提示符。为了实现您想要的效果,您需要\w
和\u
字段。所以类似的东西会给你
~:myname$
。尝试一下其他选项,看看你最喜欢哪个。找到所需的设置后,请将其输入到.bashrc
文件中,以便每次登录时都会加载它。另请参阅此问题,了解可放入.bashrc
中的精彩内容。This has nothing to do with OSX or with iterm2. OSX by default uses the bash shell and you just need to set the prompt correctly.
The prompt is set by the variable
PS1
. See this article on how to set your bash prompt. To achieve what you want, you need the\w
and the\u
fields. So something likewill give you
~:myname$
. Play around with the other options and see what you like best. Once you find a setting that you like, enter it in your.bashrc
file so that it is loaded every time you login. Also see this question for cool stuff to put in your.bashrc
.