From 091ad65ce35c4d614cde3e5b460409948b379cbe Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Mon, 23 Feb 2015 23:34:00 -0500 Subject: [PATCH] Updates --- vim/bundle/Vundle.vim | 1 + vim/bundle/ag/README.md | 7 ++- vim/bundle/ag/autoload/ag.vim | 106 ++++++++++++++++++++++++---------- vim/bundle/ag/doc/ag.txt | 64 +++++++++++++++++++- vimrc | 31 ++++++++-- zsh/aliases | 53 +++++++++-------- zsh/func/zgitinit | 4 +- zsh/functions | 9 +-- zshrc | 7 +-- 9 files changed, 201 insertions(+), 81 deletions(-) create mode 160000 vim/bundle/Vundle.vim diff --git a/vim/bundle/Vundle.vim b/vim/bundle/Vundle.vim new file mode 160000 index 0000000..0b28e33 --- /dev/null +++ b/vim/bundle/Vundle.vim @@ -0,0 +1 @@ +Subproject commit 0b28e334e65b6628b0a61c412fcb45204a2f2bab diff --git a/vim/bundle/ag/README.md b/vim/bundle/ag/README.md index f4ee2c6..e35d7bd 100644 --- a/vim/bundle/ag/README.md +++ b/vim/bundle/ag/README.md @@ -18,7 +18,7 @@ git clone https://github.com/ggreer/the_silver_searcher ag && cd ag && ./build.s * Then, if you're using [pathogen](https://github.com/tpope/vim-pathogen): ```sh -cd ~/.vim/bundle && git clone https://github.com/rking/ag.vim ag && vim +HelpTags +cd ~/.vim/bundle && git clone https://github.com/rking/ag.vim ag && vim +Helptags ``` * Or, if you're using [Vundle](https://github.com/gmarik/vundle): @@ -27,7 +27,7 @@ cd ~/.vim/bundle && git clone https://github.com/rking/ag.vim ag && vim +HelpTag echo "Bundle 'rking/ag.vim'" >> ~/.vimrc && vim +BundleInstall ``` -### Configuation +### Configuration You can specify a custom ag name and path in your .vimrc like so: @@ -49,12 +49,13 @@ Just like where you use :grep, :grepadd, :lgrep, and :lgrepadd, you can use `:Ag Some characters have special meaning, and need to be escaped your search pattern. For instance, '#'. You have to escape it like this `:Ag '\\\#define foo'` to search for `#define foo`. (From [blueyed in issue #5](https://github.com/mileszs/ack.vim/issues/5).) -Sometimes `git grep` is even faster, though in my experience it's not noticably so. +Sometimes `git grep` is even faster, though in my experience it's not noticeably so. ### Keyboard Shortcuts ### In the quickfix window, you can use: + e to open file and close the quickfix window o to open (same as enter) go to preview file (open but maintain focus on ag.vim results) t to open in new tab diff --git a/vim/bundle/ag/autoload/ag.vim b/vim/bundle/ag/autoload/ag.vim index 686d598..86cbe95 100644 --- a/vim/bundle/ag/autoload/ag.vim +++ b/vim/bundle/ag/autoload/ag.vim @@ -6,11 +6,11 @@ if !exists("g:agprg") endif if !exists("g:ag_apply_qmappings") - let g:ag_apply_qmappings = !exists("g:ag_qhandler") + let g:ag_apply_qmappings=1 endif if !exists("g:ag_apply_lmappings") - let g:ag_apply_lmappings = !exists("g:ag_lhandler") + let g:ag_apply_lmappings=1 endif if !exists("g:ag_qhandler") @@ -21,7 +21,19 @@ if !exists("g:ag_lhandler") let g:ag_lhandler="botright lopen" endif +if !exists("g:ag_mapping_message") + let g:ag_mapping_message=1 +endif + function! ag#Ag(cmd, args) + let l:ag_executable = get(split(g:agprg, " "), 0) + + " Ensure that `ag` is installed + if !executable(l:ag_executable) + echoe "Ag command '" . l:ag_executable . "' was not found. Is the silver searcher installed and on your $PATH?" + return + endif + " If no pattern is provided, search for the word under the cursor if empty(a:args) let l:grepargs = expand("") @@ -31,28 +43,45 @@ function! ag#Ag(cmd, args) " Format, used to manage column jump if a:cmd =~# '-g$' + let s:agformat_backup=g:agformat let g:agformat="%f" - else + elseif exists("s:agformat_backup") + let g:agformat=s:agformat_backup + elseif !exists("g:agformat") let g:agformat="%f:%l:%c:%m" - end + endif - let grepprg_bak=&grepprg - let grepformat_bak=&grepformat + let l:grepprg_bak=&grepprg + let l:grepformat_bak=&grepformat + let l:t_ti_bak=&t_ti + let l:t_te_bak=&t_te try let &grepprg=g:agprg let &grepformat=g:agformat + set t_ti= + set t_te= silent execute a:cmd . " " . escape(l:grepargs, '|') finally - let &grepprg=grepprg_bak - let &grepformat=grepformat_bak + let &grepprg=l:grepprg_bak + let &grepformat=l:grepformat_bak + let &t_ti=l:t_ti_bak + let &t_te=l:t_te_bak endtry if a:cmd =~# '^l' + let l:match_count = len(getloclist(winnr())) + else + let l:match_count = len(getqflist()) + endif + + if a:cmd =~# '^l' && l:match_count exe g:ag_lhandler let l:apply_mappings = g:ag_apply_lmappings - else + let l:matches_window_prefix = 'l' " we're using the location list + elseif l:match_count exe g:ag_qhandler let l:apply_mappings = g:ag_apply_qmappings + let l:matches_window_prefix = 'c' " we're using the quickfix window endif " If highlighting is on, highlight the search keyword. @@ -63,17 +92,34 @@ function! ag#Ag(cmd, args) redraw! - if l:apply_mappings - exec "nnoremap q :ccl" - exec "nnoremap t T" - exec "nnoremap T TgT" - exec "nnoremap o " - exec "nnoremap go " - exec "nnoremap h K" - exec "nnoremap H Kb" - exec "nnoremap v HbJt" - exec "nnoremap gv HbJ" - echom "ag.vim keys: q=quit /t/h/v=enter/tab/split/vsplit go/T/H/gv=preview versions of same" + if l:match_count + if l:apply_mappings + nnoremap h K + nnoremap H Kb + nnoremap o + nnoremap t T + nnoremap T TgT + nnoremap v HbJt + + exe 'nnoremap e :' . l:matches_window_prefix .'close' + exe 'nnoremap go :' . l:matches_window_prefix . 'open' + exe 'nnoremap q :' . l:matches_window_prefix . 'close' + + exe 'nnoremap gv :let b:height=winheight(0)H:' . l:matches_window_prefix . 'openJ:exe printf(":normal %d\c-w>_", b:height)' + " Interpretation: + " :let b:height=winheight(0) Get the height of the quickfix/location list window + " Open the current item in a new split + " H Slam the newly opened window against the left edge + " :copen -or- :lopen Open either the quickfix window or the location list (whichever we were using) + " J Slam the quickfix/location list window against the bottom edge + " :exe printf(":normal %d\c-w>_", b:height) Restore the quickfix/location list window's height from before we opened the match + + if g:ag_mapping_message && l:apply_mappings + echom "ag.vim keys: q=quit /e/t/h/v=enter/edit/tab/split/vsplit go/T/H/gv=preview versions of same" + endif + endif + else + echom 'No matches for "'.a:args.'"' endif endfunction @@ -85,17 +131,17 @@ function! ag#AgFromSearch(cmd, args) endfunction function! ag#GetDocLocations() - let dp = '' - for p in split(&rtp,',') - let p = p.'/doc/' - if isdirectory(p) - let dp = p.'*.txt '.dp - endif - endfor - return dp + let dp = '' + for p in split(&runtimepath,',') + let p = p.'/doc/' + if isdirectory(p) + let dp = p.'*.txt '.dp + endif + endfor + return dp endfunction function! ag#AgHelp(cmd,args) - let args = a:args.' '.ag#GetDocLocations() - call ag#Ag(a:cmd,args) + let args = a:args.' '.ag#GetDocLocations() + call ag#Ag(a:cmd,args) endfunction diff --git a/vim/bundle/ag/doc/ag.txt b/vim/bundle/ag/doc/ag.txt index f8c30cc..37b107b 100644 --- a/vim/bundle/ag/doc/ag.txt +++ b/vim/bundle/ag/doc/ag.txt @@ -54,13 +54,73 @@ with the line number of the occurrence, once for each occurrence. on a line in this window will open the file, and place the cursor on the matching line. -See http://betterthangrep.com/ for more information. +See http://geoff.greer.fm/2011/12/27/the-silver-searcher-better-than-ack/ for +more information. + +============================================================================== +OPTIONS *ag-options* + + *g:agprg* +The location of the Ag program, and any options you want passed to it before +searching. Default: "ag --column". Example: > + let g:agprg="ag --column --smart-case" +< + + *g:aghighlight* +If 1, highlight the search terms after searching. Default: 0. Example: > + let g:aghighlight=1 +< + + *g:agformat* +Format to recognize the matches. See 'errorformat' for more info. Default: +"%f" when searching for files, "%f:%l:%c:%m" if not otherwise set. For +example, if your `g:agprg` is set to just "ag" (no column numbers in the +output, so when you jump to a match your cursor will be on the start of the +line): > + let g:agformat="%f:%l:%m" +< + + *g:ag_apply_lmappings* +Whether or not to add custom mappings to location list windows opened by this +plugin. Only applies if you're using the location list. Default 1. Example: > + let g:ag_apply_lmappings=0 +< + + *g:ag_apply_qmappings* +Whether or not to add custom mappings to quickfix windows opened by this +plugin. Only applies if you're using the error list. Default 1. Example: > + let g:ag_apply_qmappings=0 +< + + *g:ag_lhandler* +A custom command used to open the location list after it's populated. +Default: "botright lopen". You might want to set this to change where the +location list is opened, or what size it is. Example: > + let g:ag_lhandler="topleft lopen" +< + + *g:ag_qhandler* +A custom command used to open the error list after it's populated. Default: +"botright copen". You might want to set this to change where the quickfix +window is opened, or what size it is. Example: > + let g:ag_qhandler="copen 20" +< + + *g:ag_mapping_message* +Whether or not to show the message explaining the extra mappings that are +added to the results list this plugin populates. This message is not shown if +the mappings are not applied (see |g:ag_apply_qmappings| and +|g:ag_apply_lmappings| for more info. Default 1. Example: > + let g:ag_mapping_message=0 +< ============================================================================== MAPPINGS *ag-mappings* The following keyboard shortcuts are available in the quickfix window: +e open file and close the quickfix window. + o open file (same as enter). go preview file (open but maintain focus on ag.vim results). @@ -78,3 +138,5 @@ v open in vertical split. gv open in vertical split silently. q close the quickfix window. + + vim:tw=78:fo=tcq2:ft=help:norl: diff --git a/vimrc b/vimrc index 94c90f1..eb0205b 100644 --- a/vimrc +++ b/vimrc @@ -1,8 +1,21 @@ let mapleader="," +set nocompatible +filetype off + """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " PLUGINS """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" set the runtime path to include Vundle and initialize +set rtp+=~/.vim/bundle/Vundle.vim +call vundle#begin() + +" Plugins go here +Plugin 'gmarik/Vundle.vim' + +" All of your Plugins must be added before the following line +call vundle#end() + call pathogen#infect() call pathogen#helptags() @@ -23,11 +36,11 @@ endfunction " Find all files in all non-dot directories starting in the working directory. " Fuzzy select one of those. Open the selected file with :e. -nnoremap ff :call SelectaCommand("find * -type f", "", ":e") +nnoremap f :call SelectaCommand("find * -type f ! -path 'resources/public/js/*' ! -path 'resources/.sass-cache/*' ! -path 'target/*'", "", ":e") " # NERDtree -nmap d :NERDTreeToggle -nmap f :NERDTreeFind +"nmap d :NERDTreeToggle +"nmap ff :NERDTreeFind " # gist-vim let g:gist_detect_filetype = 1 @@ -35,13 +48,19 @@ let g:gist_open_browser_after_post = 1 let g:gist_show_privates = 1 let g:gist_post_private = 1 +" vim-clojure-static +let g:clojure_align_multiline_strings = 1 +" Default + let g:clojure_fuzzy_indent = 1 + let g:clojure_fuzzy_indent_patterns = ['^match', '^with', '^def', '^let'] + let g:clojure_fuzzy_indent_blacklist = ['-fn$', '\v^with-%(meta|out-str|loading-context)$'] + " # c-tags set tags+=tags;$HOME """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " BASIC EDITING CONFIGURATION """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -set nocompatible " allow unsaved background buffers and remember marks/undo for them set hidden set history=10000 @@ -133,8 +152,8 @@ map bb :!bundle install map gs :Gstatus map gw :!git add . && git commit -m 'WIP' map pn :sp ~/jelly/documents/Notes/stack.txt -map sn :sp ~/jelly/documents/software-notes/pcg-dive.md -map rn :sp ~/work/pcg/files/notes/refactoring-notes.md +map sn :sp ~/jelly/documents/software-notes/clojure.md +map rn :sp ~/work/dive-networks/files/notes/refactoring-notes.md """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " CLOJURE AND CLOJURESCRIPT diff --git a/zsh/aliases b/zsh/aliases index aa92b81..01b4b87 100644 --- a/zsh/aliases +++ b/zsh/aliases @@ -5,6 +5,7 @@ if [[ $platform == 'Linux' ]]; then alias ll='ls -lrth --color' elif [[ $platform == 'Darwin' ]]; then alias l='ls -laG' + alias ls='ls -laG' alias ll='ls -lG' fi @@ -32,17 +33,18 @@ alias bo='bundle open' alias cls=clear alias code='cd ~/code' alias cpr='cp -r' -alias d='dart' +alias cw='compass watch' +alias d='cd ~/work/dive-networks/dive' alias da='dartanalyzer' alias dc='dart --checked' alias dd='dartdoc' -alias dot='cd ~/.dotfiles' +alias dot='cd ~/.' alias dr='cd ~/Dropbox' alias duh='du -csh' alias functions='vim ~/.dotfiles/zsh/functions' alias f='fg' alias gib='gem install bundler' -alias gems='cd ~/pcg/gems' +alias gems='cd ~/dive-networks/gems' alias history='fc -l 1' alias histroy='history' alias h='heroku' @@ -51,13 +53,16 @@ alias hc='heroku config' alias hca='heroku config:add' alias hcu='heroku config:unset' alias irb='irb --readline -r irb/completion' +alias lcc='lein clean' +alias lca='lein cljsbuild auto dev' +alias ldi='lein deps install' alias li='lineman' alias lir='lineman run' alias lib='lineman build' alias lig='lineman grunt' alias lis='lineman spec' alias lic='lineman spec-ci' -alias lmi='lein modules install' +alias lsd='lein start-dev' alias mc='mvn compile' alias mct='mvn test' alias mi='mvn install' @@ -123,10 +128,12 @@ alias gdm='git diff master' alias gds='git diff --stat=160,120' alias gdw='git diff --color-words' alias gf='git fetch' +alias gfa='git fetch --all' alias gfix="git commit --amend -C HEAD" alias gfixs="git commit -S -a --amend -C HEAD" # signed alias gfo='git fetch origin' alias gfm='git fetch origin master' +alias gfup='git fetch upstream' alias gh="source ~/.githelpers && show_git_head" alias gl='gll -25' alias gli='git show --pretty="format:" --name-only' @@ -143,15 +150,18 @@ alias gp='git push' alias gpa='git push && echo "pushing tags..." && git push --tags' alias gpd='git push && git push heroku master' alias gpdf='gpf && gphf' -alias gpp='git push && git push production HEAD:production' -alias gppp='git push production' +alias gpp='echo "Pushing Upstream master to production" && git push production upstream/master:master' +alias gps='git push staging master -f' +alias gpps='echo "Pushing Upstream master to staging" && git push staging upstream/master:master -f' alias gppf='gpf && git push production HEAD:production -f' alias gph='echo "pushing $(git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3) to Heroku master" && git push heroku HEAD:master' alias gphf='git push heroku master --force' alias gpf='git push -f' alias gpu='git push -u origin master' +alias gpup='git push upstream master' alias gpff='git pull --ff-only' alias gpl='git pull' +alias gplup='git pull upstream master' alias gpo='git push origin' alias gpom='git push origin master' alias gpr='git pull --rebase' @@ -164,12 +174,17 @@ alias grbi='git rebase -i' alias grbm='git fetch origin master && git rebase master' alias grbmi='git fetch origin master && git rebase master -i' alias grbo='git fetch origin master && git rebase origin/master' +alias grbmo="echo 'use grbo instead'" +alias grbu='git fetch upstream master && git rebase upstream/master' +alias grbup='echo "use grbu"' +alias grbupm='echo "use grbu"' alias gre='git remote' alias grea='git remote add' alias greao='git remote add origin' alias gref='git reflog' alias grev='git remote -v' alias grm='git rm' +alias grmr='git rm -r' alias gsnapshot='git stash save "snapshot: $(date)" && git stash apply "stash@{0}"' alias gsh='git show' alias gst='git status' @@ -189,36 +204,20 @@ alias gxx='git reset --hard HEAD~1 && git pull --ff-only' alias gstats="echo 'Total commits: $(git rev-list HEAD --count)'; echo '\nAuthor breakdown:'; git shortlog | grep -E '^[^ ]'" # Notes -alias art='cd ~/Dropbox/notes/art' alias notes='cd ~/jelly/documents' -alias bucket='cd ~/Dropbox/notes/buckets' alias pn='vim ~/jelly/documents/Notes/stack.txt' -alias sharp='vim ~/Dropbox/notes/sharpening-notes' alias writing='cd ~/brain/writing' -alias what='cd ~/brain/writing/2014/what-happened' # Projects alias projects='cd ~/jelly/projects' -alias web='cd ~/jelly/projects/websites/michael.is' -alias weba='cd ~/jelly/projects/websites/michael.is/angular' -alias dot='cd ~/jelly/dev/projects/dotfiles' +alias dot='cd ~/jelly/projects/dotfiles' alias work='cd ~/work' alias brain='cd ~/brain' alias school='cd ~/brain/school' -alias pcg='cd ~/work/pcg' -alias dive='cd ~/work/pcg/dive-network/dive' -alias di='cd ~/work/pcg/dive-network/dive/src-cljs/dive' +alias pcg='cd ~/work/dive-networks' +alias dive='cd ~/work/dive-networks/dive/dive-web-app' +alias di='cd ~/work/dive-networks/dive/dive-web-app/src/cljs/dive' # Work -alias pcgn='vim ~/work/pcg/files/notes/personal-notes.md' -alias pcgr='vim ~/work/pcg/files/notes/refactoring-notes.md' -alias pcgf='cd ~/work/pcg/files' -alias bastion='ssh 54.86.79.26 -l pcg-user -i ~/.ssh/pcg-ec2-pcg-user' -alias sigma='cd ~/pcg/pcg-ansible && ssh -vF files/ssh/config pcg-user@sigma' -alias qonos='cd ~/pcg/pcg-ansible && ssh -vF files/ssh/config pcg-user@qonos' -alias samza1='cd ~/pcg/pcg-ansible && ssh -vF files/ssh/config pcg-user@samza1' -alias samza2='cd ~/pcg/pcg-ansible && ssh -vF files/ssh/config pcg-user@samza2' -alias samza3='cd ~/pcg/pcg-ansible && ssh -vF files/ssh/config pcg-user@samza3' -alias dstaging='ssh pcg-user@192.168.2.20 -i ~/.ssh/dive_20140923_rsa' -alias dclear='ssh pcg-user@192.168.2.90 -i ~/.ssh/dive_20140923_rsa' +source ~/work/dive-networks/aliases alias dh='git push heroku-staging master -f' diff --git a/zsh/func/zgitinit b/zsh/func/zgitinit index 8355d6f..ef48767 100755 --- a/zsh/func/zgitinit +++ b/zsh/func/zgitinit @@ -243,6 +243,8 @@ zgitinit() { } zgitinit -zgit_info_update +# Temporarily disabling as this is slowing down new term tabs, especially when opening a +# work git directory +# zgit_info_update # vim:set ft=zsh: diff --git a/zsh/functions b/zsh/functions index ded50f7..cc25482 100644 --- a/zsh/functions +++ b/zsh/functions @@ -21,7 +21,7 @@ function git-done { } function git-nuke { - git branch -D $1 && git push origin :$1 + git checkout master && git branch -D $1 && git push origin :$1 } function git-on-master { @@ -64,12 +64,6 @@ function chrome () { open -a /Applications/Google\ Chrome.app/ "$1" } -# Open a file in chrome -function chrome-kiosk () { - open -a /Applications/Google\ Chrome.app/ --args --kiosk --no-first-run --no-default-browser-check --noerrdialogs --no-message-box --disable-desktop-notifications --allow-running-insecure-content --always-authorize-plugins --allow-outdated-plugins "$1" -} - - # See top 10 bash commands function hist() { cat ~/.history|cut -d ';' -f 2- 2>/dev/null| awk '{a[$1]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head @@ -86,4 +80,3 @@ function bump_gem_version { git push origin && git push origin --tags fi } - diff --git a/zshrc b/zshrc index ab18794..d5003d9 100644 --- a/zshrc +++ b/zshrc @@ -33,7 +33,7 @@ export TERM=xterm-256color export EDITOR=vi # Grep tweaks -export GREP_OPTIONS="-nRi --color --exclude-dir=.git --exclude-dir=tmp --exclude-dir=log --exclude-dir=node_modules --exclude-dir=bower_components --exclude-dir=coverage --exclude-dir=.bundle --exclude=*.csv --exclude=*.pdf --exclude-dir=vendor --exclude-dir=rdoc --exclude-dir=personal" # --exclude-dir=images --exclude-dir=coverage +export GREP_OPTIONS="-nRi --color --exclude-dir=.git --exclude-dir=tmp --exclude-dir=log --exclude-dir=node_modules --exclude-dir=bower_components --exclude-dir=coverage --exclude-dir=.bundle --exclude=*.csv --exclude=*.pdf --exclude-dir=vendor --exclude-dir=rdoc --exclude-dir=target --exclude-dir=personal" # --exclude-dir=images --exclude-dir=coverage # Save a ton of history export HISTSIZE=20000 @@ -80,12 +80,9 @@ export RUBY_GC_MALLOC_LIMIT=1000000000 export RUBY_HEAP_FREE_MIN=500000 # Setup Ansible -ANSIBLE_DIR=/Users/pulsar/Code/open-source/python/ansible +ANSIBLE_DIR=/Users/pulsar/jelly/oss/python/ansible export PATH=${ANSIBLE_DIR}/bin:${PATH} export PYTHONPATH=${ANSIBLE_DIR}/lib:${PYTHONPATH} export ANSIBLE_LIBRARY=${ANSIBLE_DIR}/library export MANPATH=${ANSIBLE_DIR}/docs/man:${MANPATH} export ANSIBLE_HOSTS=~/.ansible_hosts - -# Setup Dart -export PATH=/Applications/Dart/dart-sdk/bin:${PATH}