Problem description:
You can obviously use a pwd command to see the present working directory. For eg:
prompt$ pwd
/Users/mfaiz/myDir
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
Solution:
You can add this line -
export PS1='\u@\H:\w$'
or, if you like having a space between the $ and the command, then -
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:
export PS1="\n$C_LIGHTGREEN\u$C_DARKGRAY@$C_BLUE\h $C_DARKGRAY: $C_LIGHTYELLOW\w\n$C_DARKGRAY\$$C_DEFAULT "
Shown following are two more complex examples that include coloring as well:
Command used to achieve this is:
export PS1="\n$C_LIGHTGREEN\u$C_DARKGRAY@$C_BLUE\h $C_DARKGRAY: $C_LIGHTYELLOW\w\n$C_DARKGRAY\$$C_DEFAULT "
No comments:
Post a Comment