RSS

Color your shell

04 May

The UNIX terminal UI has stood the test of time. Tools change, new tools crop up, certain tools are used commonly and others less so. I don’t see the familiar UNIX terminal concept becoming obsolete any time soon. The extensibility and sheer power that comes with it is the best thing since sliced bread.

Now, I like colors and pretty pictures. More specifically, I find it much easier to recognize a piece of information if it is colored in a meaningful way, this is the whole reasoning behind syntax highlighting in IDEs. Luckily some other people like colors and pretty pictures too, and with the power of Free Software they have come up with various ways to add some color to common UNIX-compatible shell tools.

Some of these are just wrapper scripts for existing tools, and some are entire rewrites with lots of added functionality. Some distributions already provide a somewhat colored environment. Some of them contribute to making my shell a much more colorful place.

cw

cw is a color wrapper for common UNIX commands. According to the project’s website, “it is designed to simulate the environment of the commands being executed, so that if a person types ‘du’, ‘df’, ‘ping’, etc. in their shell it will automatically color the output in real-time according to a definition file containing the color format desired.”

cw wrapper scripts do not modify the functionality of the tools involved, they just add colors, so they are a good choice even if you alias some of them to other, more sophisticated tools. Some of the added colors are just eye candy, and some of them are actually very useful.

htop

htop is an interactive process viewer for Linux. It is not just a wrapper for top, this is a completely rewritten and much more featureful program. I alias it in my .bashrc in place of top.

dfc

I have tried at least three colored replacements and/or wrappers for df, and dfc is the one I like best. I keep it aliased in place of df.

Other note worthy alternatives include pydf (also very nice) and cdf.

cdu

cdu stands for “color du” and it is a Perl wrapper for du. I keep it aliased in place of du.

ls++

ls++ is a tool I’m currently still testing. It is a wrapper for plain old ls, it uses common color schemes for file types (as used by the –color parameter of GNU ls) and mangles the output a bit to make it more relevant. I like how it shows permissions and dates.

Other programs

For many prominent toolchain elements there is a colorized variant or wrapper, such as colordiff, colorgcc, colorsvn, colormake and others. Some of them actually already produce very good colored output with the right options (without wrappers), like grep or tree, and are easily aliased in .bashrc to always show colored output.

Combine all that with a nice LS_COLORS in .bashrc courtesy of dircolors and a nice colored prompt and your shell will make you puke rainbows in no time 😉

Lastly, as a bit of bonus content for Archlinux users I’d like to mention pacman-color and yaourt, they make pacman so awesome it’s not even funny.

Advertisements
 
18 Comments

Posted by on 04/05/2012 in Amarok, KDE

 

Tags: , ,

18 responses to “Color your shell

  1. eshatc

    05/05/2012 at 00:16

    This post was very useful to me. Thanks for sharing.

     
  2. Jeffery MacEachern

    05/05/2012 at 10:14

    A friend and I came up with this bashrc addition: http://paste.kde.org/452468/ (although the end result is all his code). It adds a green 😀 smiley to your prompt if the last command exited successfully, a red D: smiley if it failed, and a D’: if it segfaulted. It’s fun, and also useful because it gives you a quick at-a-glance status indicator.

     
  3. Rolinh

    05/05/2012 at 15:39

    Talking about colors for shell, zsh user will probably like this: https://github.com/zsh-users/zsh-syntax-highlighting. It colorizes commands as you type (green if it is a valid one, red otherwise), ‘foo’ in yellow, etc.
    You can also consider colorizing your shell prompt. For instance, display the path in prompt as red when you have no wright permission and green otherwise and so on.

    I totally agree that it’s nice to use colors in shell when they’re meaningfull 🙂

     
    • Teo

      05/05/2012 at 18:12

      Thanks, great suggestion. I had tried zsh a few years ago, I think I’m going to give it another spin with zsh-syntax-highlighting and see if I can get myself to puke even more rainbows 🙂

       
  4. pascalandreas

    05/05/2012 at 19:46

    great article. To bad not many of these tools and scripts are already packaged in ubuntu, then I have to consider whether I really trust them… E.g. the author behind ls++ is called trapd00r…. 🙂

     
  5. linduxed

    05/05/2012 at 22:30

    Very nice article, cw and dfc in particular are a great improvement.

     
  6. Ian

    05/05/2012 at 22:41

     
  7. skierpage

    06/05/2012 at 23:50

    Nice stuff. The problem I have with all colorizing is in Konsole on my LCD screen, the dark blue is very hard to read against the default black background. Is there a generic way to “make dark blue brighter” without editing each program’s settings? I tried increasing the brightness of Settings > Configure Current Profile > Appearance (Linux Colors) > Edit > Color 5 , but it didn’t seem to help.

     
  8. teprrr

    07/05/2012 at 14:42

    I’d also like to point out that colors in git are also pretty awesome, see http://jblevins.org/log/git-colors 🙂

    Thanks for those tips btw, unfortunately much of those are not packaged for Fedora at the moment…

     
    • Pascal

      07/05/2012 at 15:58

      Brilliant, I love it!

       
  9. westeros91

    26/05/2012 at 07:29

    Check out lolcat (https://github.com/busyloop/lolcat), if you haven’t already.

     

Leave a Reply

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

WordPress.com Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

 
%d bloggers like this: