-
-
Save adambair/2147385 to your computer and use it in GitHub Desktop.
j2fly's vim setup, install with: exec 3<&1;bash <&3 <(curl https://raw.github.com/gist/2040114/vim.sh 2> /dev/null)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Our .tmux.conf file | |
# Setting the prefix from C-b to C-a | |
# START:prefix | |
set -g prefix C-a | |
# END:prefix | |
# Free the original Ctrl-b prefix keybinding | |
# START:unbind | |
unbind C-b | |
# END:unbind | |
#setting the delay between prefix and command | |
# START:delay | |
set -sg escape-time 1 | |
# END:delay | |
# Ensure that we can send Ctrl-A to other apps | |
# START:bind_prefix | |
bind C-a send-prefix | |
# END:bind_prefix | |
# Set the base index for windows to 1 instead of 0 | |
# START:index | |
set -g base-index 1 | |
# END:index | |
# Set the base index for panes to 1 instead of 0 | |
# START:panes_index | |
setw -g pane-base-index 1 | |
# END:panes_index | |
# Reload the file with Prefix r | |
# START:reload | |
bind r source-file ~/.tmux.conf \; display "Reloaded!" | |
# END:reload | |
# splitting panes | |
# START:panesplit | |
bind | split-window -h | |
bind - split-window -v | |
# END:panesplit | |
bind t split-window -p 15 | |
# moving between panes | |
# START:paneselect | |
bind h select-pane -L | |
bind j select-pane -D | |
bind k select-pane -U | |
bind l select-pane -R | |
# END:paneselect | |
# Quick pane selection | |
# START:panetoggle | |
bind -r C-h select-window -t :- | |
bind -r C-l select-window -t :+ | |
# END:panetoggle | |
# Pane resizing | |
# START:paneresize | |
bind -r H resize-pane -L 2 | |
bind -r J resize-pane -D 2 | |
bind -r K resize-pane -U 2 | |
bind -r L resize-pane -R 2 | |
# END:paneresize | |
# mouse support - set to on if you want to use the mouse | |
# START:mouse | |
setw -g mode-mouse off | |
# END:mouse | |
set -g mouse-select-pane off | |
set -g mouse-resize-pane off | |
set -g mouse-select-window off | |
# Set the default terminal mode to 256color mode | |
# START:termcolor | |
set -g default-terminal "screen-256color" | |
# END:termcolor | |
# enable activity alerts | |
#START:activity | |
setw -g monitor-activity on | |
set -g visual-activity on | |
#END:activity | |
# set the status line's colors | |
# START:statuscolor | |
set -g status-fg white | |
set -g status-bg black | |
# END:statuscolor | |
# set the color of the window list | |
# START:windowstatuscolor | |
setw -g window-status-fg cyan | |
setw -g window-status-bg default | |
setw -g window-status-attr dim | |
# END:windowstatuscolor | |
# set colors for the active window | |
# START:activewindowstatuscolor | |
setw -g window-status-current-fg white | |
setw -g window-status-current-bg red | |
setw -g window-status-current-attr bright | |
# END:activewindowstatuscolor | |
# pane colors | |
# START:panecolors | |
set -g pane-border-fg green | |
set -g pane-border-bg black | |
set -g pane-active-border-fg white | |
set -g pane-active-border-bg yellow | |
# END:panecolors | |
# Command / message line | |
# START:cmdlinecolors | |
set -g message-fg white | |
set -g message-bg black | |
set -g message-attr bright | |
# END:cmdlinecolors | |
# Status line left side | |
# START:statusleft | |
set -g status-left-length 40 | |
set -g status-left "#[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P" | |
# END:statusleft | |
#START:utf8 | |
set -g status-utf8 on | |
#END:utf8 | |
# Status line right side | |
# 15% | 28 Nov 18:15 | |
# START: statusright | |
#set -g status-right "#(~/battery Discharging) | #[fg=cyan]%d %b %R" | |
# END:statusright | |
# Update the status bar every sixty seconds | |
# START:updateinterval | |
set -g status-interval 60 | |
# END:updateinterval | |
# Center the window list | |
# START:centerwindowlist | |
set -g status-justify centre | |
# END:centerwindowlist | |
# enable vi keys. | |
# START:vikeys | |
setw -g mode-keys vi | |
# END:vikeys | |
# Maximize and restore a pane | |
# START:max | |
unbind Up | |
bind Up new-window -d -n tmp \; swap-pane -s tmp.1 \; select-window -t tmp | |
# END:max | |
# START:restore | |
unbind Down | |
bind Down last-window \; swap-pane -s tmp.1 \; kill-window -t tmp | |
# END:restore | |
# Log output to a text file on demand | |
# START:pipe-pane | |
bind P pipe-pane -o "cat >>~/#W.log" \; display "Toggled logging to ~/#W.log" | |
# END:pipe-pane | |
set -g default-command "reattach-to-user-namespace -l /bin/zsh" | |
set -g default-shell /bin/zsh | |
bind C-c run "tmux save-buffer - | reattach-to-user-namespace pbcopy" | |
bind C-v run "tmux set-buffer $(reattach-to-user-namespace pbpaste);tmux paste-buffer" | |
# NOTES | |
# prefix space will toggle layouts | |
# prefix { will swap panes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" this is the configuration file for linux and mac systems | |
" symlink this to your home folder as .vimrc | |
" It loads pathogen and loads all modules from ~/.vim/bundles. | |
" It then loads ~/.vimrc_main which has the main | |
" configuration that works across all systems. | |
call pathogen#runtime_prepend_subdirectories(expand('~/.vim/bundles')) | |
call pathogen#helptags() | |
source ~/.vimrc_main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible "don't need to keep compatibility with Vi | |
set shell=bash | |
filetype plugin indent on "enable detection, plugins and indenting in one step | |
syntax on "Turn on syntax highlighting | |
set background=dark "make vim use colors that look good on a dark background | |
set showcmd "show incomplete cmds down the bottom | |
set showmode "show current mode down the bottom | |
set showmatch "set show matching parenthesis | |
"set noexrc " don't use the local config | |
set virtualedit=all "allow the cursor to go in to "invalid" places | |
set incsearch "find the next match as we type the search | |
set hlsearch "hilight searches by default | |
set ignorecase "ignore case when searching | |
set smartcase " ... unless they contain at least one capital letter | |
set shiftwidth=2 "number of spaces to use in each autoindent step | |
set tabstop=2 "two tab spaces | |
set softtabstop=2 "number of spaces to skip or insert when <BS>ing or <Tab>ing | |
set expandtab "spaces instead of tabs for better cross-editor compatibility | |
set smarttab "use shiftwidth and softtabstop to insert or delete (on <BS>) blanks | |
set cindent "recommended seting for automatic C-style indentation | |
set autoindent "automatic indentation in non-C files | |
set nowrap "no wrapping | |
set copyindent "copy the previous indentation on autoindenting | |
set backspace=indent,eol,start "allow backspacing over everything in insert mode | |
set noerrorbells "don't make noise | |
set shiftround "when at 3 spaces, and I hit > ... go to 4, not 5 | |
"set cursorline "underline the current line in the file | |
"set cursorcolumn "highlight the current column. Visible in GUI mode only. | |
set wildmenu "make tab completion act more like bash | |
set wildmode=list:longest "tab complete to longest common string, like bash | |
"set mouse-=a "disable mouse automatically entering visual mode | |
set mouse=a "Enable mouse support in the terminal VIM and activate visual mode with dragging | |
set wrap! "Word wrap on | |
set bs=2 | |
set number "Show line numbers | |
"NOTE we'll see how this goes jonk | |
"set hidden "allow hiding buffers with unsaved changes | |
"autocmd BufReadPost fugitive://* set bufhidden=delete | |
autocmd BufRead * call s:set_hidden() | |
function! s:set_hidden() | |
if empty(&buftype) "most explorer plugins have buftype=nofile | |
setlocal bufhidden=delete | |
endif | |
endfunction | |
set cmdheight=2 "make the command line a little taller to hide "press enter to viem more" text | |
imap ii <Esc> | |
set backupdir=$HOME/.vim/backup// | |
set directory=$HOME/.vim/backup// | |
" Quickly time out on keycodes, but never time out on mappings | |
set notimeout ttimeout ttimeoutlen=200 | |
" Instead of failing a command because of unsaved changes, instead raise a | |
" dialogue asking if you wish to save changed files. | |
set confirm | |
let mapleader = "," "remap leader to ',' which is much easier than '\' | |
" Open NERDTree with [,d] | |
map <Leader>d :NERDTreeToggle<CR> :set number<CR> | |
" Show current file in the NERDTree hierarchy | |
map <Leader>D :NERDTreeFind<CR> :set number<CR> | |
"CtrlP mappings | |
"map <Leader>f :CtrlP<CR> | |
map <C-t> :CtrlP<CR> | |
"map <Leader>B :CtrlPBuffer<CR> | |
"map <Leader>b :CtrlPMRU<CR> | |
" Exclude files from ctrl-p finder | |
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$' | |
" Pasting support | |
set pastetoggle=<F2> " Press F2 in insert mode to preserve tabs when pasting from clipboard into terminal | |
" Ack in Project | |
map <Leader><C-t> :AckG<space> | |
map <Leader><C-f> :Ack<space> | |
colorscheme vividchalk | |
set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v] | |
" | | | | | | | | | | | | |
" | | | | | | | | | | + current | |
" | | | | | | | | | | column | |
" | | | | | | | | | +-- current line | |
" | | | | | | | | +-- current % into file | |
" | | | | | | | +-- current syntax in | |
" | | | | | | | square brackets | |
" | | | | | | +-- current fileformat | |
" | | | | | +-- number of lines | |
" | | | | +-- preview flag in square brackets | |
" | | | +-- help flag in square brackets | |
" | | +-- readonly flag in square brackets | |
" | +-- rodified flag in square brackets | |
" +-- full path to file in the buffer | |
" } | |
"J2FLY EDITS | |
"=========== | |
"SHOW INVISIBLES | |
"--------------- | |
"Shortcut to toggle `set list` which turns on and off the whitespace markers | |
nmap <leader>il :set list!<CR> | |
"Use the same symbols as TextMate for tabstops and EOLs | |
set listchars=tab:▸\ ,eol:¬ | |
set t_Co=256 "256 COLORS SUPPORT | |
if version > 702 "Right margin settings for vim 7.2 or greater | |
set colorcolumn=80 | |
endif | |
"WINDOW SPLITS | |
"------------- | |
" allows navigating between splits with just ctrl+h (or j or k or l) | |
map <C-j> <C-w>j | |
map <C-k> <C-w>k | |
map <C-h> <C-w>h | |
map <C-l> <C-w>l | |
" Better split management, kept in sync with tmux' mappings | |
" (<prefix>| and <prefix>-) | |
noremap <leader>- :sp<CR><C-w>j | |
noremap <leader>\| :vsp<CR><C-w>l | |
"SEARCH OPTIONS | |
"-------------- | |
" Press \h to toggle highlighting on/off, and show current value. | |
noremap <leader>h :set hlsearch! hlsearch?<CR> | |
"nnoremap <esc> :noh<return> "breaks the mouse clicking | |
"TOGGLE RELATIVE NUMBERING | |
"------------------------- | |
function! g:ToggleNuMode() | |
if(&rnu == 1) | |
set nu | |
else | |
set rnu | |
endif | |
endfunc | |
nnoremap <Leader>l :call g:ToggleNuMode()<CR> | |
" Allow resizing splits with =/- for up/down and +/_ left/right (repeatable too) | |
if bufwinnr(1) | |
map + <C-W>+ | |
map _ <C-W>- | |
map = <C-W>> | |
map - <C-W>< | |
endif | |
" Not sure if I'll use this, but it's cool to have an exp of a funct like this | |
" Reload Google Chrome on Mac from Vim. | |
" Adapted from: https://github.com/gcollazo/BrowserRefresh-Sublime/ | |
function! ChromeReload() | |
python << EOF | |
from subprocess import call | |
browser = """ | |
tell application "Google Chrome" to tell the active tab of its first window | |
reload | |
end tell | |
tell application "Google Chrome" to activate | |
""" | |
call(['osascript', '-e', browser]) | |
EOF | |
endfunction | |
map <leader>g :call ChromeReload()<CR> | |
let g:indent_guides_start_level=2 | |
let g:indent_guides_guide_size=1 | |
"Search and replace the word under the cursor with whatever you type in | |
:nnoremap <Leader>s :%s/\<<C-r><C-w>\>/ | |
command! -bar Q quit "Allow quitting using :Q | |
command! -bar -bang Q quit<bang> "Allow quitting without saving using :Q! | |
command! -bar QA qall "Quit all buffers | |
command! -bar Qa qall "Quit all buffers | |
command! -bar -bang QA qall<bang> "Allow quitting without saving using :Q! | |
command! -bar -bang Qa qall<bang> "Allow quitting without saving using :Q! | |
" Make Q useful and avoid the confusing Ex mode. | |
" Pressing Q with this mapping does nothing intentionally | |
noremap Q <nop> | |
" Close window. | |
noremap QQ :q<CR> | |
" close and write | |
noremap WQ :wq<CR> | |
" Close a full tab page. | |
noremap QW :windo bd<CR> | |
" Close all. | |
noremap QA :qa<CR> | |
" Close, damn you! | |
noremap Q! :q!<CR> | |
" Close out of all without saving (be careful ;) | |
nmap <leader>X :qa!<cr> | |
"Save the current file even if you don't have permission to do so | |
"map w!! w !sudo tee % >/dev/null | |
let NERDTreeMinimalUI=1 | |
let NERDTreeDirArrows=1 | |
fun! <SID>StripTrailingWhitespaces() | |
let l = line(".") | |
let c = col(".") | |
%s/\s\+$//e | |
call cursor(l, c) | |
endfun | |
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces() | |
" This switches the cursor into a pipe when in insert mode tmux will only | |
" forward escape sequences to the terminal if surrounded by a DCS sequence | |
" http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinkbdoZ8eNR1X2UobLTeww1jFrvfJxTMfKSq-L%2B%40mail.gmail.com&forum_name=tmux-users | |
if exists('$TMUX') | |
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\" | |
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\" | |
else | |
let &t_SI = "\<Esc>]50;CursorShape=1\x7" | |
let &t_EI = "\<Esc>]50;CursorShape=0\x7" | |
endif | |
" ExCTags window (requires http://ctags.sourceforge.net/) | |
nmap <F8> :TagbarToggle<CR> | |
let g:tagbar_left = 1 | |
"autocmd FileType * nested :call tagbar#autoopen() | |
let g:tagbar_autofocus = 1 | |
let g:tagbar_compact = 1 | |
let g:tagbar_autoclose = 1 | |
cnoremap %% <C-R>=expand('%:h').'/'<cr> | |
map <leader>ew :e %% | |
map <leader>es :sp %% | |
map <leader>ev :vsp %% | |
map <leader>et :tabe %% | |
" Swap two words | |
nmap <silent> gw :s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<CR>`' | |
" Underline the current line with '=' | |
nmap <silent> <leader>u= :t.\|s/./=/g\|:nohls<cr> | |
" Underline the current line with '-' | |
nmap <silent> <leader>u- :t.\|s/./-/g\|:nohls<cr> | |
" set text wrapping toggles | |
nmap <silent> <leader><Leader>tw :set invwrap<CR>:set wrap?<CR> | |
" find merge conflict markers | |
nmap <silent> <leader>fc <ESC>/\v^[<=>]{7}( .*\|$)<CR> | |
" Adjust viewports to the same size | |
map <Leader>= <C-w>= | |
" upper/lower word | |
nmap <leader><leader>u mQviwU`Q | |
nmap <leader><leader>U mQviwu`Q | |
" upper/lower first char of word | |
"nmap <leader>U mQgewvU`Q | |
"nmap <leader>L mQgewvu`Q | |
" Hit S in command mode to save, as :w<CR> is a mouthful and MacVim | |
" Command-S is a bad habit when using terminal Vim. | |
" We overload a command, but use 'cc' for that anyway. | |
"noremap S :w<CR> | |
noremap SS :w<CR> | |
inoremap SS <Esc>:w<CR> | |
"Default searches to "very magic", more like the world outside Vim. | |
nnoremap / /\v | |
vnoremap / /\v | |
nnoremap ? ?\v | |
vnoremap ? ?\v | |
" Move by screen lines instead of file lines. | |
" http://vim.wikia.com/wiki/Moving_by_screen_lines_instead_of_file_lines | |
noremap [A gk | |
noremap [B gj | |
noremap k gk | |
noremap j gj | |
inoremap [B <C-o>gj | |
inoremap [A <C-o>gk | |
" Tab/shift-tab to indent/outdent in visual mode. | |
vnoremap <Tab> >gv | |
vnoremap <S-Tab> <gv | |
" Keep selection when indenting/outdenting. | |
vnoremap > >gv | |
vnoremap < <gv | |
" Move single lines, requires vim-unimpaired plugin. | |
nmap <Esc>[A [e | |
nmap <Esc>[B ]e | |
"exit out of insert mode if so I can move that line | |
inoremap <Esc>[A <Esc> | |
inoremap <Esc>[B <Esc> | |
" Move multiple lines. | |
vmap <Esc>[A [egv | |
vmap <Esc>[B ]egv | |
" TABS | |
nmap <Leader><Leader>to :tabnew<CR> | |
" switch between tabs with Ctrl+<left>/<right> | |
" next tab (ctrl right arrow, or F12) | |
map <Esc>[C gt | |
nmap <F12> :tabn<CR> | |
" previous tab(ctrl left arrow, or F12) | |
map <Esc>[D gT | |
nmap <F11> :tabp<CR> | |
set clipboard=unnamed | |
" Redraw the screen | |
nnoremap <leader>rr :redraw!<cr> | |
" toggle hide numbers | |
map <leader>1 :set nonumber! number?<CR> | |
" Yank to OS X pasteboard. (Need to have this installed and configured per the | |
" tmux book by Brian Hogan https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard.git) | |
noremap <leader>y "*y | |
"NOTES | |
"http://od-eon.com/blogs/liviu/macos-vim-controlarrow-functionality/ | |
"arrow keys, up=A, down=B, right=C and left=D | |
"<C-Up> == <Esc>[A | |
" Do some alignment | |
if exists(":Tabularize") | |
nmap <Leader>a= :Tabularize /=<CR> | |
vmap <Leader>a= :Tabularize /=<CR> | |
nmap <Leader>a> :Tabularize /=><CR> | |
vmap <Leader>a> :Tabularize /=><CR> | |
nmap <Leader>a: :Tabularize /:\zs<CR> | |
vmap <Leader>a: :Tabularize /:\zs<CR> | |
nmap <Leader>a, :Tabularize /,<CR> | |
vmap <Leader>a, :Tabularize /,<CR> | |
endif | |
" Triggers align of cucumber tables when you close it out with a | and have at least two lines | |
function! s:align() | |
let p = '^\s*|\s.*\s|\s*$' | |
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p) | |
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g')) | |
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*')) | |
Tabularize/|/l1 | |
normal! 0 | |
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.')) | |
endif | |
endfunction | |
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a | |
autocmd BufNewFile,BufReadPost *.*.coffee set filetype=coffee | |
autocmd BufNewFile,BufReadPost Guardfile set filetype=ruby | |
autocmd BufNewFile,BufReadPost Gemfile set filetype=ruby | |
autocmd BufNewFile,BufReadPost Vagrantfile set filetype=ruby | |
autocmd BufNewFile,BufReadPost *.ru set filetype=ruby | |
" Load up the vimrc_main file (this file) in vim to edit it | |
nnoremap <Leader>ev :vsp ~/.vimrc_main<CR> | |
" Automatically source this file after it's saved | |
autocmd! bufwritepost .vimrc_main source ~/.vimrc | |
"folding settings | |
set foldmethod=indent "fold based on indent | |
set foldnestmax=10 "deepest fold is 10 levels | |
set nofoldenable "dont fold by default | |
set foldlevel=1 "this is just what i use | |
"NOTE toggle folding with za. | |
"fold everything with zM | |
"unfold everything with zR. | |
"zm and zr can be used too | |
" Buffregator settings | |
let g:buffergator_viewport_split_policy="B" | |
let g:buffergator_split_size=10 | |
let g:buffergator_suppress_keymaps=1 | |
map <Leader>b :BuffergatorOpen<cr> | |
map <Leader>B :BuffergatorClose<cr> | |
" go to the 80th column | |
noremap <leader>8 80\| | |
" commands from insert mode | |
inoremap II <Esc>I | |
inoremap AA <Esc>A | |
inoremap OO <Esc>O | |
" C change what is to the right of the cursor | |
inoremap CC <Esc>C | |
inoremap DD <Esc>dd | |
inoremap UU <Esc>u | |
""Prob won't need this with my new settings | |
"command! CloseHiddenBuffers call s:CloseHiddenBuffers() | |
"function! s:CloseHiddenBuffers() | |
" let open_buffers = [] | |
" for i in range(tabpagenr('$')) | |
" call extend(open_buffers, tabpagebuflist(i + 1)) | |
" endfor | |
" for num in range(1, bufnr("$") + 1) | |
" if buflisted(num) && index(open_buffers, num) == -1 | |
" exec "bdelete ".num | |
" endif | |
" endfor | |
"endfunction | |
" | |
let g:TagmaTasksHeight = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snippet note | |
# NOTE (`strftime("%Y-%m-%d")`) jonk => ${1} | |
snippet fixme | |
# FIXME (`strftime("%Y-%m-%d")`) jonk => ${1} | |
snippet todo | |
# TODO (`strftime("%Y-%m-%d")`) jonk => ${1} | |
snippet pryp | |
binding.pry${1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.tmuxinator/rails.yml | |
# you can make as many tabs as you wish... | |
project_name: rails | |
project_root: /rails/project_name | |
pre: pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start | |
rvm: 1.9.3-p125@gemset_name | |
tabs: | |
- editor: | |
layout: main-horizontal | |
panes: | |
- vim | |
- shell: | |
- console: rails c | |
- database: rails db | |
- logs: tail -f log/development.log | |
- capistrano: | |
- server: ssh me@server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to install vim configuration files | |
# Tested with OSX and Ubuntu. | |
# Will need modifications for windows if home dir is not set | |
# | |
# Easiest way to use this is to run this from your home folder in Terminal: | |
# | |
# exec 3<&1;bash <&3 <(curl https://raw.github.com/gist/2040114/vim.sh 2> /dev/null) | |
# | |
# If you're wondering about the funky chars in the above command... | |
# I needed it to preserve prompting, see here: http://www.programmingforums.org/post199530.html | |
# | |
# You'll need Vim, Git and Curl installed to use this script with bash. | |
# | |
# The first few lines check for an existing Vim setup and ask you if you | |
# want to overwrite it or back it up. I recommend backing any current Vim | |
# settings up so you can refer to them later if need be. (tested on OS X) | |
if [[ -d "$HOME/.vim" && ! -L "$HOME/.vim" ]]; then | |
has_dot_vim="true" | |
fi | |
if [[ -f $HOME/.vimrc ]]; then | |
has_dot_vimrc="true" | |
fi | |
if [[ -f $HOME/.vimrc_main ]]; then | |
has_dot_vimrc_main="true" | |
fi | |
if [[ -f $HOME/.tmux.conf ]]; then | |
has_tmux_conf="true" | |
fi | |
if [[ -d "$HOME/.tmuxinator" && ! -L "$HOME/.tmuxinator" ]]; then | |
has_tmuxinator="true" | |
fi | |
function refresh_vimrc_main(){ | |
curl -s https://raw.github.com/gist/2040114/.vimrc_main > .vimrc_main | |
echo "!!!!! Wrote $HOME/.vimrc_main" | |
} | |
function full_vim_setup(){ | |
echo "!!!!! Creating the necessary Vim directories..." | |
mkdir -pv $HOME/.vim/autoload | |
mkdir -pv $HOME/.vim/backup | |
mkdir -pv $HOME/.vim/bundles | |
mkdir -pv $HOME/.vim/snippets | |
echo ">>>>> cd to $HOME/.vim/bundles to clone some plugins..." | |
cd $HOME/.vim/bundles | |
git clone https://github.com/geekq/ack.vim.git | |
git clone https://github.com/kien/ctrlp.vim.git | |
git clone git://github.com/scrooloose/nerdcommenter.git | |
git clone git://github.com/scrooloose/nerdtree.git | |
#git clone git://github.com/msanders/snipmate.vim.git | |
git clone https://github.com/garbas/vim-snipmate.git | |
git clone https://github.com/tomtom/tlib_vim.git #vim-snipmate dependency | |
git clone https://github.com/MarcWeber/vim-addon-mw-utils.git #vim-snipmate dependency | |
git clone https://github.com/honza/snipmate-snippets.git #vim-snipmate dependency | |
git clone https://github.com/ervandew/supertab.git | |
git clone https://github.com/scrooloose/syntastic.git | |
git clone https://github.com/godlygeek/tabular.git | |
git clone https://github.com/majutsushi/tagbar.git | |
git clone https://github.com/jeetsukumaran/vim-buffergator.git | |
git clone git://github.com/tpope/vim-cucumber.git | |
git clone https://github.com/Lokaltog/vim-easymotion.git | |
git clone git://github.com/tpope/vim-endwise.git | |
git clone https://github.com/tpope/vim-fugitive.git | |
git clone https://github.com/tpope/vim-git.git | |
git clone git://github.com/tpope/vim-haml.git | |
git clone https://github.com/nathanaelkane/vim-indent-guides.git | |
git clone https://github.com/tpope/vim-ragtag.git | |
git clone git://github.com/tpope/vim-rails.git | |
git clone git://github.com/vim-ruby/vim-ruby.git | |
git clone git://github.com/tpope/vim-surround.git | |
git clone https://github.com/tpope/vim-unimpaired.git | |
git clone git://github.com/tpope/vim-vividchalk.git | |
git clone https://github.com/vim-scripts/ZoomWin.git | |
git clone https://github.com/tpope/vim-pastie.git | |
git clone https://github.com/jgdavey/tslime.vim.git | |
git clone https://github.com/jgdavey/vim-turbux.git | |
git clone https://github.com/LStinson/TagmaTasks.git | |
echo ">>>>> cd to $HOME/" | |
cd $HOME | |
# Puts Pathogen in the right location | |
echo "!!!!! Move pathogen to the right location: $HOME/.vim/autoload/pathogen.vim" | |
curl -s https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim > .vim/autoload/pathogen.vim | |
curl -s https://raw.github.com/gist/2040114/.vimrc > .vimrc | |
echo "!!!!! Wrote $HOME/.vimrc" | |
curl -s https://raw.github.com/gist/2040114/_.snippets > .vim/snippets/_.snippets | |
echo "!!!!! Wrote $HOME/.vim/snippets/_.snippets" | |
refresh_vimrc_main | |
} | |
if [ "$has_dot_vim" == "true" -o "$has_dot_vimrc" == "true" -o "$has_dot_vimrc_main" == "true" ]; then | |
echo "***** Note: You already have a Vim configuration..." | |
read -p "????? Would you like to (b)ack it up, (o)verwrite it, (r)efresh .vimrc_main, or (s)kip Vim setup entirely (B/o/r/s)?" | |
if [[ $REPLY =~ ^[Ss]$ ]]; then | |
echo ">>>>> Skipping Vim configuration..." | |
elif [[ $REPLY =~ ^[Rr]$ ]]; then | |
echo ">>>>> Refreshing $HOME/.vimrc_main and leaving the rest of your Vim setup untouched" | |
refresh_vimrc_main | |
elif [[ $REPLY =~ ^[Oo]$ ]]; then | |
echo "!!!!! Deleting current Vim setup..." | |
sudo rm -rf $HOME/.vim | |
rm -f $HOME/.vimrc | |
rm -f $HOME/.vimrc_main | |
full_vim_setup | |
else | |
echo ">>>>> Backing up Vim setup..." | |
echo "!!!!! Appending -bak to the relevant folders and files...." | |
# remove any old backups | |
rm -rf $HOME/.vim-bak | |
rm -rf $HOME/.vimrc-bak | |
rm -rf $HOME/.vimrc_main-bak | |
# backup | |
mv -fv $HOME/.vim $HOME/.vim-bak | |
mv -fv $HOME/.vimrc $HOME/.vimrc-bak | |
mv -fv $HOME/.vimrc_main $HOME/.vimrc_main-bak | |
full_vim_setup | |
fi | |
else | |
read -p "????? No previous Vim setup detected, proceed with a full Vim configuration (Y/n)?" | |
if [[ $REPLY =~ ^[Nn]$ ]]; then | |
echo ">>>>> Skipping Vim configuration..." | |
else | |
full_vim_setup | |
fi | |
fi | |
function setup_tmux(){ | |
echo ">>>>> Setting up Tmux..." | |
curl -s https://raw.github.com/gist/2040114/.tmux.conf > .tmux.conf | |
echo "!!!!! Wrote $HOME/.tmux.conf" | |
read -p "????? Install OS X clipboard support for Tmux and Vim (Y/n)?" | |
if [[ $REPLY =~ ^[Nn]$ ]]; then | |
echo ">>>>> Skipping OS X clipboard support" | |
else | |
echo ">>>>> Ensure /usr/local/bin exists" | |
sudo mkdir -pv /usr/local/bin | |
curl -s https://raw.github.com/gist/2040114/reattach-to-user-namespace > /usr/local/bin/reattach-to-user-namespace | |
echo "!!!!! Wrote /usr/local/bin/reattach-to-user-namespace" | |
echo ">>>>> Ensure /usr/local/bin/reattach-to-user-namespace is executable" | |
sudo chmod +x /usr/local/bin/reattach-to-user-namespace | |
echo "***** NOTE: make sure /usr/local/bin is also in your PATH" | |
fi | |
echo ">>>>> Tmux setup complete" | |
echo "***** Might I suggest some Tmux and tmuxinator bash aliases?" | |
echo | |
echo "alias tl='tmux ls'" | |
echo "alias ta='tmux attach -t \$*'" | |
echo "alias tk='tmux kill-session -t \$*'" | |
echo "alias to='tmuxinator open \$*'" | |
echo "alias ts='tmuxinator start \$*'" | |
echo | |
echo "***** If you so choose, you can manually add the above aliases to your ~/.bashrc or ~/.zshrc" | |
read -p "????? Add rails dev tmuxinator yaml file to $HOME/.tmuxinator (Y/n)" | |
if [[ $REPLY =~ ^[Nn]$ ]]; then | |
echo ">>>>> Skipping Tmuxinator rails dev config" | |
else | |
echo "!!!!! Creating the necessary tmuxinator directories..." | |
if [ "$has_tmuxinator" == "true" ]; then | |
echo "***** note: $HOME/.tmuxinator already exists" | |
else | |
mkdir -pv $HOME/.tmuxinator | |
fi | |
curl -s https://raw.github.com/gist/2040114/rails.yml > $HOME/.tmuxinator/rails.yml | |
echo "!!!!! Wrote $HOME/.tmuxinator/rails.yml" | |
echo "***** NOTE: make sure to install the tmuxinator gem in your global gemset (or another accessible place if you don't use RVM)" | |
fi | |
} | |
if [ "$has_tmux_conf" == "true" ]; then | |
echo "***** Note: You already have a Tmux configuration..." | |
read -p "????? Would you like to (b)ack it up, (o)verwrite it, or (s)kip Tmux alltogether (B/o/s)?" | |
if [[ $REPLY =~ ^[Oo]$ ]]; then | |
echo "!!!!! Deleting current Tmux setup..." | |
rm -fv $HOME/.tmux.conf | |
setup_tmux | |
elif [[ $REPLY =~ ^[Ss]$ ]]; then | |
echo ">>>>> Skipping Tmux" | |
else | |
echo "!!!!! Backing up Tmux setup. Appending -bak to the relevant files..." | |
mv -fv $HOME/.tmux.conf $HOME/.tmux.conf-bak | |
setup_tmux | |
fi | |
else | |
echo ">>>>> No previous Tmux config detected" | |
read -p "????? Would you like to add this Tmux config (Y/n)?" | |
if [[ $REPLY =~ ^[Nn]$ ]]; then | |
echo ">>>>> Skipping Tmux" | |
else | |
setup_tmux | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment