My First Post      My Facebook Profile      My MeOnShow Profile      W3LC Facebook Page      Learners Consortium Group      Job Portal      Shopping


Thursday, November 14, 2019

How to show full working directory in mac terminal on every command

Problem description:
You can obviously use a pwd command to see the present working directory. For eg:

prompt$ pwd

But sometimes you want to show the full directory path every time. Its a common ask for eg:
/Users/mfaiz/myDir$ pwd

Or, better still you want the directory path to be displayed on top before each command. All such issues can be handled using your bash profile file:

vi ~/.bash_profile

You can add this line -
export PS1='\u@\H:\w$'

or, if you like having a space between the $ and the command, then - 
export PS1='\u@\H:\w$ '

Shown following are two more complex examples that include coloring as well:

Command used to achieve this is:


No comments:

Post a Comment