Navigating in a Linux using shell can be a bit tedious, especially considering user sometimes will not be aware of his/her current working directory.
some of the examples of bash prompts looks like below.
each of these prompts can be customized to provide a more meaningful prompt, an example shown below
Step-1: Login to terminal which probably looks like this.
Step-3: Finally once done on selecting bash prompt copy paste the lines in to ~/.bashrc file.
Here is a example of bashrc file contents.
That's all you now have a customized bash prompt ready.
some of the examples of bash prompts looks like below.
etc etc etc.$
#
bash::$
sh:$
sh:#
each of these prompts can be customized to provide a more meaningful prompt, an example shown below
[break-it@foo-bar-host ~]$
break-it - Current User Name
foo-bat-host - host name
~ - current working directory
on a whole translates to break-it is now logged on to system foo-bar-host working under home directory ( ~ is nothing but user`'s HOME )Below are a few steps needed to customize bash prompt
Step-1: Login to terminal which probably looks like this.
$
$
$
Step-2: lets start modifying type below lines on bash prompt and press enter
$There you go the new bash prompt. The trick here is to provide what ever you want as prompt to PS1 variable. for instance lets modify the prompt a bit more.
$ PS1="my-bash-$ "
my-bash-$
my-bash-$
my-bash-$or change to this
my-bash-$ PS1='Hey, `whoami` Type-in your command Here # '
Hey, break-it Type-in your command Here #
Hey, break-it Type-in your command Here #
$or this
$
$ PS1='[`whoami` `date +%F`] #'
[break-it 2015-09-06] #
[break-it 2015-09-06] #
$$ PS1='[`whoami` `date +%F`] #'[break-it@foo-bar-host ~] #
Step-3: Finally once done on selecting bash prompt copy paste the lines in to ~/.bashrc file.
Here is a example of bashrc file contents.
myname=`whoami`
myhost=`hostname`
export PS1='[$myname@$myhost `pwd`]$ '
No comments:
Post a Comment