TerminalOMatic: Customizing terminal to be even faster

For most MacBook Pro users, Terminal is an indispensable application. But we can make even better. Below is a collection of some of the tricks that I found to be are some of the tricks that I found very useful. I generally put these commands in my ~/.bashrc file. You might however want to read this blog before you decide where to put these custom commands.

Trick 1: Intelligent History Scrolling
Scrolling through history although useful can be a pain. Often you are looking for a particular command. Here is a solution that might be worth exploring. Simply bind your UP and DOWN arrow key so that it searches history looking for command that starts with what you have typed so far. For instance, searching for commands that starts with “javac”, simply type “javac” on the command line and then press UP arrow key. Now history will show only those commands that start with “javac”.

Trick 2: Case Insensitive Autcomplete
Its frustrating to realize that you were looking for a folder named “Pictures” by typing “p” instead of “P” on the command line and the autocompletion is not able to find it. Again the solution is very simple. Simply put this one line of code in your ~/.bashrc so that auto-completion is case insensitive.
bind 'set completion-ignore-case on'

Trick 3: Application shortcut
Often I like opening json files in chrome or firefox. But it’s pain to open chrome/firefox and then go to the file menu and search for the appropriate file. Why not just open it through command line. This is possible through the following command

$>open -a /Application/Firefox.app/ ~/Documents/sample.json

But you can be even more faster. As shown below, just write a function that makes the above call.

open -a /Applications/Firefox.app/ "$1"
open -a /Applications/Chrome.app/ "$1"

Now to open a file with Firefox, simple enter the following command through the command line
$>ff ~/Documents/sample.json

Trick 4: Folder shortcut
There are often two or three projects that I am work on simultaneously and often need to switch from one project to another. Even though autocomplete save tons of time navigating all the complex file structure, there is even a shorter way to save time and fingers.  Just define variables in my ~/.bashrc and use them in your command as shown below.

#Folder variables

Now, let’s say I want to open the “blog” folder in textmate, I can simply reference the above variable in the command line as follows
$>mate $blog

Trick 5: Defining commonly used commands
If there are commands that you often run, consider using alias to define. For instance, if you often open a particular folder in textmate using the following command $>mate ~/Documents/personal/writings/blog, then consider creating an alias as shown belowblog.mate=’mate ~/Documents/personal/writings/blog’

Now, from the command line simply run

Trick 6: Better Theme
Terminal ships with lot of themes but none work for me. I find this theme particularly good. Try it.


One thought on “TerminalOMatic: Customizing terminal to be even faster

  1. Thanks! This was pretty good. I was actually looking for a way to make my command prompt jump straight to the folder I work from most of the time, although I like the flexibility of just defining the path in a variable.

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