Command and Conquer

By   |  

“Pardon me, would you have any Grey Poupon?”

So asked one Rolls Royce passenger of another, and a phenomenon was born. When we analyze the question now, we understand that satisfaction was the expected result. Just as these sophisticated gents understood the importance of quality mustard, so too might today’s web developers appreciate quality tips and tricks that can add refinement to our daily tasks. I humbly offer a few of these today.

Aliases

For those who work frequently with the command line, aliases can be a savior of your time and sanity. For those who don’t know what “command line” means, I invite you to follow Mr. Miyagi’s advice and “wax on, wax off” with your Terminal program of choice, then come back later when you’re ready for tournament play. I have outfitted my own Mac Terminal with several aliases, such as these:

alias ll=’ls -AGF’
alias lll=’ls -AGFhlT’
alias sshm=’ssh topsecret@whatever.com’
alias csd=’cap staging deploy’
alias cpd=’cap prod deploy’
function cl() { cd “$@” && ll; }

These lines can be added to one of several files in your home directory, usually a file named “.profile” or “.bash_profile” or the like. The above examples basically replace long, frequently used commands with very short alternatives. So instead of typing “ls -AGFhIT” when I want to see a detailed list of file information for the current directory, I can now simply type “lll” and be done with it. For more alias fun, check fahd.blog.

History

Command line history can be accessed by tapping the up arrow on your keyboard, which will cycle through all previous commands. It’s very helpful when you run the same cycle of commands repeatedly, but it’s not so helpful when the same commands are clogging up your history. Here are a few lines that you can add to the aforementioned .profile file to improve your lot:

export HISTCONTROL=erasedups
export HISTFILESIZE=100000
export HISTSIZE=10000
export PROMPT_COMMAND=”history -a”
shopt -s histappend

These lines essentially prevent duplicate entries from occurring in your history, and also save commands to the same history file even if different terminal tabs are open. For more on command history, check MDLog.

Top Tips

There is a certain trusty command called “top” that allows you to see real-time performance of your server or machine. These tips are best used on a Linux server rather than a Mac, mainly because Apple has taken the “top” command and changed pretty much everything about it. After typing “top” on the command line, a new screen with real time data appears, at which point you can press “h” to see available interactive commands. When you find the settings you prefer, you can save them by typing a capital W. Then next time you access “top” you will see your preferences intact. A few of my favorite interactive options are z, b, y, and c. For more on “top” check The Geek Stuff.

The Bottom Line: The next time someone asks if you can make the command line more enjoyable, you can now reply, “But of course,” just like a true Grey Poupon connoisseur.

We Welcome Your Comments Below.

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>