Pimp my Prompt
Becoming a UNIX ninja was always a bit of an ambition of mine. Though i’d never consider myself a hacker, “non-computer-people” often call me that.
They all go like: “C’mon, you’re a hacker, you can do this!” or “I heard you’re so good with computers, you must be a little bit of a hacker!” – call me names, but i sometimes really love to show off a bit when my Terminal is up and i could throw some commands at it and the console would spit out lines that no mortal man would ever understand, thus staring at me in awe, thinking of me as some sorts of IT god when actually i was just pulling a commit.
So it seems that when someone from the outside world sees you typing some cryptic commands in bright green letters into the black of a terminal window, it looks to them like you would actually just be hacking the Matrix.
I am also really fond of the 80s inspired actual monochromatic terminal design, which is usually the first thing i do on a machine, change the shell color scheme. Yeah i know – i somehow got stuck in the 80s.
Glad it was music and computers, not hairstyles and clothing though.
But back to topic – it’s not only just for shows that we wanna improve those good old Shell skills, but it’s really gonna be boosting your productivity once you learn how to “shape the matrix in your own imagination”, meaning, use the command line to do your bidding.
How to become a command line show off super hero hacker
First, switch from Bash to ZSH. There’s tons of reasons why ZSH is better and cooler and more awesome thatn Bash. Generelly, let’s just say it does better tab-autocompletion and thus let’s you navigate your directory structure much faster.
Oh my, ZSH!
While you’re at it, also get oh-my-zsh. It’s sort of a kickstarter for ZSH on OSX. Find a theme to your liking there (there’s probably more than you can handle at first). Pick one that pleases you visually. “kphoen” is the one i’m stuck at for the moment. It has the colors i like and nice added git repository info integrated in the prompt.
The mythical Vim god?
Then it’s time to learn the basics, if you haven’t yet. Use vim for a while. It’s crazy complicated at first, but you’ll quickly learn the basics.
Learn how to navigate, search for text, copy and paste multiple lines, things like that. Stuff that would make it easy to extend your local PHP or Apache configuration easily even on a foreign server with only the bare minimums installed.
At some point, i though of becoming a power user of vim. There’s sort of like these mythical stories that i used to heard from some of my programmer friends . They would tell about people who “totally do everything imaginable in vim”. I guess it’s possible to use vim as a full stack IDE of sorts, but then again, honestly, for the everyday Web Developer needs, it probably wouldn’t be worth the effort and the learning curve. Plus, there just are better tools out there, like Sublime Text for example. I just fell in love with Sublime Text recently, there’s so many lovely plugins for it, i never could imagine. I also just noticed that “The Text Editor you’ll fall in love with” is sort of their slogan. The metaphor is good though, as far as you can fall in love with such a thing as a piece of software.
Back to command line stuff for now. As i said, it’s good to know the basics, in case you ever have to SSH into some server, vim or vi is usually the editor that is available on every imaginable (UNIX based) system.
Putting the Command in the Command line
Next, learn how to do “stuff” with the command line – the actual things you would do with a GUI normally, such as copying files, creating directories, finding files, even finding text inside files. Reading out logs. Get familiar with the concept of “piping”.
There’s good reads out there that will get you going with the basic commands in no time:
- Linux / UNIX Basic Command Line Tutorial
- A Command Line Primer for Beginners
- Become a Command Line Ninja With These Time-Saving Shortcuts
Then, when you know all those basics, it’s time to get some additional tools that will make everything easier again:
- iTerm – the Better Terminal Application for Mac
- z – a small bat hugely useful script for folder hopping
- ack – a tool like grep, but optimized for programmers
Configuration uber alles
It’s always nice to be able to customize everything to the point where your workflow and productivity becomes so awesomely supercharged that you’re almost able to hear the wooshing sound of things getting done at the push of a key on your keyboard.
You can customize a lot about the appearance of your shell prompt and configure various aliases for commands you use a lot. One of my favorite aliases is this one:
alias vhosts='sudo subl /usr/local/httpd-vhosts.conf'
It enables me to quickly bring up my virtual host configuration in my favorite text editor instead of having to cd there manually and then forget to sudo edit the file and so on.
Here’s a nice primer on the configuration possibilities of your shell prompt. It’s a bit different depending on whether you use bash or zsh but some things like aliases go for both.
Dotfiles for the lazy folks
If you need sort of a kickstart for your conifguration needs, you might wanna try and get familiar with the different flavors of “dotfiles” that exist. Github has a nice collection. Get someones repository of those and fiddle about with them. There’s many different ones around, so it’s best to just try some out and see what they do and see if you like what they do. I found Paul Irish’s Dotfiles quite to my liking.
What they are is essentially shell configuration presets that alter your command line and some closely related tools such as git and vim in a more user friendly way.
Practice makes Productive
As with every tool, i think practice makes perfect. At first it was a bit of a hassle for me to get used to moving files around in the command line and i found myself often switching back to Finder’s nice graphical interface, which in the end costs me a lot more time navigating to my desired folders when i can just type something simple as “z proj” and hit TAB and Enter in the command line.
Oh, and let’s not forget the showboat part. Who cares about productivity anyway, when you can impress “normal people” with the simplest SCP action or yeoman/grunt build command that make everyone think you just did some sort of serious “computer magic”.