Saturday, 25 July 2015

Fun with Linux: Change Default Text in Bash

Got bored of the default text shown in bash and want to personalize it a bit? Then this post is for you!

Fun With Linux : Change Default Text in Bash



By default, in ubuntu, the terminal shows up something like:

ubuntuuser@niks-VirtualBox:~$

You can easily change it by modifying the PS1 variable using the command:

PS1="My favourite quote here: "

To see the current value of the variable PS1, type:

echo $PS1

Ubuntu2

You can use some special characters to display a whole lot of information such as:

\u : Display username
\d : Display date
\t : Display time
\h : Display hostname
\# : Display command number
\W : Display current working directory (the folder you are currently in)
\w : Display full path of the current directory
\a : Audible bell (a sound is heard whenever a command completes executing)

Ubuntu3

Ubuntu

But, these changes will be temporary and will disappear once you exit and reopen the terminal. To make these changes persistent, change the PS1 variable in the .bashrc file stored in the home directory (home/ubuntuuser or home/whatever your username is). Remember, .bashrc is a hidden file. So, open the home directory and press Ctrl+h to show hidden files, then open up the .bashrc file in your favourite text editor, make changes and save it. Have fun ;)

No comments:

Post a Comment