문제

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.

도움이 되었습니까?

해결책

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 like

PS1=\\w:\\u\$

will 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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top