Skip to content

Instantly share code, notes, and snippets.

@zmajstor
Created November 28, 2014 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zmajstor/24b2a6ac06ed99c7c3dd to your computer and use it in GitHub Desktop.
Save zmajstor/24b2a6ac06ed99c7c3dd to your computer and use it in GitHub Desktop.
dot files
xport PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
export EDITOR='mate -w'
# export LANG=hr_HR.UTF-8
# run SSL Thin
# alias rssl="thin start -p 8443 --ssl --ssl-verify --ssl-key-file ~/.ssl_server/ssl_private.key --ssl-cert-file ~/.ssl_server/ssl_cert.cer"
# Set colors to match iTerm2 Terminal Colors
# export TERM=xterm-256color
# Tell ls to be colourful
export CLICOLOR=1
# Tell grep to highlight matches
export GREP_OPTIONS='--color=auto'
source ~/bin/git-completion.bash
alias be="bundle exec"
# alias srs="spring rails s"
# alias src="spring rails c"
alias rs="bundle exec rails s"
alias rc="bundle exec rails c"
alias ra="bundle exec rake"
gem: --no-rdoc --no-ri
[user]
name = Zoran M
email = zoran.majstorovic@gmail.com
[alias]
co = checkout
ci = commit
st = status
last = log -1 HEAD
hi = log -10 --pretty=format:\"%h - %an, %ar : %s\"
l2w = log --since=2.weeks --pretty=format:\"%h - %an, %ar : %s\"
[color]
branch = auto
diff = auto
status = auto
ui = true
[core]
editor = mate -w
[credential]
helper = osxkeychain
[push]
default = simple
set nocompatible
set encoding=utf-8
set term=xterm
filetype plugin indent on
syntax on
"syntax enable
set background=dark
"let g:solarized_termcolors=256
"colorscheme solarized
set t_Co=256
color cobalt
colorscheme cobalt
set synmaxcol=800 " don't try to highlight long lines
set number
set ruler " show the cursor position all the time
set cursorline " highlight the line of the cursor
set showcmd " show partial commands below the status line
set shell=bash " avoids munging PATH under zsh
let g:is_bash=1 " default shell syntax
set history=200 " remember more Ex commands
set scrolloff=3 " have some context around the current line always on screen
" make tab completion for files/buffers act like bash
set wildmode=longest,list
set wildmenu
" Allow backgrounding buffers without writing them, and remember marks/undo
" for backgrounded buffers
set hidden
" Auto-reload buffers when file changed on disk
set autoread
" Disable swap files; systems don't crash that often these days
set updatecount=0
"" Whitespace
set nowrap " don't wrap lines
set tabstop=2 " a tab is two spaces
set shiftwidth=2 " an autoindent (with <<) is two spaces
set expandtab " use spaces, not tabs
set list " Show invisible characters
set backspace=indent,eol,start " backspace through everything in insert mode
" Joining lines
if v:version > 703 || v:version == 703 && has("patch541")
set formatoptions+=j " Delete comment char when joining commented lines
endif
set nojoinspaces " Use only 1 space after "." when joining lines, not 2
" Indicator chars
set listchars=tab:▸\ ,trail:•,extends:❯,precedes:❮
set showbreak=↪\
set sidescroll=5 " minimum number of columns to scroll horizontally
"" Searching
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
set gdefault " have :s///g flag by default on
" Time out on key codes but not mappings.
" Basically this makes terminal Vim work sanely.
set notimeout
set ttimeout
set ttimeoutlen=100
" More intuitive splitting
set splitright
set splitbelow
if has("autocmd")
" Avoid showing trailing whitespace when in insert mode
au InsertEnter * :set listchars-=trail:•
au InsertLeave * :set listchars+=trail:•
" In Makefiles, use real tabs, not tabs expanded to spaces
au FileType make set noexpandtab
" Make sure all markdown files have the correct filetype set and setup wrapping
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn,txt} setf markdown
" Treat JSON files like JavaScript
au BufNewFile,BufRead *.json setf javascript
" https://github.com/sstephenson/bats
au BufNewFile,BufRead *.bats setf sh
" Remember last location in file, but not for commit messages.
" see :help last-position-jump
au BufReadPost * if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g`\"" | endif
" mark Jekyll YAML frontmatter as comment
au BufNewFile,BufRead *.{md,markdown,html,xml} sy match Comment /\%^---\_.\{-}---$/
" magic markers: enable using `H/S/J/C to jump back to
" last HTML, stylesheet, JS or Ruby code buffer
au BufLeave *.{erb,html} exe "normal! mH"
au BufLeave *.{css,scss,sass} exe "normal! mS"
au BufLeave *.{js,coffee} exe "normal! mJ"
au BufLeave *.{rb} exe "normal! mC"
endif
" don't use Ex mode, use Q for formatting
map Q gq
" clear the search buffer when hitting return
nnoremap <CR> :nohlsearch<cr>
" toggle the current fold
nnoremap <Space> za
let mapleader=","
" Make Vim use system clipboard for copy and paste
set clipboard=unnamed
" expand %% to current directory in command-line mode
" http://vimcasts.org/e/14
cnoremap %% <C-R>=expand('%:h').'/'<cr>
nmap <leader>gl :CommandTFlush<cr>\|:CommandT lib<cr>
nmap <leader>f :CommandTFlush<cr>\|:CommandT<cr>
nmap <leader>F :CommandTFlush<cr>\|:CommandT %%<cr>
let g:CommandTMaxHeight=10
let g:CommandTMinHeight=2
" Use "The Silver Searcher" instead of "Ack" in ack.vim
let g:ackprg = 'ag --nogroup --nocolor --column'
" In command-line mode, C-a jumps to beginning (to match C-e)
cnoremap <C-a> <Home>
" ignore Rubinius, Sass cache files
set wildignore+=tmp/**,*.log,*.rbc,.rbx,*.scssc,*.sassc
set wildignore+=.git
" ignore Bundler standalone/vendor installs & gems
set wildignore+=bundle/**,vendor/bundle/**,vendor/cache/**
set wildignore+=node_modules/**
" ignore general tempfiles
set wildignore+=.DS_Store,.git/**,.bundle/**,.binstubs/**
" toggle between last open buffers
nnoremap <leader><leader> <c-^>
command! KillWhitespace :normal :%s/ *$//g<cr><c-o><cr>
" disable cursor keys in normal mode
" map <Left> :echo "no!"<cr>
" map <Right> :echo "no!"<cr>
" map <Up> :echo "no!"<cr>
" map <Down> :echo "no!"<cr>
" easier navigation between split windows
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" Shortcuts for testing, uses the bin/test script
nmap <leader>w :exec ":!~/bin/test " . expand("%") . " " . line(".")<cr>
nmap <leader>t :exec ":!~/bin/test " . expand("%")<cr>
" Shortcut for YARD
nmap <leader>d :exec ":!yardoc"<cr>
" Shortcut for running files
nmap <leader>r :exec ":!~/bin/run " . expand("%")<cr>
" MULTIPURPOSE TAB KEY
" Indent if we're at the beginning of a line. Else, do completion.
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-n>
let g:xmpfilter_cmd = "seeing_is_believing"
autocmd FileType ruby nmap <buffer> <F2> <Plug>(seeing_is_believing-run)
autocmd FileType ruby xmap <buffer> <F2> <Plug>(seeing_is_believing-run)
autocmd FileType ruby imap <buffer> <F2> <Plug>(seeing_is_believing-run)
autocmd FileType ruby nmap <buffer> <F3> <Plug>(seeing_is_believing-mark)
autocmd FileType ruby xmap <buffer> <F3> <Plug>(seeing_is_believing-mark)
autocmd FileType ruby imap <buffer> <F3> <Plug>(seeing_is_believing-mark)
autocmd FileType ruby nmap <buffer> <F4> <Plug>(seeing_is_believing-run_-x)
autocmd FileType ruby xmap <buffer> <F4> <Plug>(seeing_is_believing-run_-x)
autocmd FileType ruby imap <buffer> <F4> <Plug>(seeing_is_believing-run_-x)
autocmd FileType ruby nmap <buffer> <F5> <Plug>(seeing_is_believing-clean)
autocmd FileType ruby xmap <buffer> <F5> <Plug>(seeing_is_believing-clean)
autocmd FileType ruby imap <buffer> <F5> <Plug>(seeing_is_believing-clean)
" populate arglist with files from the quickfix list
command! -nargs=0 -bar Qargs execute 'args' QuickfixFilenames()
function! QuickfixFilenames()
" Building a hash ensures we get each buffer only once
let buffer_numbers = {}
for quickfix_item in getqflist()
let buffer_numbers[quickfix_item['bufnr']] = bufname(quickfix_item['bufnr'])
endfor
return join(map(values(buffer_numbers), 'fnameescape(v:val)'))
endfunction
" for example, :Filter red\|blue lists all lines that contain red or blue.
command! -nargs=? Filter let @a='' | execute 'g/<args>/y A' | new | setlocal bt=nofile | put! a
if has("gui_macvim")
let macvim_hig_shift_movement = 1
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment