LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   A tweak for terminal prompt (https://www.linuxquestions.org/questions/linux-software-2/a-tweak-for-terminal-prompt-796992/)

t1nm@n 03-22-2010 02:37 AM

A tweak for terminal prompt
 
Hello , if u guys are usibg debaian or its derivative we can tweak out the terminal prompt. For example:
Quote:

ubuntu@ubuntu~#
If you are interested in tweaking. open up the .bashrc file in your home directory and add these lines
Quote:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]: ←֓
\[\033[01;34m\]\w\[\033[00m\]\$ '
←֓ replace this with :-) or any other thingy u can think of. 34 represents colour, in our case it is red. The result will be
Quote:

ubuntu@ubuntu: :-)
~$
this was seen in a book i read. if u have any doubt at all please post. i'm stll thinking of how i can remove the line saying "ubuntu@ubuntu" and just have "~$" at the prompt.
Have fun.

tinman.

kbp 03-22-2010 09:19 AM

Just a note - prompt customisation is not restricted to Debian and co. .. it will work with any bash:

color prompt example:
Code:

#------------------------------------------------------------------------
# ISO 6429 character sequences for colors etc
lc='\[\e[1;'
# foregrounds----backgrounds--------------------------------------------------
BLACK=${lc}30m;  B_BLACK=${lc}40m
RED=${lc}31m;    B_RED=${lc}41m
GREEN=${lc}32m;  B_GREEN=${lc}42m
YELLOW=${lc}33m; B_YELLOW=${lc}43m
BLUE=${lc}34m;  B_BLUE=${lc}44m
PURPLE=${lc}35m; B_PURPLE=${lc}45m
CYAN=${lc}36m;  B_CYAN=${lc}46m
WHITE=${lc}37m;  B_WHITE=${lc}47m
#------------------------------------------------------------------
BRIGHT=${lc}1m
UNDER=${lc}4m
FLASH=${lc}5m
RC=${lc}0m  # reset character
SEP="\\\$"  # separator
#------------------------------------------------------------------------
if [ "x${LOGNAME}" = "x" ]
then
  LOGNAME=$(whoami)
fi

# set pc, the prompt color
if [ "$USER" = "root" ]
then
  pc=$RED
else
  pc=$PURPLE
fi
#------------------------------------------------------------------------

# set the prompt
if [ $TERM  = "dumb" ]
then
  # no color if a dumb terminal
  pc=""; RC=""
fi

PS1="${pc}\]\u@\h \W\\$ ${RC}\]"
#PS1="${pc}\][\u@\h \w]$SEP${RC} "
#------------------------------------------------------------------------


cheers

t1nm@n 04-05-2010 12:18 PM

cool thanks for the info


All times are GMT -5. The time now is 09:41 AM.