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 Answer
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.
-
What is an "effective UID"? UPD: nvm, found it: stackoverflow.com/a/32456814/322020– NakilonCommented Aug 7, 2016 at 0:13