What’s my directory?

We know that we can find our present directory using the pwd command on the Linux shell. What if you want it displayed as part of your shell prompt?

  • Open the .bashrc file in your home directory.
  • Add this line to the file:
export PS1='\[`[ $? = 0 ] && X=2 || X=1; tput setaf $X`\]\h\[`tput sgr0`\]:$PWD\$ '
  • Restart the shell. Viola, your done 🙂




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s