I am one of those who loves to use the terminal. I think all users of GNU / Linux At one point they can't live without it, because that piece of window full of letters makes life a lot easier for us, right?
But we can make it look a little prettier than the default. An example of this can be seen (and downloaded) from gnome-look. The tips that I will show you next, is to leave our terminal with the following appearance:
As you can see, the command to execute and is put between each order a timeline with the system time.
How do I do it?
We open a text editor (example Gedit) and we put it inside:
# Fill with minuses
# (this is recalculated every time the prompt is shown in function prompt_command):
fill="--- "
reset_style='\[\033[00m\]'
status_style=$reset_style'\[\033[0;90m\]' # gray color; use 0;37m for lighter color
prompt_style=$reset_style
command_style=$reset_style'\[\033[1;29m\]' # bold black
# Prompt variable:
PS1="$status_style"'$fill \t\n'"$prompt_style"'${debian_chroot:+($debian_chroot)}\u@\h:\w\$'"$command_style "
# Reset color for command output
# (this one is invoked every time before a command is executed):
trap 'echo -ne "\e[0m"' DEBUG
function prompt_command {
# create a $fill of all screen width minus the time string and a space:
let fillsize=${COLUMNS}-9
fill=""
while [ "$fillsize" -gt "0" ]
do
fill="-${fill}" # fill with underscores to work on
let fillsize=${fillsize}-1
done
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
bname=`basename "${PWD/$HOME/~}"`
echo -ne "\033]0;${bname}: ${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"
;;
*)
;;
esac
}
PROMPT_COMMAND=prompt_command
We keep it inside our / Home with the name .bash_ps2 for example. Then we open our .bashrc and we add:
if [ -f "$HOME/.bash_ps2" ]; then
. "$HOME/.bash_ps2"
fi
We open a terminal and we will be able to see the changes
Seen in: Humans.
Thanks for the blog first of all and a question, is there any possibility to customize xterm or lxterminal beyond the color of the text and the background? (They are the terminals that I use the most).
Gracias¡¡
GREATLLLLLLLLLLLLLL : )
I tried it a week ago when I read this topic in another blog, but because of a problem with the quotes in what had to be added to the .bashrc I couldn't use it. Now it worked correctly for me first.
Thank you.
A pleasure to know that it did just what you wanted 😉
regards
:] excellent if it does what I think I imagine ... weeee, I install it this weekend 😀
In fact I improved it hehe ... I put more blushes and it looks much better, I'll make a post publishing my improvements and modifications
Edited: Instead of putting that in .bash_ps2 put this another: http://paste.desdelinux.net/paste/6
I get an error on lines 13 and 34.
We are already 2 😀
Fuck, another dark side programmer ...
I leave the code here, I don't know why it gives them an error ... o_0U works fine for me:
# Fill with minuses
# (this is recalculated every time the prompt is shown in function prompt_command):
fill="--- "
reset_style='\[\033[00m\]'
status_style=$reset_style'\[\033[0;90m\]' # gray color; use 0;37m for lighter color
prompt_style=$reset_style
command_style=$reset_style'\[\033[1;29m\]' # bold black
# Prompt variable:
PS1="$status_style"'$fill \t\n'"$prompt_style"'${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m$
# Reset color for command output
# (this one is invoked every time before a command is executed):
trap 'echo -ne "\e[0m"' DEBUG
function prompt_command {
# create a $fill of all screen width minus the time string and a space:
let fillsize=${COLUMNS}-9
fill=""
while [ "$fillsize" -gt "0" ]
do
fill="-${fill}" # fill with underscores to work on
let fillsize=${fillsize}-1
done
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
bname=`basename "${PWD/$HOME/~}"`
echo -ne "\033]0;${bname}: ${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"
;;
*)
;;
esac
}
PROMPT_COMMAND=prompt_command
Very nice this, I just tested it and it works 100% ubuntu 11.10
Greeting!!
Well, I also get an error on lines 13 and 34
line 13: Unexpected EOF while searching for a matching ``
line 34: syntactic error: the end of the file was not expected
I use linux mint 11 lxde for what it's worth.
Regards!
It works 100% with the normal user, but the moment you become superuser it stops working, it does nothing. I guess it's easy, but I don't know how to do much, any solution?
What you put in your .bashrc, you must also put it in /root/.bashrc
Take the test and tell us how are you 🙂
regards
It works perfectly, I don't know how I didn't try it before asking. Thank you
Nah don't worry 🙂
Hey friend, if you will help me please I tried it but the circle does not appear and it is still in black, I use fedora19, the timeline does appear… anyway, thank you very much for your contribution 🙂
does this work the same in Debian ???