Published: 01/28/2016

I live and die by the keyboard. The keyboard is my friend and it’s way faster to use an application using a keyboard then it is to use a mouse. In fact there are many studies that show that for non-complex key combinations keyboard shortcuts and aliases are much faster then using the mouse.

Git Aliases

If you’re a Git addict like me, you should know about git configuration. This allows you to create shortcuts to common things that you use often. In my home directory, I have a .gitconfig file with the following contents:

[alias]

st = status

ck = checkout

ckb = checkout

sta = stash apply

sth = stash

While small, I find the things I most often do in git is switch branches, git status and modifying stashes.

Zsh Aliases / Command line aliases

Another source of aliases I use is for Zsh (Zee Shell), for this you can do the following:

alias commandShortCut = “commandToRun”

One nasty one I often have to run is to drop the local database in rails, recreate it and seed it with data. This is very long and a pain to type often:

bundle exec rake db:drop db:create db:migrate db:seed;

My shortcut command for this is:

ber

To set “ber” I used:

alias ber=”bundle exec rake db:drop db:create db:migrate db:seed;”

Sublime Aliases

In Sublime Aliases are known as Snippets. Snippets are used as apart of the code complete portion of sublime.

To create a snippet in sublime, go to Tools > New Snippet. From there it’ll give you a template to work with:

<![CDATA[

Hello, ${1:this} is a ${2:snippet}.

]]></content>

<!– Optional: Set a tabTrigger to define how to trigger the snippet –>

<!– hello –>

<!– Optional: Set a scope to limit where the snippet will trigger –>

<!– source.python –>

</snippet>

It’s basically XML or HTML, uncomment the tab trigger and customize what you want to use to tab complete to auto fill in. Within the CDATA part, right where hello is, that is where you can put a tab completed item. Scope allows you to control what document scope you will trigger the snippet in.

Here’s an example I use for lorem ipsum text, the file is saved at “packages/users” within the sublime library as lorem.sublime-snippet:

<![CDATA[

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vehicula blandit neque, nec ullamcorper leo hendrerit pretium. Morbi turpis risus, finibus sodales velit a, sagittis pharetra nibh. Nullam ultrices dolor in dolor mattis, imperdiet facilisis velit sagittis. Ut dapibus eleifend felis quis consectetur. Aenean sodales lorem ac urna efficitur egestas. Vivamus nec posuere lorem, vitae feugiat quam. Praesent venenatis mattis libero, in dapibus mi molestie sed. Vestibulum mollis leo lorem. Suspendisse id consequat enim, et facilisis diam. Nullam mattis lectus ligula, ac suscipit dui elementum ut. Sed egestas laoreet rutrum. Curabitur vel ex id quam porta vestibulum. Sed hendrerit orci nisl, eu aliquet ante venenatis eu. Praesent vel dapibus velit, eget ultricies ex.

]]></content>

lorem

</snippet>

There you have it, 3 really great examples of using aliases / snippets in git, sublime and zsh. Using these is sure to make your workflow faster and easier, especially on a Mac or Linux computer!