Skip to content

Instantly share code, notes, and snippets.

@vindir
Last active September 8, 2016 01:38
Show Gist options
  • Select an option

  • Save vindir/36038f37f325b65f975b to your computer and use it in GitHub Desktop.

Select an option

Save vindir/36038f37f325b65f975b to your computer and use it in GitHub Desktop.
dotfiles dump
# ~/.bash_logout -*- coding: utf-8 -*-
#-----------------------------------------------------------------------------
echo "Goodbye!"
sleep 2
if [ "$SHLVL" = 1 ] && [ -x /usr/bin/clear_console ]; then
/usr/bin/clear_console -q
else
clear
fi
echo -en "\nduration: "
echo -e "`expr $SECONDS / 3600` hours `expr $SECONDS / 60` mins `expr $SECONDS % 60` secs\n"
# Exports
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:$PATH
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
export RAILS_ENV=development
export OPSCODE_USER=vindir
export VIRTENVS=~/Envs
# Theming
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
#export LSCOLORS=ExFxBxDxCxegedabagacad
source ~/.shell_prompt.sh # promptline generated prompting
# Shell extension sourcing
source `brew --repository`/Library/Contributions/brew_bash_completion.sh
source /usr/local/bin/virtualenvwrapper.sh
source /Users/jowens/.config/base16-shell/base16-monokai.dark.sh
# RVM Setup
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
# Aliases
alias fortune="fortune | lolcat"
alias free="vm_stat"
alias vmstat="vm_stat"
alias ggr="grep -R"
alias grep="grep --color"
alias dtree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
alias gcp="git cherry-pick"
alias gpu='git push -u'
alias gp='git push'
alias git=hub
alias vi=vim
alias ls='ls -GFh'
#Forgot as usual
#git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit"
set -o vi
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
github_prefetch () {
local fetch_return=''
local fetch_status=''
local UPDATE_INTERVAL=300
local GH_BRANCH_PREV=$GH_BRANCH
export GH_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [ -n "$GH_BRANCH" ]; then
if git show-ref --quiet --verify refs/remotes/origin/$GH_BRANCH; then
: found remote
else
export GH_STATUS='-'
return 0
fi
#if [ $? -ne 0 ]; then
# export GH_STATUS='-'
# return 0
#fi
if [ "$GH_BRANCH" != "$GH_BRANCH_PREV" ]; then
export GH_LAST_FETCH=$(date +%s)
git fetch -q
fi
if [ -z "$GH_LAST_FETCH" ]; then
export GH_LAST_FETCH=$(date +%s)
git fetch -q
fi
fetch_status=$(git log HEAD..remotes/origin/$GH_BRANCH --oneline)
# Use $RANDOM if you'd rather trigger the fetch 10% of the time
# if [ $(($RANDOM % 10)) -lt 1 ]; then
if [ $(($(date +%s) - $GH_LAST_FETCH)) -gt $UPDATE_INTERVAL ]; then
export GH_LAST_FETCH=$(date +%s)
git fetch -q
fi
fi
if [ -z "$fetch_status" ]; then
fetch_return=' '
else
fetch_return='!'
fi
export GH_STATUS=$fetch_return
return 0
}
PROMPT_COMMAND=github_prefetch
export PS1="[\$GH_STATUS] \h:\W \u$ "
source ~/.bash_profile
" Vundle Initialization "
"""""""""""""""""""""""""
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'altercation/vim-colors-solarized'
Bundle 'jpo/vim-railscasts-theme'
Bundle 'jnurmine/Zenburn'
Bundle 'tomasr/molokai'
Bundle 'sickill/vim-monokai'
Bundle 'vim-scripts/phd'
Bundle 'djjcast/mirodark'
Bundle 'jlanzarotta/bufexplorer'
" Bundle 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
Bundle 'bling/vim-airline'
Bundle 'Syntastic'
Bundle 'airblade/vim-gitgutter'
Bundle 'chrisbra/csv.vim'
Bundle 'majutsushi/tagbar'
Bundle 'kien/ctrlp.vim'
Bundle 'rodjek/vim-puppet'
Bundle 'tpope/vim-fugitive'
Bundle 'nanotech/jellybeans.vim'
Bundle 'chriskempson/tomorrow-theme'
Bundle 'godlygeek/tabular'
Bundle 'msanders/snipmate.vim'
Bundle 'plasticboy/vim-markdown'
Bundle 'tpope/vim-vividchalk'
Bundle 'mattn/webapi-vim'
Bundle 'mattn/gist-vim'
Bundle 'edkolev/promptline.vim'
Bundle 'Yggdroot/indentLine'
filetype plugin indent on " required!
" Core Configuration "
""""""""""""""""""""""
" General Settings
set path=/Users/jowens/Workspace
set history=1000
set undolevels=1000
set ignorecase " ignore case on searches
set smartcase " ignore case, but be smart about it
set hlsearch " highlight search results
set incsearch " jump while mid-way through searching
set lazyredraw " don't redraw while executing macros
set magic " enable regex simplification for special chars
set showmatch " show bracket matching on hover
set mat=2 " Set bracket match blink rate in 1/10s of a second
set noerrorbells " No annoying sound on errors
set novisualbell " No annoying visual on errors
set t_vb= " Redundantly kill of visual/audible error alerts
set tm=500 " Set global timeout length in ms
" Spacing/Presentation
set number
set ruler
set backspace=2 " Backspace handling - :h bs
set textwidth=79 " lines longer than 79 columns will be broken
set scrolloff=7 " margin of space above/below cursor
set tabstop=4 " an hard TAB displays as 4 columns
set softtabstop=2 " insert/delete 2 spaces when hitting a TAB/BACKSPACE
set shiftwidth=2 " operation >> indents 2 columns; << unindents 2 columns
set smarttab " insert tabs on the start of a line according to
" shiftwidth, not tabstop
set expandtab " insert spaces when hitting TABs
set shiftround " round indent to multiple of 'shiftwidth'
set autoindent " align the new line indent with the previous line
set laststatus=2 " always display status line
set term=xterm-256color
set encoding=utf-8
set termencoding=utf-8
set fillchars+=stl:\ ,stlnc:\
set ff=unix " Use Unix as the standard file type
" set ffs=unix,dos,mac " attempt filetype fallback
set wildmenu
set wildmode=longest:full,full
set wildignore=*.o,*~,*.pyc " Ignore compiled files
set pastetoggle=<F3>
" Set extra options when running in GUI mode
if has("gui_running")
set guioptions-=T
set guioptions+=e
set t_Co=256
set guitablabel=%M\ %t
endif
" Syntax & Colorschemes
syntax enable
set background=dark
" colorscheme railscasts
colorscheme monokai
" Backups
silent !mkdir -p ~/.vim/backup > /dev/null 2>&1
silent !mkdir -p ~/.vim/swap > /dev/null 2>&1
set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
" Keyboard handling
" set paste " paste mode breaks insert mode mappings
let mapleader = ','
nnoremap <leader>f :CtrlP<cr>
nnoremap <leader>t :CtrlPTag<cr>
nnoremap <leader>b :CtrlPBuffer<cr>
nnoremap <leader>a :CtrlPMixed<cr>
nnoremap <leader>m :CtrlPMRU<cr>
nnoremap <leader>c :bdelete<cr>
nnoremap <leader>o :Explore<cr>
nnoremap <silent> <Leader>. :TagbarToggle<CR><C-w><C-w>
" Move to the previous buffer with "gp"
nnoremap gp :bp<CR>
" Move to the next buffer with "gn"
nnoremap gn :bn<CR>
" List all possible buffers with "gl"
nnoremap gl :ls<CR>
" List all possible buffers with "gb" and accept a new buffer argument [1]
nnoremap gb :ls<CR>:b
nnoremap <leader>j <PageDown>
nnoremap <leader>k <PageUp>
nnoremap <leader>w :w<cr>
" Treat long lines as break lines (useful when moving around in them)
map j gj
map k gk
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
if has("mac") || has("macunix")
nmap <D-j> <M-j>
nmap <D-k> <M-k>
vmap <D-j> <M-j>
vmap <D-k> <M-k>
endif
" Delete trailing white space on save
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.rb :call DeleteTrailingWS()
autocmd BufWrite *.py :call DeleteTrailingWS()
autocmd BufWrite *.coffee :call DeleteTrailingWS()
autocmd BufWrite *.js :call DeleteTrailingWS()
" Remap Esc to jj for exiting insert mode
inoremap jj <Esc>
" Remap keys to maneuver in insert mode
inoremap <c-d> <esc>ddi
" Easier window navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" Quickly edit/reload the vimrc file
nmap <silent> <leader>ve :e $MYVIMRC<CR>
nmap <silent> <leader>vs :so $MYVIMRC<CR>
" set ,/ to clear search highlighting
nmap <silent> ,/ :nohlsearch<CR>
" allow sudo to be reactively invoked with w!!
cmap w!! w !sudo tee % >/dev/null
" whitespace highlighting
set list
set listchars=tab:>.,trail:.,extends:#,nbsp:.
autocmd filetype html,xml set listchars-=tab:>.
" remap shortcuts
nnoremap ; :
" Use Q for formatting current paragaph or selection
vmap Q gq
vmap Q gqap
""""""""""""""""""
" Plugin Configs "
""""""""""""""""""
" Airline Config "
""""""""""""""""""
let g:airline_powerline_fonts = 1
" enable buffer list
let g:airline#extensions#tabline#enabled = 1
" Show just the filename
" let g:airline#extensions#tabline#fnamemod = ':t'
let g:airlinesymbols = {}
let g:airlineleftsep = '»'
let g:airlinerightsep = '«'
let g:airlinesymbols.linenr = '¶'
let g:airlinesymbols.branch = 'Þ'
let g:airlinesymbols.paste = 'Þ'
let g:airlinesymbols.whitespace = '.'
" Indent Line "
"""""""""""""""
let g:indentLine_color_term = 237
let g:indentLine_color_gui = '#A4E57E'
"let g:indentLine_char = '¦'
" let g:indentLine_char = '┆'
let g:indentLine_char = '│'
" Tagbar Config "
"""""""""""""""""
" Tagbar Config :: Markdown Ctags
let g:tagbar_type_markdown = {
\ 'ctagstype' : 'markdown',
\ 'kinds' : [
\ 'h:Heading_L1',
\ 'i:Heading_L2',
\ 'k:Heading_L3'
\ ]
\ }
" Tagbar Config :: Puppet Ctags
let g:tagbar_type_puppet = {
\ 'ctagstype': 'puppet',
\ 'kinds': [
\'c:class',
\'s:site',
\'n:node',
\'d:definition'
\]
\}
" CtrlP Config "
""""""""""""""""
" Set no max file limit
let g:ctrlp_max_files = 0
" Search from current directory instead of project root
" let g:ctrlp_working_path_mode = 0
let g:ctrlp_working_path_mode = 'rc'
" Ignore these directories
set wildignore+=*/out/**
set wildignore+=*/vendor/**
" Search in certain directories a large project (hardcoded for now)
" cnoremap %proj <c-r>=expand('~/Workspace')<cr>
" ga = go api
" map <Leader>ga :CtrlP %proj/api/<cr>
" gf = go frontend
" map <Leader>gf :CtrlP %proj/some/long/path/to/frontend/code/<cr>
" Syntastic Configuration "
"""""""""""""""""""""""""""
let g:syntastic_enable_signs=1
let g:syntastic_quiet_messages = {'level': 'warnings'}
let g:syntastic_auto_loc_list=1
"To enable Just puppet-lint and disable the parser uncomment next line
""let g:syntastic_puppet_checkers=['puppetlint']
" Markdown Configuration "
""""""""""""""""""""""""""
let g:vim_markdown_initial_foldlevel=0 " Set Initial Foldlevel
" let g:vim_markdown_folding_disabled=1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => vimgrep searching and cope displaying
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" When you press gv you vimgrep after the selected text
vnoremap <silent> gv :call VisualSelection('gv')<CR>
" Open vimgrep and put the cursor in the right position
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
" Vimgreps in the current file
map <leader><space> :vimgrep // <C-R>%<C-A><right><right><right><right><right><right><right><right><right>
" When you press <leader>r you can search and replace the selected text
vnoremap <silent> <leader>r :call VisualSelection('replace')<CR>
" Do :help cope if you are unsure what cope is. It's super useful!
"
" When you search with vimgrep, display your results in cope by doing:
" <leader>cc
"
" To go to the next search result do:
" <leader>n
"
" To go to the previous search results do:
" <leader>p
"
map <leader>cc :botright cope<cr>
map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg
map <leader>n :cn<cr>
map <leader>p :cp<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pressing ,ss will toggle and untoggle spell checking
map <leader>ss :setlocal spell!<cr>
" Shortcuts using <leader>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Misc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remove the Windows ^M - when the encodings gets messed up
" noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
" Quickly open a buffer for scripbble
" map <leader>q :e ~/buffer<cr>
" Toggle paste mode on and off
" map <leader>pp :setlocal paste!<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
function! VisualSelection(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
" Don't close window, when deleting a buffer
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
http://powerline.readthedocs.org/en/latest/overview.html#installation # MmmFonts
brew install hub # https://github.com/github/hub
sudo easy_install pip
sudo pip install virtualenv
sudo pip install virtualenvwrapper
mkdir ~/.virtualenvs
mkdir -p ~/Envs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment