With Terminal: Improving the appearance of the console

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 can see the changes 😀

 

Seen in: Humans.


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

17 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Luweeds said

    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¡¡

  2.   Eduardo said

    GENIALLLLLLLLLLLLLLL : )

    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.

    1.    KZKG ^ Gaara said

      A pleasure to know that it did just what you wanted 😉
      regards

  3.   Taregon said

    :] excellent if it does what I think I imagine ... weeee, I install it this weekend 😀

    1.    KZKG ^ Gaara said

      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

      1.    Eduardo said

        I get an error on lines 13 and 34.

        1.    elav <° Linux said

          We are already 2 😀

      2.    Courage said

        Fuck, another dark side programmer ...

        1.    KZKG ^ Gaara said

          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

  4.   newbie said

    Very nice this, I just tested it and it works 100% ubuntu 11.10

    Greeting!!

  5.   rob said

    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!

  6.   Jimselfking said

    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?

    1.    KZKG ^ Gaara said

      What you put in your .bashrc, you must also put it in /root/.bashrc
      Take the test and tell us how are you 🙂

      regards

      1.    Jimselfking said

        It works perfectly, I don't know how I didn't try it before asking. Thank you

        1.    KZKG ^ Gaara <° Linux said

          Nah don't worry 🙂

  7.   angel said

    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 🙂

  8.   Miguel said

    does this work the same in Debian ???