View previous topic :: View next topic |
Author |
Message |
e980238 Tux's lil' helper
Joined: 13 Apr 2004 Posts: 89
|
Posted: Mon Jun 07, 2004 5:04 pm Post subject: HOWTO: Customize bash shell prompt |
|
|
Hey all,
I figured I would share how I customized the shell prompt for all of my terminals.
First make a file called /etc/prmpt This will define the colors based on the bash color codes which can be found in the link below, and also the special characters to add things to your prompt, like the time, current working dir, etc. have it contain this:
Code: |
BBLUE="\[\033[34;40m\]"
GRN="\[\033[37m\]"
CYAN="\[\033[36m\]"
PURP="\[\033[35m\]"
N="\[\033[0m\]"
B="\[\033[1m\]"
export PS1="$B$BBLUE[$N$GRN\\u$B$BBLUE]$N$B:$N$CYAN\\w$N\\$ $N"
|
Second, make a file (if it doesnt already exist) called /etc/bashrc and have it contain this:
Third, make sure your ~/.bashrc contains this. It will make it so that whenever you open a terminal or log into a text console, your prompt settings will get exported and will effectively be "turned on":
Code: |
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
|
this page http://www-106.ibm.com/developerworks/library/l-tip-prompt/ has some info on the escape characters and the colors which you can use and their coresponding color code.
Have fun! _________________ Theres no place like ::1 |
|
Back to top |
|
|
jftuga Tux's lil' helper
Joined: 21 Jan 2004 Posts: 139 Location: Athens, GA
|
Posted: Mon Jun 07, 2004 6:34 pm Post subject: |
|
|
First off, nice howto. I think a lot of people will be changing their prompts after reading your article.
Might it be advisable to wrap variable names in curly braces?
For example:
${BLUE} instead of $BLUE
-John |
|
Back to top |
|
|
BlindSpy Apprentice
Joined: 20 Mar 2004 Posts: 263
|
Posted: Mon Jun 07, 2004 11:34 pm Post subject: |
|
|
Code: | export PS1='\e[01;32m\]\H\e[01;34m\][\@]\$ \e[00m\]' |
someone wanna help me with the brackets on this one? I'm getting wrapping errors. |
|
Back to top |
|
|
pagerc@ufl.edu n00b
Joined: 02 Jan 2004 Posts: 15
|
|
Back to top |
|
|
e980238 Tux's lil' helper
Joined: 13 Apr 2004 Posts: 89
|
Posted: Tue Jun 08, 2004 11:56 am Post subject: |
|
|
Longer, yes. Better, no?
The "tip" in that post does not really, as you said, say howto do it. That is why I decided to start this post, so people would understand what to do with all of the variable exporting. _________________ Theres no place like ::1 |
|
Back to top |
|
|
BlindSpy Apprentice
Joined: 20 Mar 2004 Posts: 263
|
Posted: Wed Jun 09, 2004 7:02 pm Post subject: |
|
|
BlindSpy wrote: | Code: | export PS1='\e[01;32m\]\H\e[01;34m\][\@]\$ \e[00m\]' |
someone wanna help me with the brackets on this one? I'm getting wrapping errors. |
please? |
|
Back to top |
|
|
mholtz Tux's lil' helper
Joined: 04 Feb 2004 Posts: 110 Location: Ohio, USA
|
Posted: Tue Jun 22, 2004 3:08 am Post subject: |
|
|
Could someone explain to me how to make my root prompt use the same prompt as my normal user account when using the command su? It seems that by default su does not execute /root/.bashrc |
|
Back to top |
|
|
yuppienetworking Tux's lil' helper
Joined: 23 Feb 2004 Posts: 110 Location: Caracas - Venezuela
|
Posted: Tue Jun 22, 2004 4:13 am Post subject: |
|
|
Code: |
man su
...
su is used to become another user during a login session. Invoked with-
out a username, su defaults to becoming the super user. The optional
argument - may be used to provide an environment similiar to what the
user would expect had the user logged in directly.
....
|
I other words, when you su, you are not executing config files like .bashrc or .bash_profile. If you want to execute these files when su-ing try su - |
|
Back to top |
|
|
|