Shell Powertools

Shell Powertools

We all have those tools in our shed to make us more effective at what we do. For developers, these tools are often text editors, because a majority of what we do is edit code, which is mostly text. When I started writing code over 20 years ago, we didn't have the fancy wiz-bang IDEs that we have now. I used Emacs. For some of the people that I worked around, Emacs was the wiz-bang IDE. A lot of folks used Vi/Vim or even ed. I particularly liked Emacs because it was extremely customizable through the Lisp programming language, so if I didn't like how things worked, I could just go in and hack it to work the way I wanted.

I'm a Customization Freak

I hacked the hell out of my whole UNIX environment. If there was a dotfile that allowed me to configure something, I explored it and tweaked the hell out of it. I changed the colors to be loud and bright, I got rid of the titlebars and scrollbars on my X Windows, and I made it so that I could move around as much as possible without touching a mouse. That was one thing I always liked about X - while you couldn't necessarily customize the look of an application's UI, you could pretty much make the look of the window borders around the app look however you wanted, and to some degree, you still can.

I wasn't alone in this - lots of folks did the same thing, and I stole borrowed a lot of configurations from folks around me. I of course shared a lot of what I wrote as well. I even hacked my Zephyr messages to be formatted the way I wanted - nice and compact and only keeping relevant information. I'm a little lot older now, and I don't have as much time for hacking the look and feel of everything.

Why UNIX Shells Rock

Modern IDEs, where a lot of us hack on code, are a lot less customizable unless you are willing to hack the source. There is another tool, however, that a lot of us use, and it is still wildly customizable. Your shell.

Strangely, Windows 10 still comes with an MS-DOS shell, which is really one of the worst command-line interfaces on the planet. We made it work, but I avoid it like the plague. It just simply lacks the flexibility to do much that can't be done better with almost any other shell. Microsoft introduced PowerShell, which is a huge leap forward in terms of command-line functionality and scriptability, but it still launches in an MS-DOS window which is extremely clunky.

Finally, Microsoft got the hint that developers weren't in love with the shell experience that came as part of Windows, and the fact that developers just love Linux and other UNIX-based operating systems better. I still have hopes that one day Microsoft will throw in the towel and join the modern world of operating systems (if you dig inside Windows 10, you'll still find bits and pieces of Windows 95/NT in there, and it's been like 15 years, and they are old, outdated, and clunky to use), but I understand that it probably will never happen. Anyway, they introduced the Windows Subsystem for Linux, so now you can have a rich UNIX shell inside of Windows. Folks running Linux have been able to do incredible things for years that a lot of folks who only worked in Windows are finally able to do, and fortunately, Microsoft is embracing Linux now instead of trying to compete with it.

Some Tools to Make Your UNIX Shell Better

Now I have arrived at what I really wanted to talk about: some tools to make the UNIX shell even better. One thing I noticed back in my days at MIT was that some people never customized anything in their UNIX environment. It literally looked the same as the first day they used it. That is ok - I'm not going to say you have to customize things or tweak them. If you don't, however, you are going to spend a lot more time trying to get stuff done. The time you spend on little things like tweaking your shell will cut down the time you spend on routine tasks, and over time, that time savings will save you hours, days, weeks, or more in productivity.


First, let's talk about what shell you use. Back in my MIT days, the hot shell was the C shell or the Turbo C shell. Some folks also used the Bourne shell. No, not related to Jason Bourne, but rather Stephen Bourne. These early shells were great and got the job done. These days, it is mostly bash (the Bourne-Again shell), the Korn shell, Dash, or Zsh. I have no stats on this, but my impression is that bash is the leading contender, but zsh is making a lot of headway to become the leader. I'm still learning zsh, but I will say that since I've enabled it, I haven't looked back at bash. Here you can find some reasons why you should look into zsh.


You really need to look at oh-my-zsh though, because it will enhance your shell experience considerably. You can apply really powerful themes to it, and the one I use, agnoster, gives you powerful icons on the prompt that tell you a lot. Take a look at my prompt:


I've obscured the first part, which is my username and hostname (I can't share everything!), but as you can see, the second part is my current directory (Ghost is my blog publishing platform). The third part tells you that I'm in a git repo on the master branch. Not only that, it tells me that I have some changes that have not been added to the working set nor committed to the repo - if I commit or revert the changes, the background will change to green:


There is also a little wheel icon at the front that tells you a background process is running. If I become the super user, a lightning bolt tells you that you are running as a privileged user:


It will even tell me if the last command I ran failed:


There's lots more, but I got all this out of the box from oh-my-zsh using the angoster theme.


I have previously tweeted about tmux. Basically, it is a power tool that is focused around users that need to start up a bunch of shells and switch between them. This is incredibly empowering, especially when you are working on a remote machine over ssh and you don't have an easy way to just open another terminal with a keystroke. I use it a lot because I'm working on a cluster of machines and I'll have connections to multiple machines and I want to switch between the connections with one keystroke. I could describe it more and teach you how to use it, but really, you should just Google tmux tutorial and find some good tutorials on it. I stole borrowed a co-worker's tmux configuration which is really slick.


I previously tweeted about fzf as well. It's a seriously better way to search through your command history. The built-in Control-R works ok, but I often pass by the thing I'm looking for, and it gets all fudged up when I try to recover. fzf gives you a nice visual list, narrows the list as you type, and even allows you to use the arrow keys to navigate through the list. I saw a guy doing this during a demo at DockerCon 18 and saw how much easier it was. Take a look:


As you can easily see, I have 104 commands in my history, but I was able to narrow them down to 11 by typing vi (clearly I've been tweaking dotfiles today) and I was able to up-arrow to the .bashrc file I wanted to edit. Seriously easier.

The Ultimate Vimrc

One last one for today. A co-worker pointed me to his .vimrc file, which was inspried by the Ultimate Vimrc on GitHub. Now, whether it is actually the ultimate .vimrc is up for debate, but it enhances the vim UI and has lots of plugins. I've barely scratched the surface of what it can do, but the out-of-the-box configuration is already really nice:


You can clearly see what file I'm editing, that I'm in a file managed by git on the master branch, and that I'm in normal mode. If I go into insert mode, it becomes obvious:


One plugin I especially like is NERDTree, which essentially gives you a file explorer inside of vim. Yes, it's like it is a real IDE now.



This won't be the last post on developer power tools, because I'm always open to learning new ones, and as I learn these new tools, I'm likely going to blog tips and tricks here. So stay tuned.

Related Article