# Start early, compound your productivity

When it comes to finances, investing early ensures you get more bang for your buck with compound interest. The same concept can be applied to developer productivity, investing the time to create a productive development environment, will pay dividends for many years down the road. Productivity gains can come in the form of reducing the amount of keystrokes to type common commands, or code blocks, for moving windows around, and lastly for automating your computer setup, so a new laptop can be setup in no time. In this article I’ll mention aliases, snippets, window managers, switching to vim/emacs, and finally storing dotfiles on github.

Like many of you, I heard about these ideas for a long time. I read blog posts about them, watched co-workers swear by vim, or emacs, yet I kept putting off investing the time in my own productivity. This year, I finally decided that one of my new year resolutions will be to set up a productive development environment. I spent most of January learning about those tools, and installing new software. Now i’m on the second month, and I can already say, I feel much more productive in the new setup. Below are some of the investments, that I believe are worth starting with on the path to a more productive environment.

## Aliases

Aliases are like shortcuts, defining a shortened version of a long command you tend to repeat often. Think of them like tinyurl for your shell. For example aliasing ‘gcb’ can turn:

$gcb feature-branch  into: $ git checkout —branch feature-branch.


And:

$gcm  into: $ git checkout master


This is one of the easiest productivity tips to get started. To add an alias, open your ~/.bash_profile in any text editor, and add the following lines:

alias gcb=git checkout --branch
alias gcm=git checkout master


}
$3 endsnippet  This means when typing fvi, clicking TAB, it will expand to the for loop, and the cursor will be positioned on$1. Pressing TAB again will cycle to the next position in the snippet until $3. All modern text editors support snippets, read more below: Atom Snippets , Sublime Text, VIM, Emacs, ## Window Manager Minimizing, maximizing, moving to the right, or to the left, are all common operations performed to get running programs positioned in a way that matches the task at hand. Window Managers allow performing those actions using keyboard shortcuts instead of the mouse. I checked the history of Mac window managers, SizeUp was released in 2009, Slate followed in 2013, while the last one, HammerSpoon was released in 2014. HammerSpoon fits my needs perfectly. It’s free, open source and the configuration is done using a single lua file, stored in the home directory. Here’s a sample configuration that assigns Cmd+Alt+Ctrl+Left arrow, the action of moving the current window to the left side, and resizing the window to occupy 50% of the screen: hs.hotkey.bind({"cmd", "alt", "ctrl"}, 'Left', function() hs.window.focusedWindow():moveToUnit(hs.layout.left50) end)  ## VIM/Emacs Talking about text editors can easily lead to a flame war between those who prefer IDEs, and those who prefer text editors. Instead i’ll focus on my personal experience using IDEs for a long time (Visual Studio, Sublime, Atom) and switching to VIM earlier this year. And use the following paragraphs to nudge you to consider learning one of those editors, so you can decide what works best for you. VIM and Emacs are both quite old, dating back to 1976, yet they are still in active development today. The reason for that, is that for purely editing text, vim is far superior to any other IDE. You can find evidence for that in the VIM plugins available for every IDE - VIM Mode for Atom, Vintage mode for Sublime, VsVim for Visual Studio etc. VIM itself has plugins as well, and with them it’s possible to get VIM and Emacs close to the level of an IDE (auto complete, JIT warnings, refactoring etc.) while keeping the superior editing experience. Learning VIM is not easy. Gaining mastery of all the commands requires a multi month investment. Also getting VIM customized to your liking will require more tinkering and learning than the other productivity tips in this post. Yet editing text is what we developers do most of the day, so learning VIM has a potential to give the most productivity gains. Also, with the pre-packaged vim installations below, it’s possible to get started and be productive much faster than starting from scratch. For VIM there’s Macvim that allows running VIM as an app on the Mac, and the SPF13 package by Steve Francia. It gives an experience similar to Atom/Sublime out of the box, with autocomplete and a file explorer visible on the left. For Emacs, the story is more complicated. Prelude is a classic emacs and comes with popular packages pre-installed. I didn’t get a chance to play with it too much. Just like other editors, there’s a vim mode extension called evil mode. And then there’s Spacemacs — my favorite emacs distribution that attempts to find the middle ground, and provide a solid, unified experience with a great looking UI. Your first experience opening it might be wow. It looks quite amazing (or confusing). To install vim on the mac: $ brew install macvim --with-cscope --with-lua --with-luajit --with-python3 --with-override-system-vim


To install emacs on the mac:

\$ brew install emacs --HEAD --use-git-head --with-cocoa


## Store dotfiles in github

Finally, after you spent some time customizing your environment with aliases, window manager and vim configuration, share all this goodness with others, and exchange ideas by putting your dotfiles on github. Dotfiles are the files beginning with a dot in your home directory that stores configuration files. VIM has .vimrc, Bash has .bash_profile and so on. To get started:

1. Create a folder called dotfiles somewhere on your computer.
2. Create a git repository in that folder and upload it to github.
3. Copy your .bash_profile to the dotfiles folder and symlink it to the home folder:

 cp ~/.bash_profile ~/dotfiles
rm ~/.bash_profile
ln -s ~/dotfiles/.bash_profile ~/.bash_profile 
4. Repeat with other configuration files. Such as Hammerspoon above, vim, emacs etc.
5. Commit!
6. Share with your friends and get more tips.

## Conclusion

There’s a lot of productivity to be gained by taking an active role in improving your development environment. Spending a few minutes every day to customize your environment, and you’ll be on your way to save more seconds, compounded to minutes, and hours, one step at a time

[top]