Tuesday 3 March 2015

Creating a custom bash prompt

Here is an easy tip for those who like to customize the bash prompt of his server.

The bash prompt of my server looks as below, with name "localhost"

I don't like to see localhost on my server, I want it to be customized with my name.

So, here is an easy step:

Create a file named "/etc/profile.d/custom_prompt.sh".

Enter the below content to the file:
export PS1='[root@MANINMANOJ]#'

Now, the file looks as below snippet:
[root@MANINMANOJ]#cat /etc/profile.d/custom_prompt.sh
export PS1='[root@MANINMANOJ]#'

Execute the script using sh:
sh /etc/profile.d/custom_prompt.sh

Now, logout and login again to the shell.  

You will see that the bash prompt changed.

No comments:

Post a Comment

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