Saturday, September 15, 2012

Shorten user name, host name and path in terminal

Sometimes, it is very annoying to have a long account name and path in the Linux terminal. It will make us difficult to work in terminal because the text is long and not shown clearly. One of the solution is to make it shorter both of account name and path name.
For example, here is account name in terminal:
I want to make it shorter, so it will become:
To make that work, let's edit .bashrc in your home directory, and find the following,

    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
Then, change to
    PS1='${debian_chroot:+($debian_chroot)}bta@g580:\W\$ '
The parameter \u and \h will change the user name and host name shown in terminal, the changing of \w to \W will make the last current path instead of whole path shown in terminal. The other parameters are shown below,

\t - time

\d - date

\n - newline

\s - Shell name

\W - The current working directory

\w - The full path of the current working directory.

\u - The user name

\h - Hostname

\# - The command number of this command.

\! - The history number of the current command

Related Posts Plugin for WordPress, Blogger...