Tuesday, December 10, 2013

Mac OSX bash prompt

Put this in .bash_profile

export PS1="\w\$ "

This will considerably shorten your bash prompt to display only the working directory instead of the default which also displays computer name and user name.

We can display those as well by playing around with the defaults:

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

\h = First part of host name
\W = Directory name (notice this is uppercase rather than the lowercase I used above.  Lowercase w means the entire directory path; uppercase W means just the working directory)
\u = Username
\$ = If not root, display $ (otherwise display #)

There are other "magic" symbols that can be used - see http://www.ibm.com/developerworks/linux/library/l-tip-prompt/


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.