Oh My Zsh + iTerm2 + Vim: Configuration and Custom Theme


Firstly you should install Oh My Zsh to enable the custom theme for your terminal.

# install using curl
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# install using wget
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

Then, change the theme to “agnoster” (see details on https://github.com/agnoster/agnoster-zsh-theme).

In order to enable a theme, set ZSH_THEME to the name of the theme in your ~/.zshrc, before sourcing Oh My Zsh; for example: ZSH_THEME="agnoster" If you do not want any theme enabled, just set ZSH_THEME to blank: ZSH_THEME=" "

(Quoted from: https://github.com/ohmyzsh/ohmyzsh/wiki/Themes)

iTerm2 colorsscheme:

Before changing the color scheme, you could notice some font issues. To solve the unknown unicode character, install the powerline font (https://github.com/powerline/fonts):

# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts

Then, apply this colorscheme in iTerm2 to change the color.

Vim settings:

set tabstop=4
set softtabstop=0 noexpandtab
" Don't try to be vi compatible
set nocompatible

" Helps force plugins to load correctly when it is turned back on below        
filetype on

" TODO: Load plugins here (pathogen or vundle)
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
  \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
endif

call plug#begin('~/.vim/plugged')
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
call plug#end()

" Turn on syntax highlighting
syntax on

" For plugins to load correctly
filetype plugin indent on

" TODO: Pick a leader key
" let mapleader = ","

" Security
set modelines=0

" Show line numbers
set number
set numberwidth=5
highlight LineNr ctermfg=grey

" Show line limit 81
set colorcolumn=81
highlight ColorColumn ctermbg=239 guibg=lightgrey

" Show file stats
set ruler

" Encoding
set encoding=utf-8

" Whitespace
set wrap
" set textwidth=80
set formatoptions=tcqrn1
set shiftwidth=4
set expandtab
set noshiftround

" Cursor motion
set scrolloff=3
set backspace=indent,eol,start
set matchpairs+=<:> " use % to jump between pairs
runtime! macros/matchit.vim

" Move up/down editor lines
nnoremap j gj
nnoremap k gk

" Allow hidden buffers
set hidden

" Rendering
set ttyfast

" Status bar
set laststatus=2

" Last line
set showmode
set showcmd

" Searching
nnoremap / /\v
vnoremap / /\v
set hlsearch
set incsearch
set ignorecase
set smartcase
set showmatch
map <leader><space> :let @/=''<cr> " clear search

" Remap help key.
inoremap <F1> <ESC>:set invfullscreen<CR> 
nnoremap <F1> :set invfullscreen<CR>
vnoremap <F1> :set invfullscreen<CR>

" Textmate holdouts

" Formatting
map <leader>q gqip

" Visualize tabs and newlines
set listchars=tab:▸\ ,eol:¬
" Uncomment this to enable by default:
" set list " To enable by default
" Or use your leader key + l to toggle on/off
map <leader>l :set list!<CR> " Toggle tabs and EOL

" Color scheme (terminal)
set t_Co=256
set background=dark
let g:solarized_termcolors=256
let g:solarized_termtrans=1

let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#tabline#formatter = 'default'

Screenshots:


Leave a Reply