zsh + tmux + vim = awesome

I have frequently switched between working on IDEs like IntelliJ and PyCharm to plain old command line. While I usually settled on working with bash and vim, I realized that there is a lot of cool tweaking that you can do, to make the overall development experience much more productive and awesome.

zsh is awesome!

First of all, lets come to the shell. I usually used to just go with bash, until I saw that zsh is way more loaded ( for instance cycling through your directory when you do cd, correction suggestions, … I am still discovering all the cool stuff, but here’s a great  HN discussion ). So I switched to using zsh as my default shell. I also was able to get a cool theme, by using the oh-my-zsh framework – which you should definitely checkout! The default ‘robbyrussell’ theme was good enough for me, I didn’t want anything too fancy that required me to add powerfonts / color schemes. But here’s how my shell prompt looks like. It basically prints out my directory, followed by which git branch I am currently on which is super useful. There’s other stuff that you can add to the right like your battery status, etc if interested.

Screen Shot 2016-04-03 at 12.06.14 AM

Making Vim more awesome!

While I definitely do not want to start another flame war on vim vs emacs, here’s my take. I used emacs initially and I really loved it. Being able to run the terminal from within the shell and gdb without doing anything special was super convenient. But a lot of my work requires ssh-ing to a bunch of different servers, and most of them don’t come with emacs installed. I figured that if I was using vim most of the time, I might as well use it all of the time, so that I could do the keystrokes quicker.

I have installed some really useful plugins and remapped some of the keys, and it has made working in vim a lot more efficient. I’ll include my vimrc at the bottom of the post. I use Vundle  for plugin management. I use the gruvbox dark theme, because it is nice and aesthetic and works right out of the box without needing to install new palettes. I found a lot of the plugins by looking at http://vimawesome.com/. Currently I have used these for working on C++. I am still tweaking vim for Python and Clojure. Basically with the right set of plugins, your vim is as powerful and much more light weight than any IDE – IntelliJ used to take some crazy amount of memory on my OS X.  I remapped C-d to easily switch between vim and the shell, and also have a mapping that makes sure that the current search term is always at the page centre. I am using a minimal set of plugins – NerdTree for directory navigation, Tagbar for quickly capturing the file structure ( needs to have ctags installed), Airline for getting a nice status line at the bottom, Syntastic that quickly highlights any compile time errors, similar to an IDE and a couple of others. I am yet to try YouCompleteMe for code completion, but it’s definitely on the top of my list.

One super useful feature in vim is that it allows opening files in different tabs, something I only discovered recently. Simply do :tabe <file> and the file will be opened in a new tab. It is very easy to cycle between tabs using gT. You can also directly jump to a tab i by using {i}gT. I installed Tabline, which is a nice plugin that adds a number to every tab title, making it much easier to jump to tabs directly.

Here’s the final effect:

Screen Shot 2016-04-03 at 1.08.01 AM

tmux saves the day!

Finally tmux! I was initially quite scared of using tmux – I thought it was too complicated for a noob like me, but it turns out that there are really very few keystrokes with which you can do most of the useful stuff. I prefer using tmux for splitting panes and stuff because that means that I can use it both on linux and OS X, unlike iterm.

The biggest advantage of tmux is definitely that it keeps all your sessions alive, exactly like you left them. No more worrying when you accidentally unplug the wifi cable, or snap your macbook shut. I typically find it very useful when building a large project, I can just come back in the next day and check on the build status by attaching back my session, or can attach and continue with my debugging, where I left off during the commute.

There are some other cool projects like tmuxinator, which will actually fire up various sessions for you,  tile your panes and keep everything ready for you each day! I haven’t had a chance to look at it so far, but that’s definitely something I want to try out


All in all I am definitely more productive with all these tweaks. If there are any plugins or tools that have served you well, I would be very excited to try those out, so do let me know. Finally here’s my vimrc:

set backspace=indent,eol,start
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=/Users/xyz/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'majutsushi/tagbar'
Plugin 'morhetz/gruvbox'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/syntastic' "Syntax checking hacks for vim, displays errors on left after save
Plugin 'luochen1990/rainbow'
Plugin 'terryma/vim-multiple-cursors' "Submlime multiple text selection
Plugin 'Raimondi/delimitMate' "Auto add dual quotes, parenthesis, brackets, etc.
Plugin 'mkitt/tabline.vim'
Plugin 'bling/vim-airline'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
" Brief help
" :PluginList – lists configured plugins
" :PluginInstall – installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo – searches for foo; append `!` to refresh local cache
" :PluginClean – confirms removal of unused plugins; append `!` to auto-approve removal
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
nmap <F8> :TagbarToggle<CR>
nmap <F10> :NERDTreeToggle<CR>
nmap <C-d> :sh<CR>
" emacs binding for begin and end
cnoremap <c-a> <home>
cnoremap <c-e> <end>
" Keep search matches in the middle of the window.
nnoremap n nzzzv
nnoremap N Nzzzv
set background=dark
colorscheme gruvbox
let g:rainbow_active = 1
:syntax on
:set laststatus=2
:set statusline=%F
:set cursorline
:set tags+=$OSCAR_HOME/tags
:set number
"Use spaces instead of tabs
set tabstop=2 softtabstop=2 expandtab shiftwidth=2

view raw


hosted with ❤ by GitHub

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 )

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