From eff7e9d88059bd073c440c6d40d7645b2816b15c Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Sat, 13 Aug 2016 16:06:49 -0400 Subject: [PATCH] Revamp --- Makefile | 21 ++- aliases | 30 +---- functions | 8 -- git_template/hooks/pre-commit | 26 ---- gitconfig | 2 - linux.sh | 8 -- tmux.conf | 16 +-- vimrc | 236 +++++++--------------------------- zsh/completion | 73 ----------- zshrc | 18 ++- 10 files changed, 81 insertions(+), 357 deletions(-) delete mode 100755 git_template/hooks/pre-commit delete mode 100755 linux.sh delete mode 100644 zsh/completion diff --git a/Makefile b/Makefile index 224ccdd..f4acdfb 100644 --- a/Makefile +++ b/Makefile @@ -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): diff --git a/aliases b/aliases index ac88a0a..f06642e 100644 --- a/aliases +++ b/aliases @@ -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" diff --git a/functions b/functions index db94f45..ca9cc30 100644 --- a/functions +++ b/functions @@ -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/$@ } diff --git a/git_template/hooks/pre-commit b/git_template/hooks/pre-commit deleted file mode 100755 index 68c1026..0000000 --- a/git_template/hooks/pre-commit +++ /dev/null @@ -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 diff --git a/gitconfig b/gitconfig index 4e414ce..633793d 100644 --- a/gitconfig +++ b/gitconfig @@ -32,8 +32,6 @@ autocrlf = input editor = vim filemode = false -[init] - templatedir = ~/.git_template [merge] tool = vimdiff [push] diff --git a/linux.sh b/linux.sh deleted file mode 100755 index 0e70038..0000000 --- a/linux.sh +++ /dev/null @@ -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 diff --git a/tmux.conf b/tmux.conf index 73bd579..84a0e9d 100644 --- a/tmux.conf +++ b/tmux.conf @@ -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" diff --git a/vimrc b/vimrc index d72105d..a9ab7c2 100644 --- a/vimrc +++ b/vimrc @@ -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 :w -imap :w - +" KEYBINDS " quick replaceement nmap S :%s//g " consistency is key - Y should act like C, D map Y y$ -" Still using arrow keys when in insert mode sometimes -map -map -map -map -inoremap -inoremap -inoremap -inoremap - " Don't cancel visual mode while indenting vnoremap > >gv vnoremap < n n:call HLNext(0.4) -nnoremap N N:call HLNext(0.4) +" ZoomWin +nmap z 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 2 :set tabstop=2 softtabstop=2 shiftwidth=2 expandtab map 4 :set tabstop=4 softtabstop=4 shiftwidth=4 expandtab map a :set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab -" buffer movement -map h :wincmd h -map j :wincmd j -map k :wincmd k -map l :wincmd l - -" auto character alignment -map t> :Tabularize /=> -map te :Tabularize /= - -" vundle -map bi :PluginInstall -map bu :PluginInstall! - -" copy and paste - for Linux -map c "+ -map p "+p -map pm :set paste! +" plugin +map bi :PlugInstall +map bu :PlugUpdate " clear search map cs :let @/ = "" -" indent and return -map i mmgg=G`m -" reload all buffers -map ra :bufdo e! -" this was better when it was :Sexplore... -map s :Vexplore ~/Source/ -map d :Vexplore . " bclose nnoremap bd :Bclose nnoremap bD :Bclose! nnoremap BD :Bclose! +" other map fw :FixWhitespace -map lf :call LargeFileToggle() +map pm :set paste! map sa :call RenameFile() map se :e ~/.vimrc -map st :call SyntaxToggle() map sz :so ~/.vimrc -map ts :sp ~/tool-sharpener.txt -" rspec -map t :w:call RunNearestSpec() - -" 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 z :ZoomToggle - -" 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() diff --git a/zsh/completion b/zsh/completion deleted file mode 100644 index f5b2924..0000000 --- a/zsh/completion +++ /dev/null @@ -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 diff --git a/zshrc b/zshrc index 2aa8f50..e8100d2 100644 --- a/zshrc +++ b/zshrc @@ -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