![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
Tutorials & Tips The place to find Ubuntu related Tips & Tricks. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
100% Pure Ubuntu
![]() |
HOWTO: Customize terminal header
By default, the terminal header is a bit boring and unattractive. This format is determined by your ~/.bashrc file. By default there will be many lines, most of which don't matter. We want the PS1 line (which determines what to show) looks like the following:
Code:
PS1='[\u@\h \W]\$ ' Code:
\a an ASCII bell character (07)
\d the date in "Weekday Month Date" format (e.g., "Tue May 26")
\D{format}
the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format
results in a locale-specific time representation. The braces are required
\e an ASCII escape character (033)
\h the hostname up to the first `.'
\H the hostname
\j the number of jobs currently managed by the shell
\l the basename of the shell's terminal device name
\n newline
\r carriage return
\s the name of the shell, the basename of $0 (the portion following the final slash)
\t the current time in 24-hour HH:MM:SS format
\T the current time in 12-hour HH:MM:SS format
\@ the current time in 12-hour am/pm format
\A the current time in 24-hour HH:MM format
\u the username of the current user
\v the version of bash (e.g., 2.00)
\V the release of bash, version + patch level (e.g., 2.00.0)
\w the current working directory, with $HOME abbreviated with a tilde
\W the basename of the current working directory, with $HOME abbreviated with a tilde
\! the history number of this command
\# the command number of this command
\$ if the effective UID is 0, a #, otherwise a $
\nnn the character corresponding to the octal number nnn
\\ a backslash
\[ begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into
the prompt
\] end a sequence of non-printing characters
Code:
Black 0;30 Dark Gray 1;30 Blue 0;34 Light Blue 1;34 Green 0;32 Light Green 1;32 Cyan 0;36 Light Cyan 1;36 Red 0;31 Light Red 1;31 Purple 0;35 Light Purple 1;35 Brown 0;33 Yellow 1;33 Light Gray 0;37 White 1;37 Code:
PS1='\[\e[0;34m\][\W]\[\e[m\] ' Code:
PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$ \[\e[m\]\[\e[1;37m\] ' **If any of this makes no sense, please let me know and I'll try to expand it. |
|
|
|
|
|
#2 | |
|
Dark Roasted Ubuntu
![]() Join Date: Jan 2006
Location: Edge of Time
My beans are hidden!
Ubuntu 9.04 Jaunty Jackalope
|
Re: HOWTO: Customize terminal header
Quote:
Code:
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color)
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
;;
*)
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
;;
esac
# Comment in the above and uncomment this below for a color prompt
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
;;
*)
;;
esac
Thanks. |
|
|
|
|
|
|
#3 |
|
100% Pure Ubuntu
![]() |
Re: HOWTO: Customize terminal header
Remember you posted this here so you can revert it if I'm wrong. However, notice the two PS1 lines at the beginning? They are essentially the same thing, one is just in color. So I'm just going to comment them out, then put your own PS1 line somewhere, preferably at the beginning, and see if that works.
Code:
# set a fancy prompt (non-color, unless we know we "want" color)
#case "$TERM" in
#xterm-color)
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# ;;
#*)
# PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
# ;;
#esac
# Comment in the above and uncomment this below for a color prompt
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
;;
*)
;;
esac
|
|
|
|
|
|
#4 |
|
First Cup of Ubuntu
![]() Join Date: Jan 2008
Beans: 3
|
Re: HOWTO: Customize terminal header
Just append it to the bottom of the file. It will just override any previously set ones.
Here's mine: Code:
PS1='\n[\[\e[36;40m\]\u\[\e[0m\]] \[\e[32;40m\]\W \[\e[0m\]\$ ' |
|
|
|
|
|
#5 |
|
Dark Roasted Ubuntu
![]() Join Date: Jan 2006
Location: Edge of Time
My beans are hidden!
Ubuntu 9.04 Jaunty Jackalope
|
Re: HOWTO: Customize terminal header
@PurposeOfReason: Hey, that worked. Thanks. I thought maybe the bit about ${USER}@${HOSTNAME} had to change as that's what I normally have as part of the prompt. Guess not. That's one confusing file though.
Last edited by m.musashi; January 24th, 2008 at 10:43 PM.. Reason: clarify |
|
|
|
|
|
#6 | |
|
A Carafe of Ubuntu
![]() |
Re: HOWTO: Customize terminal header
If you want to try it out first to see what it does, simply type "export " then your PS1=... part so it would look like
Quote:
This doesn't do anything to any files, it just changes it for that one window. |
|
|
|
|
|
|
#7 |
|
Gee! These Aren't Roasted!
![]() Join Date: Aug 2007
Location: Cluj/Kolozsvár, Romania
Beans: 189
|
Re: HOWTO: Customize terminal header
hey, this is a very fine little thread.
how about making a collection of terminal headers people are using? |
|
|
|
|
|
#8 |
|
First Cup of Ubuntu
![]() |
Re: HOWTO: Customize terminal header
wow!! i didn't even know that something like ~/.bashrc existed, thanks a lot guys
Last edited by thyultimate; March 3rd, 2008 at 03:13 PM.. Reason: oops sorry wrong thread, cant i delete this post?? |
|
|
|
|
|
#9 | |
|
Ubuntu Extra Shot
![]() |
Re: HOWTO: Customize terminal header
Hey I have a question I was playing with my colors and I got a color I really like but cant get it again.
Could some one tell what to put in to get the color I have include a picture of it.
__________________
Quote:
|
|
|
|
|
|
|
#10 |
|
100% Pure Ubuntu
![]() |
Re: HOWTO: Customize terminal header
|
|
|
|
| Bookmarks |
| Tags |
| header, terminal |
| Thread Tools | |
| Display Modes | |
|
|