2

My OSX El Capitan terminal prompt is "~$". As I am logged in as a user.
How can I get it to show the machine~user$ instead? Thanks

1

1 Answer 1

5

Assuming your shell is bash edit the /etc/bashrc file changing PS1='\W\$ ' to:

PS1='\h:\W \u\$ '

You'll need to use sudo, e.g., sudo nano /etc/bashrc

On OS X 10.11 you might also need to disable SIP in order to make the edit.

Otherwise setting it in your ̃/.bash_profile or ~/.profile file, either of which, you'd not have to use sudo or disable SIP to edit.

Explanation:

PS1='\h:\W \u\$ '

PS1 The value of this parameter is expanded (see PROMPTING below) and used as the primary prompt string.
=   equals
'   single quote
\h  the hostname up to the first ‘.’
:   colon
\W  the basename of the current working directory, with $HOME abbreviated with a tilde
    white space
\u  the username of the current user
\$  if the effective UID is 0, a #, otherwise a $
    white space
'   single quote

Examples:

MacBookPro:~ user$
MacBookPro:Documents user$
MacBookPro:~ root#

See the PROMPT_COMMAND and PROMPTING sections in the OS X Man Pages for BASH(1) for more information on the subject.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .