This commit is contained in:
Andrew Tomaka 2016-08-13 16:06:49 -04:00
parent 02f1e08bf8
commit eff7e9d880
10 changed files with 81 additions and 357 deletions

View file

@ -5,11 +5,24 @@ symlinks = $(shell ls $(excludes) `pwd`)
all: install
install: repos $(symlinks)
install: plug-vim $(symlinks)
repos:
if test ! -d ~/.vim/bundle/vundle ; then \
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/vundle ; \
plug-vim:
if test ! -d ~/.vim/autoload/plug.vim ; then \
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim ; \
fi
rbenv: rbenv-base rbenv-build
rbenv-base:
if test ! -d ~/.rbenv ; then \
git clone https://github.com/rbenv/rbenv.git ~/.rbenv ; \
fi
rbenv-build:
if test ! -d ~/.rbenv/plugins/ruby-build ; then \
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build ; \
fi
$(symlinks):

30
aliases
View file

@ -3,25 +3,15 @@ alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias a="ls -l --human-readable --all --color=auto"
alias agi="sudo apt-get install"
alias agl="dpkg --get-selections"
alias agL="dpkg --listfiles"
alias agu="sudo apt-get update && sudo apt-get upgrade"
alias al="zsh_stats"
alias awsp="aws-profile"
alias b="bundle"
alias be="bundle exec"
alias bea="bundle exec rails"
alias beg="bundle exec guard"
alias bej="bundle exec jekyll"
alias ber="bundle exec rake"
alias bet="bundle exec rspec"
alias betd="bundle exec rspec --format documentation"
alias c="clear"
alias dc="docker-compose"
alias dcu="docker-compose up -d"
alias dcr="docker-compose rm --all"
alias f="map-sshfs"
alias g="g" # overwrite g alias in git plugin so function will work
alias ga="git add"
alias gaa="git add --all"
@ -29,13 +19,13 @@ alias gap="git add --patch"
alias gb="git branch"
alias gbc="git branch --merged master | grep -v master | xargs git branch -d"
alias gbda="git branch | grep -v master | xargs git branch -D"
alias gbdm='git branch --merged | grep -v "\*" | grep -v master | grep -v dev | xargs -n 1 git branch -d'
alias gc="git commit"
alias gca="git commit --amend"
alias gcm="echo Do not specify message at command line. Use gc"
alias gco="git checkout"
alias gd="git diff"
alias gdc="git diff --cached"
alias gdm='git branch --merged | grep -v "\*" | grep -v master | grep -v dev | xargs -n 1 git branch -d'
alias gds="git diff --stat"
alias gdss="git diff --shortstat"
alias gfa="git-date-added"
@ -58,7 +48,6 @@ alias grbc="git rebase --continue"
alias grbi="git rebase --interactive"
alias grc="git rm --cached"
alias grh="git reset --hard"
alias gri="echo Use grbi"
alias grm="git rm"
alias gs="git status"
alias gup="git remote update --prune"
@ -67,40 +56,23 @@ alias Grep='grep'
alias h='heroku'
alias hp='git push heroku master'
alias hip='heroku logs -n 1500 | grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+" | sort | uniq'
alias jb="./gradlew"
alias jbd="./gradlew dependencies"
alias jbr="./gradlew run"
alias jbt="./gradlew test"
alias l="ls"
alias ll="ls -lv --human-readable --color=auto"
alias lp="librarian-puppet"
alias ls="ls --color=auto"
alias m="more"
alias md="cd ~/dotfiles > /dev/null 2>&1; make; cd -1 > /dev/null 2>&1"
alias mf="mkdir"
alias ms="tmux -S /tmp/pair && chmod 777 /tmp/pair"
alias mw="tmux new-session -A -s work"
alias p="sudo"
alias pf="port-forward"
alias r="ssh"
alias rd="popd"
alias rs="bundle exec rspec"
alias s="cd ~/Source"
alias sci="ssh-copy-id -i .ssh/id_rsa.pub"
alias sd="pwd | pushd"
alias sfs="map-sshfs"
alias sz="source ~/.zshrc"
alias t="tmux"
alias tls="tmux list-sessions"
alias v="vim"
alias vd="vagrant destroy"
alias vh="vagrant halt"
alias vn="vim -u NONE"
alias vp="vagrant provision"
alias vr="vagrant reload"
alias vs="vagrant status"
alias vssh="vagrant ssh"
alias vu="vagrant up"
alias w="python -m SimpleHTTPServer"
alias wo="curl http://wttr.in/48912?m"
alias x="exit"

View file

@ -27,14 +27,6 @@ function port-forward {
fi
}
function map-sshfs {
if [ $# -eq 0 ]; then
echo Usage: map-sshfs HOST DIRECTORY MOUNT
else
sshfs -o idmap=user -o workaround=rename $USER'@'$1':'$2 $HOME'/Mounts/'$3
fi
}
function gitignore-io {
curl https://www.gitignore.io/api/$@
}

View file

@ -1,26 +0,0 @@
#!/bin/sh
# Copyright 2012 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# git gofmt pre-commit hook
#
# To use, store as .git/hooks/pre-commit inside your repository and make sure
# it has execute permissions.
#
# This script does not handle file names that contain spaces.
gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.go$')
[ -z "$gofiles" ] && exit 0
unformatted=$(gofmt -l $gofiles)
[ -z "$unformatted" ] && exit 0
# Some files are not gofmt'd. Print message and fail.
echo >&2 "Go files must be formatted with gofmt. Please run:"
for fn in $unformatted; do
echo >&2 " gofmt -w $PWD/$fn"
done
exit 1

View file

@ -32,8 +32,6 @@
autocrlf = input
editor = vim
filemode = false
[init]
templatedir = ~/.git_template
[merge]
tool = vimdiff
[push]

View file

@ -1,8 +0,0 @@
#!/bin/bash
if test ! -d ~/.rbenv ; then
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
fi
if test ! -d ~/.rbenv/plugins/ruby-build ; then
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
fi

View file

@ -1,14 +1,14 @@
# for setting up
bind-key r source-file ~/.tmux.conf \; display-message " ✱ ~/.tmux.conf is reloaded"
# ctrl-b is annoying
set-option -g prefix C-a
# 256 colors
set -g default-terminal "screen-256color"
# double tap for back and forth
bind-key C-a last-window
bind-key C-b last-window
# for muxception
bind-key a send-prefix
bind-key b send-prefix
# close window
bind q confirm kill-window
@ -17,10 +17,7 @@ bind q confirm kill-window
set-option -g base-index 1
setw -g pane-base-index 1
# 256 colors (bce matches whatever I am doing with t_Co=256 in vim)
set -g default-terminal "screen-256color"
# hostry should be longer
# history should be longer
set -g history-limit 10000
# no autorename
@ -61,4 +58,5 @@ set-option -g status-right '%d %b %Y @ %k:%M'
# because the new tmux is inadequate
source-file ~/.tmux.1-8.conf # always source the 1.8 file
if-shell 'tmux -V | grep -q "1.9\|2.0\|2.1\|2.2"' "source-file ~/.tmux.1-9.conf"
if-shell "[[ `tmux -V | cut -d' ' -f2` -ge 1.9 ]]" \
"source-file ~/.tmux.1-9.conf"

236
vimrc
View file

@ -1,49 +1,41 @@
scriptencoding utf-8
set encoding=utf-8
" PLUGINS
call plug#begin('~/.vim/plugged')
" fix colors in some ubuntu terminals
set background=dark
" colors
Plug 'alessandroyorba/alduin'
Plug 'nanotech/jellybeans.vim'
" vundle bundle; not for changing
set nocompatible " Disable vi compatibility
filetype off
" keepers
Plug 'airblade/vim-gitgutter'
Plug 'bronson/vim-trailing-whitespace'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'rbgrouleff/bclose.vim'
Plug 'tpope/vim-surround'
Plug 'vim-scripts/ZoomWin'
set runtimepath+=~/.vim/bundle/vundle/
call vundle#begin()
" languages
Plug 'fatih/vim-go'
Plug 'posva/vim-vue'
Plug 'tpope/vim-markdown'
Plug 'tpope/vim-rails'
Plug 'vim-ruby/vim-ruby'
Plugin 'gmarik/vundle'
" maybe
Plug 'tommcdo/vim-lion'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plugin 'airblade/vim-gitgutter'
Plugin 'bronson/vim-trailing-whitespace'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'fatih/vim-go'
Plugin 'godlygeek/tabular'
Plugin 'itchyny/lightline.vim'
Plugin 'nathanaelkane/vim-indent-guides'
Plugin 'posva/vim-vue'
Plugin 'rbgrouleff/bclose.vim'
Plugin 'rodjek/vim-puppet'
Plugin 'thoughtbot/vim-rspec'
Plugin 'tpope/vim-dispatch'
Plugin 'tpope/vim-endwise'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-markdown'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-vividchalk'
Plugin 'vim-ruby/vim-ruby'
call plug#end()
call vundle#end()
filetype plugin indent on
" end vundle
" STATUS LINE
set statusline=%<\ %f\ %m%r%y%w%=%l\/%-6L\ %3c\
" Options
" OPTIONS
set fileformats=unix,mac,dos " File format prefer unix endings
set endofline " Add newlien at end of file
set shellslash " Forward slashes
set nobackup " No backup files
set noswapfile " Hope for the best
set formatoptions=crq
set textwidth=80
set cpoptions+=$ " delimit end of change text
@ -55,8 +47,8 @@ set cursorcolumn " Highlight current column
set nowrap " Disable wrapping by default
set backspace=2 " Backspace over indent, eol, start of insert
set hlsearch " Search highlights
set wrapscan " Wraped search
set incsearch " Search as yuo type
set wrapscan " Wrapped search
set incsearch " Search as you type
set ignorecase " Ignore case with search
set smartcase " Search will not ignore uppercase
set showcmd " Show command as you type
@ -67,7 +59,6 @@ set colorcolumn=80 " Ruler at line 80
set nomodeline
set relativenumber " Relative line numbers
set number
set noswapfile " Hope for the best
set virtualedit=all " Cursor can go anywhere
set scrolloff=3 " Keep cursor from touching edges
set timeoutlen=500 " Don't wait too long (ambiguous leaders)
@ -76,19 +67,14 @@ set hidden " Allow unsaved buffers to be hidden
set wildmenu " Command line completion
set wildmode=list:longest,full " Better file completion
set infercase " Adjust completions to match case
set noshowmode " Already tracking mode with plugin
set wildignorecase " Ignore case on commandline
set autowrite " Save file when focus is lost
" Make syntax highlighting faster
syntax sync minlines=256
set ttyfast
set lazyredraw
" Tabs are 2 spaces
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
set shiftround " if at odd number spaces, make >> go to next even
set shiftround " make >> go to next tab
" Show whitespace markers before cursor in insert mode
set list listchars=tab:\ \ ,trail
" Ignore stuff
@ -104,42 +90,21 @@ if has('persistent_undo')
set undofile
endif
" Filetype stuff
syntax on
" Keybinds
" ctrl+s for save spam
map <C-s> <esc>:w<CR>
imap <C-s> <esc>:w<CR>
" KEYBINDS
" quick replaceement
nmap S :%s//g<LEFT><LEFT>
" consistency is key - Y should act like C, D
map Y y$
" Still using arrow keys when in insert mode sometimes
map <Left> <NOP>
map <Right> <NOP>
map <Up> <NOP>
map <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
inoremap <Up> <NOP>
inoremap <Down> <NOP>
" Don't cancel visual mode while indenting
vnoremap > >gv
vnoremap < <gv
" Use better search highlighting
nnoremap <silent> n n:call HLNext(0.4)<cr>
nnoremap <silent> N N:call HLNext(0.4)<cr>
" ZoomWin
nmap <c-w>z <Plug>ZoomWin
" i don't even know what semi-colon does so steal it
noremap ; :
" Leaders (shortcuts)
" LEADERS
let mapleader = ","
" tab swaps
@ -147,107 +112,34 @@ map <Leader>2 :set tabstop=2 softtabstop=2 shiftwidth=2 expandtab<cr>
map <Leader>4 :set tabstop=4 softtabstop=4 shiftwidth=4 expandtab<cr>
map <Leader>a :set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab<cr>
" buffer movement
map <Leader>h :wincmd h<cr>
map <Leader>j :wincmd j<cr>
map <Leader>k :wincmd k<cr>
map <Leader>l :wincmd l<cr>
" auto character alignment
map <Leader>t> :Tabularize /=><cr>
map <Leader>te :Tabularize /=<cr>
" vundle
map <Leader>bi :PluginInstall<cr>
map <Leader>bu :PluginInstall!<cr>
" copy and paste - for Linux
map <Leader>c "+
map <Leader>p "+p
map <Leader>pm :set paste!<cr>
" plugin
map <Leader>bi :PlugInstall<cr>
map <Leader>bu :PlugUpdate<cr>
" clear search
map <Leader>cs :let @/ = ""<cr>
" indent and return
map <Leader>i mmgg=G`m<cr>
" reload all buffers
map <Leader>ra :bufdo e!<cr>
" this was better when it was :Sexplore...
map <Leader>s :Vexplore ~/Source/<cr>
map <Leader>d :Vexplore .<cr>
" bclose
nnoremap <silent> <Leader>bd :Bclose<CR>
nnoremap <silent> <Leader>bD :Bclose!<CR>
nnoremap <silent> <Leader>BD :Bclose!<CR>
" other
map <Leader>fw :FixWhitespace<cr>
map <Leader>lf :call LargeFileToggle()<cr>
map <Leader>pm :set paste!<cr>
map <Leader>sa :call RenameFile()<cr>
map <Leader>se :e ~/.vimrc<cr>
map <Leader>st :call SyntaxToggle()<cr>
map <Leader>sz :so ~/.vimrc<cr>
map <Leader>ts :sp ~/tool-sharpener.txt<cr>
" rspec
map <Leader>t :w<cr>:call RunNearestSpec()<cr>
" Set style
colorscheme vividchalk
" special case colors set at end of file via function
" dispatch fix for bundle exec rspec always quickfixing
let g:dispatch_compilers = {
\ 'bundle exec': ''}
" rspec
let g:rspec_command = "Dispatch bundle exec rspec {spec}"
" Indentation
let g:indent_guides_guide_size=1
let g:indent_guides_enable_on_vim_startup=1
let g:indent_guides_auto_colors=0
" lightline
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'filename' ] ]
\ },
\ 'component': {
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
\ },
\ 'component_visible_condition': {
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ }
\ }
" PLUGIN CONFIGURATION
" style
colorscheme jellybeans
syntax enable
" go
let g:go_fmt_command = "goimports"
" editorconfig with fugitive
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
" Functions
" Toggle relative line numbers and cursorline; useful for long line files
function! LargeFileToggle()
set relativenumber!
set cursorline!
set cursorcolumn!
call SyntaxToggle()
endfunction
" Toggle syntax highlighting
function! SyntaxToggle()
if exists("g:syntax_on")
:syntax off
else
syntax enable
endif
call SetColors()
endfunction
" FUNCTIONS
" Rename current file - from github/garybernhardt
function! RenameFile()
let old_name = expand('%')
@ -258,43 +150,3 @@ function! RenameFile()
redraw!
endif
endfunction
" Blink current search item - from Damian Conway 'More Instantly Better Vim'
function! HLNext (blinktime)
let [bufnum, lnum, col, off] = getpos('.')
let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))
let target_pat = '\c\%#'.@/
let ring = matchadd('ErrorMsg', target_pat, 101)
redraw
exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
call matchdelete(ring)
redraw
endfunction
" Zoom / Restore window.
function! s:ZoomToggle() abort
if exists('t:zoomed') && t:zoomed
execute t:zoom_winrestcmd
let t:zoomed = 0
else
let t:zoom_winrestcmd = winrestcmd()
resize
vertical resize
let t:zoomed = 1
endif
endfunction
command! ZoomToggle call s:ZoomToggle()
nnoremap <silent> <C-w>z :ZoomToggle<CR>
" Set special case colors
function! SetColors()
highlight CursorLine cterm=NONE ctermbg=234
highlight CursorColumn cterm=NONE ctermbg=234
highlight StatusLine ctermfg=white ctermbg=236
highlight ColorColumn ctermbg=234
highlight IndentGuidesOdd ctermbg=black
highlight IndentGuidesEven ctermbg=234
endfunction
" Needs to come after SetColors definition
call SetColors()

View file

@ -1,73 +0,0 @@
# fixme - the load process here seems a bit bizarre
unsetopt menu_complete # do not autoselect the first completion entry
unsetopt flowcontrol
setopt auto_menu # show completion menu on succesive tab press
setopt complete_in_word
setopt always_to_end
WORDCHARS=''
zmodload -i zsh/complist
## case-insensitive (all),partial-word and then substring completion
if [ "x$CASE_SENSITIVE" = "xtrue" ]; then
zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
unset CASE_SENSITIVE
else
if [ "x$HYPHEN_INSENSITIVE" = "xtrue" ]; then
zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
unset HYPHEN_INSENSITIVE
else
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
fi
fi
zstyle ':completion:*' list-colors ''
# should this be in keybindings?
bindkey -M menuselect '^o' accept-and-infer-next-history
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
if [ "$OSTYPE[0,7]" = "solaris" ]
then
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm"
else
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
fi
# disable named-directories autocompletion
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
# Use caching so that commands like apt and dpkg complete are useable
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion::complete:*' cache-path $ZSH_CACHE_DIR
# Don't complete uninteresting users
zstyle ':completion:*:*:*:users' ignored-patterns \
adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
usbmux uucp vcsa wwwrun xfs '_*'
# ... unless we really want to.
zstyle '*' single-ignored show
if [[ $COMPLETION_WAITING_DOTS = true ]]; then
expand-or-complete-with-dots() {
# toggle line-wrapping off and back on again
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam
print -Pn "%{%F{red}......%f%}"
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam
zle expand-or-complete
zle redisplay
}
zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots
fi

18
zshrc
View file

@ -18,7 +18,6 @@ source $HOME/.aliases
source $HOME/.functions
source $HOME/.zsh/prompt
source $HOME/.zsh/completion
if [[ "$OSTYPE" == darwin* ]]; then
source $HOME/.aliases-mac
@ -28,11 +27,6 @@ fi
zle -N insert-sudo
bindkey "^z" insert-sudo
# make 256colors work maybe
if [ $TERM="xterm" ]; then
export TERM=xterm-256color
fi
# default editor is vim
export EDITOR='vim'
@ -45,3 +39,15 @@ fi
if test -d "$NVM_DIR"; then
source "$NVM_DIR/nvm.sh"
fi
# temporary fix for tmux
bindkey "^a" beginning-of-line
bindkey "^e" end-of-line
# completion
autoload -U compinit
compinit
setopt completeinword
# directory
setopt auto_cd