command prompt setting for my sanity

I have finally decided to change my usual command prompt setting to avoid countless times of typing pwd, ls -l, stuff like that. If you find yourself typing a lot of certain commands to just get the status of your current directory, then I suggest you to take a look at the following so you may save some typing in the long run.

Here you go. I am using the bash shell btw. All changes should go into your local ~/.bash_profile .


Perhaps you have some applications you installed but they are not at the usual /usr/bin path. This is how to append/prepend another path to the $PATH env var.

export PATH=/usr/local/mysql/bin/:$PATH

Command prompt

Your usual command prompt is set as: PS1=’h:W u$ ‘. What that means is, h is your host name until the dot, W is the basename of the full path of your pwd, u is your username. The problem I have here is that, W will print the same thing both when you are at /path/dirA and /path/blah/blah/blah/dirA . I often find myself typing pwd again and again. To fix that, use w. Here is the setting:

PS1='h:w u$ '

ls color

When you make an ls call, all directories and files and links are all printed out in the same way. I often will need to do another “ls -l” to see what they really are, not to mention the long list of output. How nice if the output is color-coded. Here is the setting to print out different colors for directories, files, and links.

export CLICOLOR=1
export LSCOLORS=EgFxCxDxBxegedabagacad

Below is the reference to the above setting string.

LSCOLORS       The value of this variable describes what color to use
                     for which attribute when colors are enabled with
                     CLICOLOR.  This string is a concatenation of pairs of the
                     format fb, where f is the foreground color and b is the
                     background color.

                     The color designators are as follows:

                           a     black
                           b     red
                           c     green
                           d     brown
                           e     blue
                           f     magenta
                           g     cyan
                           h     light grey
                           A     bold black, usually shows up as dark grey
                           B     bold red
                           C     bold green
                           D     bold brown, usually shows up as yellow
                           E     bold blue
                           F     bold magenta
                           G     bold cyan
                           H     bold light grey; looks like bright white
                           x     default foreground or background

                     Note that the above are standard ANSI colors.  The actual
                     display may differ depending on the color capabilities of
                     the terminal in use.

                     The order of the attributes are as follows:

                           1.   directory
                           2.   symbolic link
                           3.   socket
                           4.   pipe
                           5.   executable
                           6.   block special
                           7.   character special
                           8.   executable with setuid bit set
                           9.   executable with setgid bit set
                           10.  directory writable to others, with sticky bit
                           11.  directory writable to others, without sticky

                     The default is "exfxcxdxbxegedabagacad", i.e. blue fore-
                     ground and default background for regular directories,
                     black foreground and red background for setuid executa-
                     bles, etc.

ls output – directory

Sometimes color coded output still isn’t enough. It’s still not obvious enough for me to recognize the directories/folders. That’s when I want to see the extra “/” at the end of them. Here is the command.

alias ls='ls -p'

Hope these settings can save your typing. 😉

More reading:

One thought on “command prompt setting for my sanity

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s