Skip to content

Instantly share code, notes, and snippets.

@karlbright
Created December 10, 2015 05:05
Show Gist options
  • Save karlbright/5176b6d72c6cdf670f25 to your computer and use it in GitHub Desktop.
Save karlbright/5176b6d72c6cdf670f25 to your computer and use it in GitHub Desktop.
# A better prefix
unbind-key C-b
set -g prefix 'C-a'
bind-key 'C-a' send-prefix
# Use reattach-to-user-namespace to fix clipboard issues
set-option -g default-command "reattach-to-user-namespace -l zsh"
set-environment -g TMUX_COMMAND tmux
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
bind r source-file ~/.tmux.conf \; display "Reloaded!"
set -g status-left-length 70
# Navigation between vim and tmux panes made easy
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?x?)(diff)?$"'
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
# New splits
bind-key v split-window -h
bind-key x split-window -v
# Resize splits
bind-key J resize-pane -D 5
bind-key K resize-pane -U 5
bind-key H resize-pane -L 5
bind-key L resize-pane -R 5
# Resize without prefix
bind-key -n C-S-Up resize-pane -U 5
bind-key -n C-S-Down resize-pane -D 5
bind-key -n C-S-Left resize-pane -L 10
bind-key -n C-S-Right resize-pane -R 10
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup copy paste like vim for copy mode
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# Update default binding of enter to use copy-pipe
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
# Bind ']' to use pbpaste
bind ] run "reattach-to-user-namespace pbpaste | tmux load-buffer - && tmux paste-buffer"
# Start indexing at 1, not 0
set-option -g base-index 1
setw -g pane-base-index 1
# Enable 256 colorspace
set -g default-terminal "screen-256color"
"---------------------------------------------------"
" Author: Karl Brightman "
" Homepage: http://karlbrig.ht "
" Source: http://github.com/karlbright/vimrc "
"---------------------------------------------------"
" vim:set ts=2 sts=2 sw=2 expandtab:
autocmd!
filetype off "Turn off file type detection. Required for Vundle
set nocompatible " Disable vi compatibility
set hidden " Allow buffers to be hidden without writing to the disk
set history=10000 " Large command history
set encoding=utf-8 " Character encoding
set shell=/bin/zsh " Set shell to use zsh
set clipboard=unnamed " Allow yank and paste from system
set ch=1 " Number of lines to use for the command-line
set showcmd " Show incomplete commands in status line
set nolazyredraw " Redraw while executing macros
set nostartofline " Do not move cursor to first non blank in line
set shortmess+=I " Do not show the introduction screen
set wildmode=longest:full " Complete longest common string, then list alternatives
set wildmenu " Use menu for command line completion
set ignorecase smartcase " Ignore case until another other case is used
set switchbuf=useopen " Jump to first open window that contains specified buffer on open
set laststatus=2 " Always show status line
set cmdheight=1 " Use one line height for command
set showtabline=2 "Always show tab bar
set visualbell " Stop beeping
set cursorline " Highlight current line
set ruler " Show column and line
set number " Show line numbers
set guioptions-=T guioptions-=e guioptions-=L guioptions-=r " Remove toolbars, scrollbars etc if around
set showmatch " Briefly jump to matching bracket if insert one
set mat=5 " Time for showing matching bracket
set incsearch " Highlight match while typing search pattern
set hlsearch " Highlight search results
set expandtab " Use spaces for tabs
set tabstop=2 " Use 2 spaces for indenting here...
set shiftwidth=2 " here, and...
set softtabstop=2 " here
set autoindent " Take indentation from previous line
set splitright " Open new vertical splits to the right of the current buffer
set splitbelow " Open new horizontal splits below current buffer
set winwidth=60 " Minimal number of columns for current window
set t_ti= t_te= " Fix vim clobbering scrollback buffer (http://bit.ly/158EoqS)
set scrolloff=3 " Minimum number of lines to show above and below cursor
set nowrap " Do not wrap lines
set textwidth=0 " The text must flow (http://bit.ly/pWJOw)
set nowritebackup " We don't need backups...
set nobackup " when we have version control
set directory=~/.tmp,/var/tmp,/tmp " Set swap file directories with alternatives
set foldmethod=manual " Disable automatic folding
set nofoldenable " Always open folds when opening file
set backspace=indent,eol,start " Make backspace work as it should
set equalalways
" ******
" VUNDLE
" Automatically setting up Vundle, taken from
" http://www.erikzaadi.com/2012/03/19/auto-installing-vundle-from-your-vimrc/
" ******
let vundle_virgin=0
if !filereadable($HOME."/.vim/bundle/vundle/README.md")
" Clone vundle via github
echo "Installing Vundle..."
echo ""
silent !mkdir -p $HOME/.vim/bundle
silent !git clone https://github.com/gmarik/vundle $HOME/.vim/bundle/vundle
let vundle_virgin=1
endif
set rtp+=$HOME/.vim/bundle/vundle/ " Add vundle directory to runtime path
call vundle#rc() " Initialize vundle
" Include Vundle its self
Bundle 'gmarik/vundle'
" File finder
Bundle 'kien/ctrlp.vim'
let g:ctrlp_custom_ignore = 'node_modules\|bower_components\|DS_Store\|git'
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:20,results:20'
" Ack replacement via the_silver_searcher (requires: brew install ag)
Bundle 'rking/ag.vim'
" File explorer replacement
Bundle 'scrooloose/nerdtree'
let NERDTreeWinSize=26
nmap <leader>nn :NERDTree<cr>
nmap <leader>nq :NERDTreeClose<cr>
nmap <leader>nf :NERDTreeFind<cr>
" Vinegar exporer split
"Bundle 'tpope/vim-vinegar'
" Comment like a pro across file types
Bundle 'scrooloose/nerdcommenter'
" Quoting/paranthesizing/html-tagging made simple
Bundle 'tpope/vim-surround'
" Enable repeating supported plugin maps
Bundle 'tpope/vim-repeat'
" Align things because pretty code is good code
Bundle 'godlygeek/tabular'
" Vim syntax for LESS (dynamic CSS)
Bundle 'groenewege/vim-less'
" Ruby
Bundle 'vim-ruby/vim-ruby'
Bundle 'tpope/vim-rails'
autocmd FileType ruby setlocal regexpengine=1
" Syntax checker with Syntastic
" Bundle 'scrooloose/syntastic'
"set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_javascript_checkers = ['jsxhint']
" Node
Bundle 'moll/vim-node'
" Coffeescript support
Bundle 'kchmck/vim-coffee-script'
" Go lang
Bundle 'fatih/vim-go'
let g:go_fmt_command = "goimports"
" Split join multiple line statements
Bundle 'splitjoin.vim'
nmap <leader>sj :SplitjoinSplit<cr>
nmap <leader>sl :SplitjoinJoin<cr>
" Tmux vim navigation
Bundle 'christoomey/vim-tmux-navigator'
Bundle 'benmills/vimux'
let g:VimuxTmuxCommand = $TMUX_COMMAND
map <Leader>vp :VimuxPromptCommand<CR>
map <Leader>vl :VimuxRunLastCommand<CR>
map <Leader>vi :VimuxInspectRunner<CR>
map <Leader>vq :VimuxCloseRunner<CR>
map <Leader>vs :VimuxInterruptRunner<CR>
map <Leader>vc :VimuxClearRunnerHistory<CR>
map <Leader>vz :VimuxZoomRunner<CR>
" Import JS commonJS styles
Bundle 'trotzig/import-js'
" Dash keybindings for docs
Bundle 'rizzatti/dash.vim'
:nmap <silent> <leader>d <Plug>DashSearch
" Abolish - Substitution with coercion and keeping case
Bundle 'tpope/vim-abolish'
Bundle 'chriskempson/base16-vim'
set t_Co=256 " Set 256 colors
let transparency=1 " A little bit of transparency never killed anyone..
set background=dark " Background should be dark like my coffee
let base16colorspace=256 " Use 256 color space
colorscheme base16-tomorrow " Make things pretty
if vundle_virgin == 1
" Install bundles if this is the first time vim has been run with this config
ech "Installing bundles..."
echo ""
:BundleInstall
source $HOME/.vimrc
:q
endif
syntax on " Enable syntax highlighting
highlight LineNr ctermbg=none ctermfg=darkgrey
highlight CursorLineNr term=bold ctermfg=Yellow gui=bold guifg=Yellow
filetype plugin indent on "Automatically detect file types
" Basic key mappings
imap <c-c> <esc>
nmap <space> :nohlsearch<cr>
nmap <leader><tab> :b#<cr>
nmap <leader>[ :cprev<cr>
nmap <leader>] :cnext<cr>
nnoremap <leader>= <C-W>=
nnoremap <leader>+ :exe "resize +10"<cr>
nnoremap <leader>- :exe "resize -10"<cr>
" Disable the arrow keys, its bad practice...
map <Left> <Nop>
map <Right> <Nop>
map <Up> <Nop>
map <Down> <Nop>
" Filetype settings
autocmd BufRead,BufNewFile {*.hbs} set filetype=html
source /opt/boxen/env.sh
export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
export EDITOR=vim
export PATH=/usr/local/bin:$PATH
if [ -z "$TMUX_COMMAND" ]; then
export TMUX_COMMAND=tmux
fi
BASE16_SHELL="$HOME/Development/chriskempson-base16-shell/base16-tomorrow.dark.sh"
[[ -s $BASE16_SHELL ]] && source $BASE16_SHELL
alias drangus='ssh 192.168.1.100'
bindkey '^R' history-incremental-pattern-search-backward
bindkey '^F' history-incremental-pattern-search-forward
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment