├── .dockerignore ├── .editorconfig ├── .github └── workflows │ └── stale.yml ├── .gitignore ├── .gitmodules ├── .yadr ├── CHANGELOG.md ├── Dockerfile ├── LICENSE ├── README.md ├── Rakefile ├── bin ├── fasd ├── fix_macvim_external_display.sh ├── jsl ├── macos ├── marky.rb ├── rebuild_mail_index.sh └── yadr │ ├── default_libs.rb │ ├── lib │ ├── git-style-binaries-0.1.11 │ │ ├── README.markdown │ │ ├── Rakefile │ │ ├── VERSION.yml │ │ ├── lib │ │ │ ├── ext │ │ │ │ ├── colorize.rb │ │ │ │ └── core.rb │ │ │ ├── git-style-binary.rb │ │ │ └── git-style-binary │ │ │ │ ├── autorunner.rb │ │ │ │ ├── command.rb │ │ │ │ ├── commands │ │ │ │ └── help.rb │ │ │ │ ├── helpers │ │ │ │ ├── name_resolver.rb │ │ │ │ └── pager.rb │ │ │ │ └── parser.rb │ │ └── test │ │ │ ├── fixtures │ │ │ ├── flickr │ │ │ ├── flickr-download │ │ │ ├── wordpress │ │ │ ├── wordpress-categories │ │ │ ├── wordpress-list │ │ │ └── wordpress-post │ │ │ ├── git-style-binary │ │ │ └── command_test.rb │ │ │ ├── git_style_binary_test.rb │ │ │ ├── running_binaries_test.rb │ │ │ ├── shoulda_macros │ │ │ └── matching_stdio.rb │ │ │ └── test_helper.rb │ └── trollop-1.16.2 │ │ ├── FAQ.txt │ │ ├── History.txt │ │ ├── README.txt │ │ ├── lib │ │ └── trollop.rb │ │ ├── release-script.txt │ │ └── test │ │ └── test_trollop.rb │ ├── vundle.rb │ ├── yadr │ ├── yadr-init-plugins │ ├── yadr-update-plugins │ ├── yadr-vim-add-plugin │ ├── yadr-vim-delete-plugin │ └── yadr-vim-list-plugin ├── chrome ├── Custom.css └── install.sh ├── ctags └── ctags ├── doc ├── credits.md ├── macos_tools.md ├── pry.md ├── vim │ ├── coding.md │ ├── enhancements.md │ ├── keymaps.md │ ├── manage_plugins.md │ ├── navigation.md │ ├── override.md │ ├── textobjects.md │ └── utils.md └── zsh │ └── themes.md ├── docker-compose.yml ├── fonts ├── Inconsolata XL Bold.otf ├── Inconsolata XL.otf ├── Inconsolata-dz-Powerline.otf ├── Menlo-Powerline.otf └── mensch-Powerline.otf ├── git ├── gitconfig └── gitignore ├── iTerm2 ├── Solarized Dark.itermcolors └── Solarized Light.itermcolors ├── install.sh ├── irb └── pryrc ├── ruby ├── gemrc └── rdebugrc ├── tmux └── tmux.conf ├── vim ├── .gitignore ├── after │ └── plugin │ │ └── vimrc_after.vim ├── ftplugin │ └── gitcommit.vim ├── settings.vim ├── settings │ ├── NERDtree-tabs.vim │ ├── NERDtree.vim │ ├── README.md │ ├── abbr.vim │ ├── ag.vim │ ├── autotag.vim │ ├── camelcasemotion.vim │ ├── ctrlp.vim │ ├── easymotion.vim │ ├── es6.vim │ ├── fugitive.vim │ ├── gh-markdown.vim │ ├── gotofile.vim │ ├── grep.vim │ ├── gundo.vim │ ├── iterm-rspec.vim │ ├── lightline.vim │ ├── neocomplete.vim │ ├── next-textobject.vim │ ├── open-changed-files.vim │ ├── outerblock.vim │ ├── path.vim │ ├── quickfix-search.vim │ ├── rails.vim │ ├── rspec.vim │ ├── search.vim │ ├── showmarks.vim │ ├── smart_jump_to_tag.vim │ ├── sneak.vim │ ├── snipmate.vim │ ├── solarized.vim │ ├── surround.vim │ ├── syntastic.vim │ ├── tComment.vim │ ├── tidy.vim │ ├── unimpaired.vim │ ├── vim-fugitive.vim │ ├── vim-indent-guides.vim │ ├── vim-multiple-cursors.vim │ ├── vim-session.vim │ ├── vim-tmux-navigator.vim │ ├── yadr-appearance.vim │ ├── yadr-guioptions.vim │ ├── yadr-keymap-linux.vim │ ├── yadr-keymap-mac.vim │ ├── yadr-keymap.vim │ ├── yadr-sudo-write.vim │ ├── yadr-whitespace-killer.vim │ ├── yadr-window-killer.vim │ ├── yadr-wrapping.vim │ └── yankring.vim ├── vundles.vim └── vundles │ ├── appearance.vundle │ ├── git.vundle │ ├── languages.vundle │ ├── project.vundle │ ├── ruby.vundle │ ├── search.vundle │ ├── textobjects.vundle │ └── vim-improvements.vundle ├── vimify ├── editrc └── inputrc ├── vimrc └── zsh ├── 0000_before.zsh ├── 0_path.zsh ├── aliases.zsh ├── colors.zsh ├── custom_prompt_path.zsh ├── fasd.zsh ├── git.zsh ├── key-bindings.zsh ├── last-command.zsh ├── noglob.zsh ├── prezto-override ├── zpreztorc └── zshrc ├── prezto-themes ├── prompt_agnoster_setup ├── prompt_kylewest_setup ├── prompt_skwp_setup └── prompt_steeef_simplified_setup ├── rm.zsh ├── secrets.zsh ├── theme.zsh ├── vi-mode.zsh ├── zmv.zsh ├── zsh-aliases.zsh └── zzzz_after.zsh /.dockerignore: -------------------------------------------------------------------------------- 1 | docker-compose.yml 2 | Dockerfile 3 | bin/fix_macvim_external_display.sh 4 | bin/macos 5 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | end_of_line = lf 6 | insert_final_newline = true 7 | trim_trailing_whitespace = true 8 | indent_style = space 9 | indent_size = 2 10 | charset = utf-8 11 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: "Close stale issues" 2 | on: 3 | schedule: 4 | - cron: "0 0 * * *" 5 | 6 | jobs: 7 | stale: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/stale@v1 11 | with: 12 | repo-token: ${{ secrets.GITHUB_TOKEN }} 13 | stale-issue-message: 'This issue is stale because it has been open for 45 days with no activity. If no action is taken it will be closed in 10 days' 14 | days-before-stale: 45 15 | days-before-close: 10 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | custom/zsh 2 | 3 | vim/backups 4 | vim/view 5 | *un~ 6 | vim/.netrwhist 7 | vim/tmp 8 | vim/spell 9 | vim/after/.vimrc.after 10 | vim/.vundles.local 11 | vim/.vundles.local.bak 12 | vim/bundle 13 | vim/sessions 14 | .netrwhist 15 | bin/subl 16 | tags 17 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "zsh/prezto"] 2 | path = zsh/prezto 3 | url = https://github.com/sorin-ionescu/prezto.git 4 | ignore = dirty 5 | -------------------------------------------------------------------------------- /.yadr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skwp/dotfiles/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/.yadr -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2015-10-27 2 | ================== 3 | * Support for running zeus commands for rspec (`zl` and `zr`) 4 | * Ctrl-x and Ctrl-z to navigate the quickfix list 5 | 6 | 2014-06-01 7 | ================== 8 | * Change Cmd-Space to Ctrl-Space for vim autocomplete so it doesn't conflict with osx spotlight by default, and so there are no additional steps to install. 9 | 10 | 2014-02-15 11 | ================== 12 | 13 | * Replace Git Grep with Ag and remove unused plugins 14 | * Sneak: hit Space and type two letters to quickly jump somewhere 15 | * Added Ctrl-R, reverse history search for :commands 16 | * Remove ;; semicolon mapping. Messes with regular semicolon usage (find next char) 17 | * Change to Lightline instead of Airline [Fix #418] 18 | 19 | Jan 5, 2013 20 | ================== 21 | 22 | * Switch to lightline instead of airline for status bar. Works better in terminal vim and should be faster. 23 | * Added investigate.vim (gK for docs) 24 | * Fix homebrew installation of macvim with lua enabled, and fix deprecated homebrew install. 25 | 26 | Dec 17, 2013 27 | ================== 28 | 29 | * Cleanup of README to make it more palatable, focusing on the primary key bindings 30 | * Improved integration with Ag, giving ,ag and ,af aliases 31 | * Got rid of conque term, implemented a "send to iTerm" rspec runner (invoke with ,rs ,rl ,ss ,sl) for the rspec and spring/rspec versions. 32 | 33 | March 29, 2013 34 | ================== 35 | 36 | * Migrated to Vundle instead of pathogen for easier bundle management 37 | * Added Silver Searcher for lightning fast :Gsearch 38 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | LABEL maintainer="Luiz Filho " 3 | 4 | ENV TERM xterm-256color 5 | 6 | # Bootstrapping packages needed for installation 7 | RUN \ 8 | apt-get update && \ 9 | apt-get install -yqq \ 10 | locales \ 11 | lsb-release \ 12 | software-properties-common && \ 13 | apt-get clean 14 | 15 | # Set locale to UTF-8 16 | ENV LANGUAGE en_US.UTF-8 17 | ENV LANG en_US.UTF-8 18 | RUN localedef -i en_US -f UTF-8 en_US.UTF-8 && \ 19 | /usr/sbin/update-locale LANG=$LANG 20 | 21 | # Install dependencies 22 | # `universe` is needed for ruby 23 | # `security` is needed for fontconfig and fc-cache 24 | # Let the container know that there is no tty 25 | RUN DEBIAN_FRONTEND=noninteractive \ 26 | add-apt-repository ppa:aacebedo/fasd && \ 27 | apt-get update && \ 28 | apt-get -yqq install \ 29 | autoconf \ 30 | build-essential \ 31 | curl \ 32 | fasd \ 33 | fontconfig \ 34 | git \ 35 | python \ 36 | python-setuptools \ 37 | python-dev \ 38 | ruby-full \ 39 | sudo \ 40 | tmux \ 41 | vim \ 42 | wget \ 43 | zsh && \ 44 | apt-get clean && \ 45 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 46 | 47 | # Install dotfiles 48 | COPY . /root/.yadr 49 | RUN cd /root/.yadr && rake install 50 | 51 | # Run a zsh session 52 | CMD [ "/bin/zsh" ] 53 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2012, Yan Pritzker 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 17 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /bin/fix_macvim_external_display.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm ~/Library/Preferences/org.vim.MacVim.LSSharedFileList.plist && \ 3 | rm ~/Library/Preferences/org.vim.MacVim.plist && \ 4 | echo "Files deleted sucessfully. You may have to restart OSX." 5 | -------------------------------------------------------------------------------- /bin/jsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skwp/dotfiles/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/bin/jsl -------------------------------------------------------------------------------- /bin/marky.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # source http://brettterpstra.com/marky-the-markdownifier-reintroductions/ 4 | 5 | require 'open-uri' 6 | require 'net/http' 7 | require 'iconv' 8 | require 'optparse' 9 | require 'fileutils' 10 | require 'cgi' 11 | 12 | $options = {} 13 | # $fymdhost = "http://fym.dev" 14 | $fymdhost = "http://heckyesmarkdown.com" 15 | 16 | optparse = OptionParser.new do|opts| 17 | opts.banner = "Usage: #{File.basename(__FILE__)} [-o OUTPUT_PATH] -f TYPE [-t TYPE] input1 [input2, ...]" 18 | $options[:outfolder] = false 19 | opts.on( '-o DIR','--output DIR', 'Output folder, default STDOUT. Use "." for current folder, void if output type is "nv"' ) do |outfolder| 20 | filepath = File.expand_path(outfolder) 21 | unless File.exists?(filepath) && File.directory?(filepath) 22 | if File.exists?(filepath) 23 | puts "Output folder is not a directory" 24 | exit 25 | else 26 | FileUtils.mkdir_p(filepath) 27 | puts "Created #{filepath}" 28 | end 29 | end 30 | $options[:outfolder] = filepath.gsub(/\/$/,'') + "/" 31 | puts "Output folder: #{$options[:outfolder]}" 32 | end 33 | if STDIN.stat.nlink == 1 34 | if ARGV[-1] =~ /https?:/ 35 | $options[:inputtype] = 'url' 36 | else 37 | $options[:inputtype] = case File.extname(File.expand_path(ARGV[-1])) 38 | when '.html' then 'htmlfile' 39 | when '.htm' then 'htmlfile' 40 | when '.txt' then 'htmlfile' 41 | when '.webarchive' then 'webarchive' 42 | when '.webloc' then 'bookmark' 43 | when '.webbookmark' then 'bookmark' 44 | else 'url' 45 | end 46 | end 47 | else 48 | $options[:inputtype] = 'html' 49 | end 50 | opts.on( '-f TYPE','--from TYPE', 'Input type (html, htmlfile, url [default], bookmark, webarchive, webarchiveurl)') do |input_type| 51 | $options[:inputtype] = input_type 52 | end 53 | $options[:outputtype] = 'md' 54 | opts.on( '-t TYPE', '--to TYPE', 'Output type (md [default], nv)') do |output_type| 55 | $options[:outputtype] = output_type 56 | end 57 | opts.on( '-h', '--help', 'Display this screen' ) do 58 | puts opts 59 | exit 60 | end 61 | end 62 | 63 | optparse.parse! 64 | $input = STDIN.stat.nlink == 0 ? STDIN.read : ARGV 65 | 66 | # Convert html input to readable Markdown 67 | def html_to_markdown(input,filename = false) 68 | input = input.class == Array ? input.join : input 69 | res = Net::HTTP.post_form(URI.parse("#{$fymdhost}/go/"),{'html'=>input,'read'=>'1'}) 70 | if res.code.to_i == 200 71 | if $options[:outfolder] 72 | outfile = $options[:outfolder] 73 | if filename 74 | outfile += File.basename(filename,'.html')+'.md' 75 | else 76 | outfile += res.body.split("\n")[2].gsub(/^#\s*/,'').strip.gsub(/[!?*$^()]+/,'') + '.md' 77 | end 78 | File.open(outfile,'w') {|f| 79 | f.puts res.body 80 | } 81 | puts "Markdown written to #{outfile}" 82 | else 83 | puts res.body 84 | end 85 | else 86 | puts "Error converting HTML" 87 | end 88 | end 89 | 90 | def html_file_to_markdown(outtype) 91 | $input.each {|file| 92 | input = File.expand_path(file) 93 | if File.exists?(input) 94 | html = File.open(input,'r') {|infile| 95 | CGI.escape(CGI.unescapeHTML(infile.read)) 96 | } 97 | if outtype == 'md' 98 | html_to_markdown(html,input) 99 | else 100 | html_to_nv(html) 101 | end 102 | else 103 | puts "File does not exist: #{input}" 104 | end 105 | } 106 | end 107 | 108 | def url_to_markdown 109 | $input.each {|input| 110 | res = Net::HTTP.post_form(URI.parse("#{$fymdhost}/go/"),{'u'=>input,'read'=>'1'}) 111 | if res.code.to_i == 200 112 | if $options[:outfolder] 113 | outfile = $options[:outfolder] 114 | outfile += input.gsub(/^https?:\/\//,'').strip.gsub(/\//,'_').gsub(/[!?*$^()]+/,'') + '.md' 115 | File.open(outfile,'w') {|f| 116 | f.puts res.body 117 | } 118 | puts "Markdown written to #{outfile}" 119 | else 120 | puts res.body 121 | end 122 | else 123 | puts "Error opening URL: #{input}" 124 | end 125 | } 126 | end 127 | 128 | # Convert html input to Markdown and add to nvALT 129 | def html_to_nv(input) 130 | input = input.class == Array ? input.join : input 131 | res = Net::HTTP.post_form(URI.parse("#{$fymdhost}/go/"),{'html'=>input,'read'=>'1','output' => 'nv'}) 132 | if res.code.to_i == 200 133 | %x{osascript -e 'tell app "nvALT" to activate'} 134 | %x{open "#{res.body}"} 135 | else 136 | puts "Error converting HTML" 137 | end 138 | end 139 | 140 | # Capture URL as Markdown note in nvALT 141 | def url_to_nv 142 | $input.each {|input| 143 | res = Net::HTTP.post_form(URI.parse("#{$fymdhost}/go/"),{'u'=>input,'read'=>'1','output' => 'nv'}) 144 | if res.code.to_i == 200 145 | %x{osascript -e 'tell app "nvALT" to activate'} 146 | %x{open "#{res.body}"} 147 | else 148 | puts "Error opening URL: #{input}" 149 | end 150 | } 151 | end 152 | 153 | # Convert url of web archive to Markdown 154 | def webarchive_url_to_markdown(outtype) 155 | $input.each {|f| 156 | file = File.expand_path(f) 157 | source_url = %x{mdls -name 'kMDItemWhereFroms' -raw #{file}}.split("\n")[1].strip.gsub(/(^"|"$)/,'') 158 | res = Net::HTTP.post_form(URI.parse("#{$fymdhost}/go/"),{'u'=>source_url,'read'=>'1','output' => outtype}) 159 | if res.code.to_i == 200 160 | if outtype == 'nv' 161 | %x{osascript -e 'tell app "nvALT" to activate'} 162 | %x{open "#{res.body}"} 163 | elsif ($options[:outfolder]) 164 | outfile = $options[:outfolder] 165 | outfile += %x{textutil -info #{file} | grep "Title:"}.gsub(/^\s*Title:\s*/,'').strip.gsub(/[!?*$^()]+/,'') + '.md' 166 | File.open(outfile,'w') {|f| 167 | f.puts res.body 168 | } 169 | puts "Webarchive origin converted and saved to #{outfile}" 170 | else 171 | puts res.body 172 | end 173 | else 174 | puts "Error opening URL: #{source_url}" 175 | end 176 | } 177 | end 178 | 179 | # Convert webarchive contents to Markdown 180 | def webarchive_to_markdown(outtype) 181 | $input.each {|f| 182 | file = File.expand_path(f) 183 | html = %x{textutil -convert html -noload -nostore -stdout #{file} 2> /dev/null} 184 | res = Net::HTTP.post_form(URI.parse("#{$fymdhost}/go/"),{'html'=>html,'read'=>'1','output' => outtype}) 185 | if res.code.to_i == 200 186 | if outtype == 'nv' 187 | %x{osascript -e 'tell app "nvALT" to activate'} 188 | %x{open "#{res.body}"} 189 | elsif ($options[:outfolder]) 190 | outfile = $options[:outfolder] 191 | outfile += %x{textutil -info #{file} | grep "Title:"}.gsub(/^\s*Title:\s*/,'').strip.gsub(/[!?*$^()]+/,'') + '.md' 192 | File.open(outfile,'w') {|out| 193 | out.puts res.body 194 | } 195 | puts "Webarchive converted and saved to #{outfile}" 196 | else 197 | puts res.body 198 | end 199 | else 200 | puts "Error converting HTML" 201 | end 202 | } 203 | end 204 | 205 | # Save the contents of a webbookmark or webloc url as Markdown 206 | def bookmark_to_markdown(outtype) 207 | $input.each {|f| 208 | file = File.expand_path(f) 209 | if File.exists?(file) 210 | outfile = $options[:outfolder] ? $options[:outfolder] : "" 211 | outfile += %x{mdls -name 'kMDItemDisplayName' -raw "#{file}"}.strip.gsub(/(\.webbookmark|\.webloc)$/,'') + '.md' 212 | source_url = %x{mdls -name 'kMDItemURL' -raw "#{file}"}.strip 213 | if source_url.nil? || source_url == "(null)" 214 | source_url = File.open(file,'r') do |infile| 215 | ic = Iconv.new('UTF-8//IGNORE', 'UTF-8') 216 | urlstring = ic.iconv(infile.read + ' ')[0..-2].match(/\URL\<\/key\>\n\s*\(.*?)\<\/string\>/) 217 | urlstring.nil? ? nil : urlstring[1] 218 | end 219 | end 220 | if source_url.nil? 221 | puts "Could not locate URL for bookmark" 222 | else 223 | res = Net::HTTP.post_form(URI.parse("#{$fymdhost}/go/"),{'u'=>source_url,'read'=>'1','output' => outtype}) 224 | if res.code.to_i == 200 225 | if outtype == 'nv' 226 | %x{osascript -e 'tell app "nvALT" to activate'} 227 | %x{open "#{res.body}"} 228 | elsif ($options[:outfolder]) 229 | File.open(outfile,'w') {|f| 230 | f.puts res.body 231 | } 232 | puts "Bookmark converted and saved to #{outfile}" 233 | else 234 | puts res.body 235 | end 236 | else 237 | puts "Error opening URL: #{source_url}" 238 | end 239 | end 240 | end 241 | } 242 | end 243 | 244 | def bad_combo 245 | puts "Bad input/output combination" 246 | exit 247 | end 248 | 249 | if ($options[:inputtype] == 'url' || $options[:inputtype] == 'bookmark') && $input.class != Array 250 | p $input 251 | puts "Wrong argument format. This input type should be a space-separated list of urls or bookmark files." 252 | exit 253 | end 254 | 255 | if $options[:inputtype] == 'url' 256 | if $options[:outputtype] == 'md' 257 | url_to_markdown 258 | elsif $options[:outputtype] == 'nv' 259 | url_to_nv 260 | else 261 | bad_combo 262 | end 263 | elsif $options[:inputtype] == 'html' 264 | if $options[:outputtype] == 'md' 265 | html_to_markdown($input) 266 | elsif $options[:outputtype] == 'nv' 267 | html_to_nv($input) 268 | else 269 | bad_combo 270 | end 271 | elsif $options[:inputtype] == 'htmlfile' 272 | if $options[:outputtype] == 'md' 273 | html_file_to_markdown('md') 274 | elsif $options[:outputtype] == 'nv' 275 | html_file_to_markdown('nv') 276 | else 277 | bad_combo 278 | end 279 | elsif $options[:inputtype] == 'bookmark' 280 | if $options[:outputtype] == 'md' 281 | bookmark_to_markdown('md') 282 | elsif $options[:outputtype] == 'nv' 283 | bookmark_to_nv('nv') 284 | else 285 | bad_combo 286 | end 287 | elsif $options[:inputtype] == 'webarchiveurl' 288 | if $options[:outputtype] == 'md' 289 | webarchive_url_to_markdown('md') 290 | elsif $options[:outputtype] == 'nv' 291 | webarchive_url_to_nv('nv') 292 | else 293 | bad_combo 294 | end 295 | elsif $options[:inputtype] == 'webarchive' 296 | if $options[:outputtype] == 'md' 297 | webarchive_to_markdown('md') 298 | elsif $options[:outputtype] == 'nv' 299 | webarchive_to_nv('nv') 300 | else 301 | bad_combo 302 | end 303 | else 304 | bad_combo 305 | end 306 | -------------------------------------------------------------------------------- /bin/rebuild_mail_index.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mail_data_dir="/Users/$USER/Library/Mail/V2/MailData" 4 | killall -HUP Mail 5 | BEFORE=`ls -lah $mail_data_dir | grep -E 'Envelope Index$' | awk '{ print $5 }'` 6 | /usr/bin/sqlite3 $mail_data_dir/Envelope\ Index 'PRAGMA integrity_check'; 7 | /usr/bin/sqlite3 $mail_data_dir/Envelope\ Index vacuum; 8 | AFTER=`ls -lah $mail_data_dir | grep -E 'Envelope Index$' | awk '{ print $5}'` 9 | echo "before: $BEFORE" 10 | echo "after: $AFTER" 11 | open -a "Mail.app" 12 | 13 | /usr/bin/osascript -e 'tell application "Mail" to display dialog "Envelope Index before: " & "'$BEFORE'" & return & "Envelope Index after: " & "'$AFTER'"' 14 | -------------------------------------------------------------------------------- /bin/yadr/default_libs.rb: -------------------------------------------------------------------------------- 1 | Dir[File.join(File.dirname(__FILE__),"lib/**/lib")].each {|dir| $LOAD_PATH << dir} 2 | require 'git-style-binary/command' 3 | 4 | $yadr = File.join(ENV['HOME'], ".yadr") 5 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/README.markdown: -------------------------------------------------------------------------------- 1 | git-style-binaries 2 | ================== 3 | 4 | Ridiculously easy git-style binaries. 5 | 6 | This gem uses [`trollop`](http://trollop.rubyforge.org/) for option parsing 7 | 8 | ## Installation 9 | 10 | gem install jashmenn-git-style-binaries --source=http://gems.github.com 11 | 12 | ## Screencast 13 | 14 | Checkout the new screencast! 15 | 16 | 17 | 18 | ## Try it out 19 | 20 | cd `gem env gemdir`/gems/jashmenn-git-style-binaries-0.1.4/test/fixtures 21 | ./wordpress -h 22 | ./wordpress help post 23 | 24 | ## Goal 25 | 26 | Lets use the imaginary `wordpress` gem. Let's say we have three different 27 | actions we want to specify: 28 | 29 | * categories 30 | * list 31 | * post 32 | 33 | Each command has its own binary in a directory structure like this: 34 | 35 | bin/ 36 | |-- wordpress 37 | |-- wordpress-categories 38 | |-- wordpress-list 39 | `-- wordpress-post 40 | 41 | The goal is to be able to call commands in this manner: 42 | 43 | wordpress -h # gives help summary of all commands 44 | wordpress-list -h # gives long help of wordpress-list 45 | wordpress list -h # ditto 46 | echo "about me" | wordpress-post --title="new post" # posts a new post with that title 47 | 48 | ## Example code 49 | Our `bin/wordpress` binary is called the *primary* . Our primary only needs to contain the following line: 50 | 51 | #!/usr/bin/env ruby 52 | require 'git-style-binary/command' 53 | 54 | `git-style-binary` will automatically make this command the primary. 55 | 56 | The `bin/wordpress-post` binary could contain the following: 57 | 58 | #!/usr/bin/env ruby 59 | require 'git-style-binary/command' 60 | 61 | GitStyleBinary.command do 62 | short_desc "create a blog post" 63 | banner <<-EOS 64 | Usage: #{command.full_name} #{all_options_string} {content|STDIN} 65 | 66 | Posts content to a wordpress blog 67 | 68 | EOS 69 | opt :blog, "short name of the blog to use", :default => 'default' 70 | opt :category, "tag/category. specify multiple times for multiple categories", :type => String, :multi => true 71 | opt :title, "title for the post", :required => true, :type => String 72 | opt :type, "type of the content [html|xhtml|text]", :default => 'html', :type => String 73 | 74 | run do |command| 75 | command.die :type, "type must be one of [html|xhtml|text]" unless command.opts[:type] =~ /^(x?html|text)$/i 76 | 77 | puts "Subcommand name: #{command.name.inspect}" 78 | puts "Options: #{command.opts.inspect}" 79 | puts "Remaining arguments: #{command.argv.inspect}" 80 | end 81 | end 82 | 83 | And so on with the other binaries. 84 | 85 | ## Running the binaries 86 | 87 | Now if we run `wordpress -h` we get the following output: 88 | 89 | NAME 90 | wordpress 91 | 92 | VERSION 93 | 0.0.1 (c) 2009 Nate Murray - local 94 | 95 | SYNOPSIS 96 | wordpress [--version] [--test-primary] [--help] [--verbose] COMMAND [ARGS] 97 | 98 | SUBCOMMANDS 99 | wordpress-categories 100 | do something with categories 101 | 102 | wordpress-help 103 | get help for a specific command 104 | 105 | wordpress-list 106 | list blog postings 107 | 108 | wordpress-post 109 | create a blog post 110 | 111 | 112 | See 'wordpress help COMMAND' for more information on a specific command. 113 | 114 | OPTIONS 115 | -v, --verbose 116 | verbose 117 | 118 | 119 | -t, --test-primary= 120 | test an option on the primary 121 | 122 | 123 | -e, --version 124 | Print version and exit 125 | 126 | 127 | -h, --help 128 | Show this message 129 | 130 | 131 | 132 | Default **options**, **version string**, and **usage banner** are automatically selected for you. 133 | The subcommands and their short descriptions are loaded automatically! 134 | 135 | You can pass the `-h` flag to any one of the subcommands (with or without the 136 | connecting `-`) or use the built-in `help` subcommand for the same effect. For instance: 137 | 138 | $ wordpress help post 139 | 140 | NAME 141 | wordpress-post - create a blog post 142 | 143 | VERSION 144 | 0.0.1 (c) 2009 Nate Murray - local 145 | 146 | SYNOPSIS 147 | wordpress-post [--type] [--version] [--test-primary] [--blog] [--help] [--verbose] [--category] 148 | [--title] COMMAND [ARGS] {content|STDIN} 149 | 150 | OPTIONS 151 | -v, --verbose 152 | verbose 153 | 154 | 155 | -t, --test-primary= 156 | test an option on the primary 157 | 158 | 159 | -b, --blog= 160 | short name of the blog to use (default: default) 161 | 162 | 163 | -c, --category= 164 | tag/category. specify multiple times for multiple 165 | categories 166 | 167 | 168 | -i, --title= 169 | title for the post 170 | 171 | 172 | -y, --type= 173 | type of the content [html|xhtml|text] (default: html) 174 | 175 | 176 | -e, --version 177 | Print version and exit 178 | 179 | 180 | -h, --help 181 | Show this message 182 | 183 | 184 | For more examples, see the binaries in `test/fixtures/`. 185 | 186 | ## Primary options 187 | 188 | Often you may *want* the primary to have its own set of options. Simply call `GitStyleBinary.primary` with a block like so: 189 | 190 | #!/usr/bin/env ruby 191 | require 'git-style-binary/command' 192 | GitStyleBinary.primary do 193 | version "#{command.full_name} 0.0.1 (c) 2009 Nate Murray - local" 194 | opt :test_primary, "a primary string option", :type => String 195 | 196 | run do |command| 197 | puts "Primary Options: #{command.opts.inspect}" 198 | end 199 | end 200 | 201 | Primary options are **inherited** by all subcommands. That means in this case 202 | all subcommands will now get the `--test-primary` option available to them as 203 | well as this new `version` string. 204 | 205 | ## Option parsing 206 | 207 | Option parsing is done by [trollop](http://trollop.rubyforge.org/). 208 | `git-style-binary` uses this more-or-less exactly. See the [trollop 209 | documentation](http://trollop.rubyforge.org/) for information on how to setup 210 | the options and flags. 211 | 212 | ## Callbacks 213 | 214 | Callbacks are available on the primary and subcommands. Available callbacks currently 215 | are before/after_run. These execute before the run block of the command parser and take 216 | take one argument, which is the command itself 217 | 218 | ## The `run` block 219 | 220 | To get the 'introspection' on the individual binaries every binary is `load`ed 221 | on `primary help`. We need a way to get that information while not running 222 | every command when calling `primary help`. To achieve that you need to put what 223 | will be run in the `run` block. 224 | 225 | `run` `yields` a `Command` object which contains a number of useful options 226 | such as `name`, `full_name`, `opts`, and `argv`. 227 | 228 | * `command.opts` is a hash of the options parsed 229 | * `command.argv` is an array of the remaining arguments 230 | 231 | ## Features 232 | * automatic colorization 233 | * automatic paging 234 | 235 | ## To Learn more 236 | 237 | Play with the examples in the `test/fixtures` directory. 238 | 239 | ## Credits 240 | * `git-style-binary` was written by Nate Murray `` 241 | * `trollop` was written by [William Morgan](http://trollop.rubyforge.org/) 242 | * Inspiration comes from Ari Lerner's [git-style-binaries](http://blog.xnot.org/2008/12/16/git-style-binaries/) for [PoolParty.rb](http://poolpartyrb.com) 243 | * [`colorize.rb`](http://colorize.rubyforge.org) by Michal Kalbarczyk 244 | * Automatic less paging by [Nathan Weizenbaum](http://nex-3.com/posts/73-git-style-automatic-paging-in-ruby) 245 | * Color inspiration from [Brian Henderson](http://xcombinator.com) teaching me how to get `man git` colors using `less` on MacOSX 246 | 247 | ## TODO 248 | * automagic tab completion - Automatic for subcommands and options for any library that uses this 249 | 250 | ## Known Bugs/Problems 251 | * Young 252 | * A few places of really ugly code 253 | * A feeling that this could be done in 1/2 lines of code 254 | 255 | ## Authors 256 | By Nate Murray and Ari Lerner 257 | 258 | ## Copyright 259 | 260 | The MIT License 261 | 262 | Copyright (c) 2009 Nate Murray. See LICENSE for details. 263 | 264 | Permission is hereby granted, free of charge, to any person obtaining a copy 265 | of this software and associated documentation files (the "Software"), to deal 266 | in the Software without restriction, including without limitation the rights 267 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 268 | copies of the Software, and to permit persons to whom the Software is 269 | furnished to do so, subject to the following conditions: 270 | 271 | The above copyright notice and this permission notice shall be included in 272 | all copies or substantial portions of the Software. 273 | 274 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 275 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 276 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 277 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 278 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 279 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 280 | THE SOFTWARE. 281 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'rake' 3 | 4 | begin 5 | require 'jeweler' 6 | Jeweler::Tasks.new do |gem| 7 | gem.name = "git-style-binaries" 8 | gem.description = %Q{Ridiculously easy git-style binaries} 9 | gem.summary =<<-EOF 10 | Add git-style binaries to your project easily. 11 | EOF 12 | gem.email = "nate@natemurray.com" 13 | gem.homepage = "http://github.com/jashmenn/git-style-binaries" 14 | gem.authors = ["Nate Murray"] 15 | gem.add_dependency 'trollop' 16 | gem.add_dependency 'shoulda' # for running the tests 17 | 18 | excludes = /(README\.html)/ 19 | gem.files = (FileList["[A-Z]*.*", "{bin,examples,generators,lib,rails,spec,test,vendor}/**/*", 'Rakefile', 'LICENSE*']).delete_if{|f| f =~ excludes} 20 | gem.extra_rdoc_files = FileList["README*", "ChangeLog*", "LICENSE*"].delete_if{|f| f =~ excludes} 21 | end 22 | rescue LoadError 23 | puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" 24 | end 25 | 26 | require 'rake/testtask' 27 | Rake::TestTask.new(:test) do |test| 28 | test.libs << 'lib' << 'test' 29 | test.pattern = 'test/**/*_test.rb' 30 | test.verbose = true 31 | end 32 | 33 | begin 34 | require 'rcov/rcovtask' 35 | Rcov::RcovTask.new do |test| 36 | test.libs << 'test' 37 | test.pattern = 'test/**/*_test.rb' 38 | test.verbose = true 39 | end 40 | rescue LoadError 41 | task :rcov do 42 | abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov" 43 | end 44 | end 45 | 46 | 47 | task :default => :test 48 | 49 | require 'rake/rdoctask' 50 | require 'yaml' 51 | Rake::RDocTask.new do |rdoc| 52 | if File.exist?('VERSION.yml') 53 | config = YAML.load(File.read('VERSION.yml')) 54 | version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}" 55 | else 56 | version = "" 57 | end 58 | 59 | rdoc.rdoc_dir = 'rdoc' 60 | rdoc.title = "git-style-binaries #{version}" 61 | rdoc.rdoc_files.include('README*') 62 | rdoc.rdoc_files.include('lib/**/*.rb') 63 | end 64 | 65 | task :bump => ['version:bump:patch', 'gemspec', 'build'] 66 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/VERSION.yml: -------------------------------------------------------------------------------- 1 | --- 2 | :patch: 10 3 | :major: 0 4 | :minor: 1 5 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/lib/ext/colorize.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Colorize String class extension. 3 | # 4 | class String 5 | 6 | # 7 | # Version string 8 | # 9 | COLORIZE_VERSION = '0.5.6' 10 | 11 | # 12 | # Colors Hash 13 | # 14 | COLORS = { 15 | :black => 0, 16 | :red => 1, 17 | :green => 2, 18 | :yellow => 3, 19 | :blue => 4, 20 | :magenta => 5, 21 | :cyan => 6, 22 | :white => 7, 23 | :default => 9, 24 | 25 | :light_black => 10, 26 | :light_red => 11, 27 | :light_green => 12, 28 | :light_yellow => 13, 29 | :light_blue => 14, 30 | :light_magenta => 15, 31 | :light_cyan => 16, 32 | :light_white => 17 33 | } 34 | 35 | # 36 | # Modes Hash 37 | # 38 | MODES = { 39 | :default => 0, # Turn off all attributes 40 | #:bright => 1, # Set bright mode 41 | :underline => 4, # Set underline mode 42 | :blink => 5, # Set blink mode 43 | :swap => 7, # Exchange foreground and background colors 44 | :hide => 8 # Hide text (foreground color would be the same as background) 45 | } 46 | 47 | protected 48 | 49 | # 50 | # Set color values in new string intance 51 | # 52 | def set_color_parameters( params ) 53 | if (params.instance_of?(Hash)) 54 | @color = params[:color] 55 | @background = params[:background] 56 | @mode = params[:mode] 57 | @uncolorized = params[:uncolorized] 58 | self 59 | else 60 | nil 61 | end 62 | end 63 | 64 | public 65 | 66 | # 67 | # Change color of string 68 | # 69 | # Examples: 70 | # 71 | # puts "This is blue".colorize( :blue ) 72 | # puts "This is light blue".colorize( :light_blue ) 73 | # puts "This is also blue".colorize( :color => :blue ) 74 | # puts "This is blue with red background".colorize( :color => :light_blue, :background => :red ) 75 | # puts "This is blue with red background".colorize( :light_blue ).colorize( :background => :red ) 76 | # puts "This is blue text on red".blue.on_red 77 | # puts "This is red on blue".colorize( :red ).on_blue 78 | # puts "This is red on blue and underline".colorize( :red ).on_blue.underline 79 | # puts "This is blue text on red".blue.on_red.blink 80 | # 81 | def colorize( params ) 82 | 83 | unless STDOUT.use_color 84 | return self unless STDOUT.isatty 85 | end 86 | return self if ENV['NO_COLOR'] 87 | 88 | begin 89 | require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32/ 90 | rescue LoadError 91 | raise 'You must gem install win32console to use color on Windows' 92 | end 93 | 94 | color_parameters = {} 95 | 96 | if (params.instance_of?(Hash)) 97 | color_parameters[:color] = COLORS[params[:color]] 98 | color_parameters[:background] = COLORS[params[:background]] 99 | color_parameters[:mode] = MODES[params[:mode]] 100 | elsif (params.instance_of?(Symbol)) 101 | color_parameters[:color] = COLORS[params] 102 | end 103 | 104 | color_parameters[:color] ||= @color || 9 105 | color_parameters[:background] ||= @background || 9 106 | color_parameters[:mode] ||= @mode || 0 107 | 108 | color_parameters[:uncolorized] ||= @uncolorized || self.dup 109 | 110 | # calculate bright mode 111 | color_parameters[:color] += 50 if color_parameters[:color] > 10 112 | 113 | color_parameters[:background] += 50 if color_parameters[:background] > 10 114 | 115 | return "\033[#{color_parameters[:mode]};#{color_parameters[:color]+30};#{color_parameters[:background]+40}m#{color_parameters[:uncolorized]}\033[0m".set_color_parameters( color_parameters ) 116 | end 117 | 118 | 119 | # 120 | # Return uncolorized string 121 | # 122 | def uncolorize 123 | return @uncolorized || self 124 | end 125 | 126 | # 127 | # Return true if sting is colorized 128 | # 129 | def colorized? 130 | return !@uncolorized.nil? 131 | end 132 | 133 | # 134 | # Make some color and on_color methods 135 | # 136 | COLORS.each_key do | key | 137 | eval <<-"end_eval" 138 | def #{key.to_s} 139 | return self.colorize( :color => :#{key.to_s} ) 140 | end 141 | def on_#{key.to_s} 142 | return self.colorize( :background => :#{key.to_s} ) 143 | end 144 | end_eval 145 | end 146 | 147 | # 148 | # Methods for modes 149 | # 150 | MODES.each_key do | key | 151 | eval <<-"end_eval" 152 | def #{key.to_s} 153 | return self.colorize( :mode => :#{key.to_s} ) 154 | end 155 | end_eval 156 | end 157 | 158 | class << self 159 | 160 | # 161 | # Return array of available modes used by colorize method 162 | # 163 | def modes 164 | keys = [] 165 | MODES.each_key do | key | 166 | keys << key 167 | end 168 | keys 169 | end 170 | 171 | # 172 | # Return array of available colors used by colorize method 173 | # 174 | def colors 175 | keys = [] 176 | COLORS.each_key do | key | 177 | keys << key 178 | end 179 | keys 180 | end 181 | 182 | # 183 | # Display color matrix with color names. 184 | # 185 | def color_matrix( txt = "[X]" ) 186 | size = String.colors.length 187 | String.colors.each do | color | 188 | String.colors.each do | back | 189 | print txt.colorize( :color => color, :background => back ) 190 | end 191 | puts " < #{color}" 192 | end 193 | String.colors.reverse.each_with_index do | back, index | 194 | puts "#{"|".rjust(txt.length)*(size-index)} < #{back}" 195 | end 196 | end 197 | end 198 | end 199 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/lib/ext/core.rb: -------------------------------------------------------------------------------- 1 | class Object 2 | def returning(value) 3 | yield(value) 4 | value 5 | end unless Object.respond_to?(:returning) 6 | end 7 | 8 | class Symbol 9 | def to_proc 10 | Proc.new { |*args| args.shift.__send__(self, *args) } 11 | end 12 | end 13 | 14 | class IO 15 | attr_accessor :use_color 16 | end 17 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary.rb: -------------------------------------------------------------------------------- 1 | $:.unshift(File.dirname(__FILE__)) 2 | require 'rubygems' 3 | 4 | # Load the vendor gems 5 | $:.unshift(File.dirname(__FILE__) + "/../vendor/gems") 6 | %w(trollop).each do |library| 7 | begin 8 | require "#{library}/lib/#{library}" 9 | rescue LoadError 10 | begin 11 | require 'trollop' 12 | rescue LoadError 13 | puts "There was an error loading #{library}. Try running 'gem install #{library}' to correct the problem" 14 | end 15 | end 16 | end 17 | 18 | require 'ext/core' 19 | require 'ext/colorize' 20 | require 'git-style-binary/autorunner' 21 | Dir[File.dirname(__FILE__) + "/git-style-binary/helpers/*.rb"].each {|f| require f} 22 | 23 | module GitStyleBinary 24 | 25 | class << self 26 | include Helpers::NameResolver 27 | attr_accessor :current_command 28 | attr_accessor :primary_command 29 | attr_writer :known_commands 30 | 31 | # If set to false GitStyleBinary will not automatically run at exit. 32 | attr_writer :run 33 | 34 | # Automatically run at exit? 35 | def run? 36 | @run ||= false 37 | end 38 | 39 | def parser 40 | @p ||= Parser.new 41 | end 42 | 43 | def known_commands 44 | @known_commands ||= {} 45 | end 46 | 47 | def load_primary 48 | unless @loaded_primary 49 | @loaded_primary = true 50 | primary_file = File.join(binary_directory, basename) 51 | load primary_file 52 | 53 | if !GitStyleBinary.primary_command # you still dont have a primary load a default 54 | GitStyleBinary.primary do 55 | run do |command| 56 | educate 57 | end 58 | end 59 | end 60 | end 61 | end 62 | 63 | def load_subcommand 64 | unless @loaded_subcommand 65 | @loaded_subcommand = true 66 | cmd_file = GitStyleBinary.binary_filename_for(GitStyleBinary.current_command_name) 67 | load cmd_file 68 | end 69 | end 70 | 71 | def load_command_file(name, file) 72 | self.name_of_command_being_loaded = name 73 | load file 74 | self.name_of_command_being_loaded = nil 75 | end 76 | 77 | # UGLY eek 78 | attr_accessor :name_of_command_being_loaded 79 | 80 | end 81 | end 82 | 83 | at_exit do 84 | unless $! || GitStyleBinary.run? 85 | command = GitStyleBinary::AutoRunner.run 86 | exit 0 87 | end 88 | end 89 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/autorunner.rb: -------------------------------------------------------------------------------- 1 | require 'git-style-binary/parser' 2 | 3 | module GitStyleBinary 4 | class AutoRunner 5 | 6 | def self.run(argv=ARGV) 7 | r = new 8 | r.run 9 | end 10 | 11 | def run 12 | unless GitStyleBinary.run? 13 | if !GitStyleBinary.current_command 14 | GitStyleBinary.load_primary 15 | end 16 | GitStyleBinary.current_command.run 17 | end 18 | end 19 | 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/command.rb: -------------------------------------------------------------------------------- 1 | require 'git-style-binary' 2 | 3 | module GitStyleBinary 4 | def self.command(&block) 5 | returning Command.new(:constraints => [block]) do |c| 6 | c.name ||= (GitStyleBinary.name_of_command_being_loaded || GitStyleBinary.current_command_name) 7 | GitStyleBinary.known_commands[c.name] = c 8 | 9 | if !GitStyleBinary.current_command || GitStyleBinary.current_command.is_primary? 10 | GitStyleBinary.current_command = c 11 | end 12 | end 13 | end 14 | 15 | def self.primary(&block) 16 | returning Primary.new(:constraints => [block]) do |c| 17 | c.name ||= (GitStyleBinary.name_of_command_being_loaded || GitStyleBinary.current_command_name) 18 | GitStyleBinary.known_commands[c.name] = c 19 | 20 | GitStyleBinary.primary_command = c unless GitStyleBinary.primary_command 21 | GitStyleBinary.current_command = c unless GitStyleBinary.current_command 22 | end 23 | end 24 | 25 | class Command 26 | class << self 27 | def defaults 28 | lambda do 29 | name_desc "#{command.full_name}\#{command.short_desc ? ' - ' + command.short_desc : ''}" # eval jit 30 | version_string = defined?(VERSION) ? VERSION : "0.0.1" 31 | version "#{version_string} (c) #{Time.now.year}" 32 | banner <<-EOS 33 | #{"SYNOPSIS".colorize(:red)} 34 | #{command.full_name.colorize(:light_blue)} #{all_options_string} 35 | 36 | #{"SUBCOMMANDS".colorize(:red)} 37 | \#{GitStyleBinary.pretty_known_subcommands.join("\n ")} 38 | 39 | See '#{command.full_name} help COMMAND' for more information on a specific command. 40 | EOS 41 | 42 | opt :verbose, "verbose", :default => false 43 | end 44 | end 45 | end 46 | 47 | attr_reader :constraints 48 | attr_reader :opts 49 | attr_accessor :name 50 | 51 | def initialize(o={}) 52 | o.each do |k,v| 53 | eval "@#{k.to_s}= v" 54 | end 55 | end 56 | 57 | def parser 58 | @parser ||= begin 59 | p = Parser.new 60 | p.command = self 61 | p 62 | end 63 | end 64 | 65 | def constraints 66 | @constraints ||= [] 67 | end 68 | 69 | def run 70 | GitStyleBinary.load_primary unless is_primary? 71 | GitStyleBinary.load_subcommand if is_primary? && running_subcommand? 72 | load_all_parser_constraints 73 | @opts = process_args_with_subcmd 74 | call_parser_run_block 75 | self 76 | end 77 | 78 | def running_subcommand? 79 | GitStyleBinary.valid_subcommand?(GitStyleBinary.current_command_name) 80 | end 81 | 82 | def load_all_parser_constraints 83 | @loaded_all_parser_constraints ||= begin 84 | load_parser_default_constraints 85 | load_parser_primary_constraints 86 | load_parser_local_constraints 87 | true 88 | end 89 | end 90 | 91 | def load_parser_default_constraints 92 | parser.consume_all([self.class.defaults]) 93 | end 94 | 95 | def load_parser_primary_constraints 96 | parser.consume_all(GitStyleBinary.primary_command.constraints) 97 | end 98 | 99 | def load_parser_local_constraints 100 | cur = GitStyleBinary.current_command # see, why isn't 'this' current_command? 101 | 102 | unless self.is_primary? && cur == self 103 | # TODO TODO - the key lies in this function. figure out when you hav emore engergy 104 | # soo UGLY. see #process_parser! unify with that method 105 | # parser.consume_all(constraints) rescue ArgumentError 106 | parser.consume_all(cur.constraints) 107 | end 108 | end 109 | 110 | def call_parser_run_block 111 | runs = GitStyleBinary.current_command.parser.runs 112 | 113 | parser.run_callbacks(:before_run, self) 114 | parser.runs.last.call(self) # ... not too happy with this 115 | parser.run_callbacks(:after_run, self) 116 | end 117 | 118 | def process_args_with_subcmd(args = ARGV, *a, &b) 119 | cmd = GitStyleBinary.current_command_name 120 | vals = process_args(args, *a, &b) 121 | parser.leftovers.shift if parser.leftovers[0] == cmd 122 | vals 123 | end 124 | 125 | # TOOooootally ugly! why? bc load_parser_local_constraints doesn't work 126 | # when loading the indivdual commands because it depends on 127 | # #current_command. This really sucks and is UGLY. 128 | # the todo is to put in 'load_all_parser_constraints' and this works 129 | def process_parser! 130 | # load_all_parser_constraints 131 | 132 | load_parser_default_constraints 133 | load_parser_primary_constraints 134 | # load_parser_local_constraints 135 | parser.consume_all(constraints) 136 | 137 | # hack 138 | parser.consume { 139 | opt :version, "Print version and exit" if @version unless @specs[:version] || @long["version"] 140 | opt :help, "Show this message" unless @specs[:help] || @long["help"] 141 | resolve_default_short_options 142 | } # hack 143 | end 144 | 145 | def process_args(args = ARGV, *a, &b) 146 | p = parser 147 | begin 148 | vals = p.parse args 149 | args.clear 150 | p.leftovers.each { |l| args << l } 151 | vals # ugly todo 152 | rescue Trollop::CommandlineError => e 153 | $stderr.puts "Error: #{e.message}." 154 | $stderr.puts "Try --help for help." 155 | exit(-1) 156 | rescue Trollop::HelpNeeded 157 | p.educate 158 | exit 159 | rescue Trollop::VersionNeeded 160 | puts p.version 161 | exit 162 | end 163 | end 164 | 165 | def is_primary? 166 | false 167 | end 168 | 169 | def argv 170 | parser.leftovers 171 | end 172 | 173 | def short_desc 174 | parser.short_desc 175 | end 176 | 177 | def full_name 178 | # ugly, should be is_primary? 179 | GitStyleBinary.primary_name == name ? GitStyleBinary.primary_name : GitStyleBinary.primary_name + "-" + name 180 | end 181 | 182 | def die arg, msg=nil 183 | p = parser # create local copy 184 | Trollop.instance_eval { @p = p } 185 | Trollop::die(arg, msg) 186 | end 187 | 188 | # Helper to return the option 189 | def [](k) 190 | opts[k] 191 | end 192 | 193 | end 194 | 195 | class Primary < Command 196 | def is_primary? 197 | true 198 | end 199 | def primary 200 | self 201 | end 202 | end 203 | 204 | end 205 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/commands/help.rb: -------------------------------------------------------------------------------- 1 | module GitStyleBinary 2 | module Commands 3 | class Help 4 | # not loving this syntax, but works for now 5 | GitStyleBinary.command do 6 | short_desc "get help for a specific command" 7 | run do |command| 8 | 9 | # this is slightly ugly b/c it has to muck around in the internals to 10 | # get information about commands other than itself. This isn't a 11 | # typical case 12 | self.class.send :define_method, :educate_about_command do |name| 13 | load_all_commands 14 | if GitStyleBinary.known_commands.has_key?(name) 15 | cmd = GitStyleBinary.known_commands[name] 16 | cmd.process_parser! 17 | cmd.parser.educate 18 | else 19 | puts "Unknown command '#{name}'" 20 | end 21 | end 22 | 23 | if command.argv.size > 0 24 | command.argv.first == "help" ? educate : educate_about_command(command.argv.first) 25 | else 26 | educate 27 | end 28 | end 29 | end 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/helpers/name_resolver.rb: -------------------------------------------------------------------------------- 1 | module GitStyleBinary 2 | module Helpers 3 | module NameResolver 4 | 5 | def basename(filename=zero) 6 | File.basename(filename).match(/(.*?)(\-|$)/).captures.first 7 | end 8 | alias_method :primary_name, :basename 9 | 10 | # checks the bin directory for all files starting with +basename+ and 11 | # returns an array of strings specifying the subcommands 12 | def subcommand_names(filename=zero) 13 | subfiles = Dir[File.join(binary_directory, basename + "-*")] 14 | cmds = subfiles.collect{|file| File.basename(file).sub(/^#{basename}-/, '')}.sort 15 | cmds += built_in_command_names 16 | cmds.uniq 17 | end 18 | 19 | def binary_directory(filename=zero) 20 | File.dirname(filename) 21 | end 22 | 23 | def built_in_commands_directory 24 | File.dirname(__FILE__) + "/../commands" 25 | end 26 | 27 | def built_in_command_names 28 | Dir[built_in_commands_directory + "/*.rb"].collect{|f| File.basename(f.sub(/\.rb$/,''))} 29 | end 30 | 31 | def list_subcommands(filename=zero) 32 | subcommand_names(filename).join(", ") 33 | end 34 | 35 | # load first from users binary directory. then load built-in commands if 36 | # available 37 | def binary_filename_for(name) 38 | user_file = File.join(binary_directory, "#{basename}-#{name}") 39 | return user_file if File.exists?(user_file) 40 | built_in = File.join(built_in_commands_directory, "#{name}.rb") 41 | return built_in if File.exists?(built_in) 42 | user_file 43 | end 44 | 45 | def current_command_name(filename=zero,argv=ARGV) 46 | current = File.basename(zero) 47 | first_arg = ARGV[0] 48 | return first_arg if valid_subcommand?(first_arg) 49 | return basename if basename == current 50 | current.sub(/^#{basename}-/, '') 51 | end 52 | 53 | # returns the command name with the prefix if needed 54 | def full_current_command_name(filename=zero,argv=ARGV) 55 | cur = current_command_name(filename, argv) 56 | subcmd = cur == basename(filename) ? false : true # is this a subcmd? 57 | "%s%s%s" % [basename(filename), subcmd ? "-" : "", subcmd ? current_command_name(filename, argv) : ""] 58 | end 59 | 60 | def valid_subcommand?(name) 61 | subcommand_names.include?(name) 62 | end 63 | 64 | def zero 65 | $0 66 | end 67 | 68 | def pretty_known_subcommands(theme=:long) 69 | GitStyleBinary.known_commands.collect do |k,cmd| 70 | next if k == basename 71 | cmd.process_parser! 72 | ("%-s%s%-10s" % [basename, '-', k]).colorize(:light_blue) + ("%s " % [theme == :long ? "\n" : ""]) + ("%s" % [cmd.short_desc]) + "\n" 73 | end.compact.sort 74 | end 75 | 76 | end 77 | end 78 | end 79 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/helpers/pager.rb: -------------------------------------------------------------------------------- 1 | module GitStyleBinary 2 | module Helpers 3 | module Pager 4 | 5 | # by Nathan Weizenbaum - http://nex-3.com/posts/73-git-style-automatic-paging-in-ruby 6 | def run_pager 7 | return if RUBY_PLATFORM =~ /win32/ 8 | return unless STDOUT.tty? 9 | STDOUT.use_color = true 10 | 11 | read, write = IO.pipe 12 | 13 | unless Kernel.fork # Child process 14 | STDOUT.reopen(write) 15 | STDERR.reopen(write) if STDERR.tty? 16 | read.close 17 | write.close 18 | return 19 | end 20 | 21 | # Parent process, become pager 22 | STDIN.reopen(read) 23 | read.close 24 | write.close 25 | 26 | ENV['LESS'] = 'FSRX' # Don't page if the input is short enough 27 | 28 | Kernel.select [STDIN] # Wait until we have input before we start the pager 29 | pager = ENV['PAGER'] || 'less -erXF' 30 | exec pager rescue exec "/bin/sh", "-c", pager 31 | end 32 | 33 | module_function :run_pager 34 | 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/parser.rb: -------------------------------------------------------------------------------- 1 | module GitStyleBinary 2 | class Parser < Trollop::Parser 3 | attr_reader :runs, :callbacks 4 | attr_reader :short_desc 5 | attr_accessor :command 6 | 7 | def initialize *a, &b 8 | super 9 | @runs = [] 10 | setup_callbacks 11 | end 12 | 13 | def setup_callbacks 14 | @callbacks = {} 15 | %w(run).each do |event| 16 | %w(before after).each do |time| 17 | @callbacks["#{time}_#{event}".to_sym] = [] 18 | instance_eval "def #{time}_#{event}(&block);@callbacks[:#{time}_#{event}] << block;end" 19 | end 20 | end 21 | end 22 | 23 | def run_callbacks(at, from) 24 | @callbacks[at].each {|c| c.call(from) } 25 | end 26 | 27 | def banner s=nil; @banner = s if s; @banner end 28 | def short_desc s=nil; @short_desc = s if s; @short_desc end 29 | def name_desc s=nil; @name_desc = s if s; @name_desc end 30 | 31 | # Set the theme. Valid values are +:short+ or +:long+. Default +:long+ 32 | attr_writer :theme 33 | 34 | def theme 35 | @theme ||= :long 36 | end 37 | 38 | ## Adds text to the help display. 39 | def text s; @order << [:text, s] end 40 | 41 | def spec_names 42 | @specs.collect{|name, spec| spec[:long]} 43 | end 44 | 45 | # should probably be somewhere else 46 | def load_all_commands 47 | GitStyleBinary.subcommand_names.each do |name| 48 | cmd_file = GitStyleBinary.binary_filename_for(name) 49 | GitStyleBinary.load_command_file(name, cmd_file) 50 | end 51 | end 52 | 53 | ## Print the help message to 'stream'. 54 | def educate(stream=$stdout) 55 | load_all_commands 56 | width # just calculate it now; otherwise we have to be careful not to 57 | # call this unless the cursor's at the beginning of a line. 58 | GitStyleBinary::Helpers::Pager.run_pager 59 | self.send("educate_#{theme}", stream) 60 | end 61 | 62 | def educate_long(stream=$stdout) 63 | left = {} 64 | 65 | @specs.each do |name, spec| 66 | left[name] = 67 | ((spec[:short] ? "-#{spec[:short]}, " : "") + 68 | "--#{spec[:long]}" + 69 | case spec[:type] 70 | when :flag; "" 71 | when :int; "=" 72 | when :ints; "=" 73 | when :string; "=" 74 | when :strings; "=" 75 | when :float; "=" 76 | when :floats; "=" 77 | end).colorize(:red) 78 | end 79 | 80 | leftcol_width = left.values.map { |s| s.length }.max || 0 81 | rightcol_start = leftcol_width + 6 # spaces 82 | leftcol_start = 6 83 | leftcol_spaces = " " * leftcol_start 84 | 85 | unless @order.size > 0 && @order.first.first == :text 86 | 87 | if @name_desc 88 | stream.puts "NAME".colorize(:red) 89 | stream.puts "#{leftcol_spaces}"+ colorize_known_words(eval(%Q["#{@name_desc}"])) + "\n" 90 | stream.puts 91 | end 92 | 93 | if @version 94 | stream.puts "VERSION".colorize(:red) 95 | stream.puts "#{leftcol_spaces}#@version\n" 96 | end 97 | 98 | stream.puts 99 | 100 | banner = colorize_known_words_array(wrap(eval(%Q["#{@banner}"]) + "\n", :prefix => leftcol_start)) if @banner # lazy banner 101 | stream.puts banner 102 | 103 | stream.puts 104 | stream.puts "OPTIONS".colorize(:red) 105 | else 106 | stream.puts "#@banner\n" if @banner 107 | end 108 | 109 | @order.each do |what, opt| 110 | if what == :text 111 | stream.puts wrap(opt) 112 | next 113 | end 114 | 115 | spec = @specs[opt] 116 | stream.printf " %-#{leftcol_width}s\n", left[opt] 117 | desc = spec[:desc] + 118 | if spec[:default] 119 | if spec[:desc] =~ /\.$/ 120 | " (Default: #{spec[:default]})" 121 | else 122 | " (default: #{spec[:default]})" 123 | end 124 | else 125 | "" 126 | end 127 | stream.puts wrap(" %s" % [desc], :prefix => leftcol_start, :width => width - rightcol_start - 1 ) 128 | stream.puts 129 | stream.puts 130 | end 131 | 132 | end 133 | 134 | def educate_short(stream=$stdout) 135 | left = {} 136 | 137 | @specs.each do |name, spec| 138 | left[name] = "--#{spec[:long]}" + 139 | (spec[:short] ? ", -#{spec[:short]}" : "") + 140 | case spec[:type] 141 | when :flag; "" 142 | when :int; " " 143 | when :ints; " " 144 | when :string; " " 145 | when :strings; " " 146 | when :float; " " 147 | when :floats; " " 148 | end 149 | end 150 | 151 | leftcol_width = left.values.map { |s| s.length }.max || 0 152 | rightcol_start = leftcol_width + 6 # spaces 153 | leftcol_start = 0 154 | 155 | unless @order.size > 0 && @order.first.first == :text 156 | stream.puts "#@version\n" if @version 157 | stream.puts colorize_known_words_array(wrap(eval(%Q["#{@banner}"]) + "\n", :prefix => leftcol_start)) if @banner # jit banner 158 | stream.puts "Options:" 159 | else 160 | stream.puts "#@banner\n" if @banner 161 | end 162 | 163 | @order.each do |what, opt| 164 | if what == :text 165 | stream.puts wrap(opt) 166 | next 167 | end 168 | 169 | spec = @specs[opt] 170 | stream.printf " %#{leftcol_width}s: ", left[opt] 171 | desc = spec[:desc] + 172 | if spec[:default] 173 | if spec[:desc] =~ /\.$/ 174 | " (Default: #{spec[:default]})" 175 | else 176 | " (default: #{spec[:default]})" 177 | end 178 | else 179 | "" 180 | end 181 | stream.puts wrap(desc, :width => width - rightcol_start - 1, :prefix => rightcol_start) 182 | end 183 | 184 | end 185 | 186 | 187 | def colorize_known_words_array(txts) 188 | txts.collect{|txt| colorize_known_words(txt)} 189 | end 190 | 191 | def colorize_known_words(txt) 192 | txt = txt.gsub(/^([A-Z]+\s*)$/, '\1'.colorize(:red)) # all caps words on their own line 193 | txt = txt.gsub(/\b(#{bin_name})\b/, '\1'.colorize(:light_blue)) # the current command name 194 | txt = txt.gsub(/\[([^\s]+)\]/, "[".colorize(:magenta) + '\1'.colorize(:green) + "]".colorize(:magenta)) # synopsis options 195 | end 196 | 197 | def consume(&block) 198 | cloaker(&block).bind(self).call 199 | end 200 | 201 | def consume_all(blocks) 202 | blocks.each {|b| consume(&b)} 203 | end 204 | 205 | def bin_name 206 | GitStyleBinary.full_current_command_name 207 | end 208 | 209 | def all_options_string 210 | # '#{spec_names.collect(&:to_s).collect{|name| "[".colorize(:magenta) + "--" + name + "]".colorize(:magenta)}.join(" ")} COMMAND [ARGS]' 211 | '#{spec_names.collect(&:to_s).collect{|name| "[" + "--" + name + "]"}.join(" ")} COMMAND [ARGS]' 212 | end 213 | 214 | def run(&block) 215 | @runs << block 216 | end 217 | 218 | def action(name = :action, &block) 219 | block.call(self) if block 220 | end 221 | 222 | end 223 | end 224 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/test/fixtures/flickr: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | $:.unshift(File.dirname(__FILE__) + "/../../lib") 3 | VERSION="0.0.2" # just to test it 4 | require 'git-style-binary/command' 5 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/test/fixtures/flickr-download: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | $:.unshift(File.dirname(__FILE__) + "/../../lib") 3 | require 'git-style-binary/command' 4 | 5 | GitStyleBinary.command do 6 | short_desc "download a flickr image" 7 | banner <<-EOS 8 | SYNOPSIS 9 | #{command.full_name} #{all_options_string} url 10 | 11 | Downloads an image from flickr 12 | 13 | EOS 14 | run do |command| 15 | puts "would download: #{command.argv.inspect}" 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/test/fixtures/wordpress: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | $:.unshift(File.dirname(__FILE__) + "/../../lib") 3 | 4 | require 'git-style-binary/command' 5 | GitStyleBinary.primary do 6 | version "0.0.1 (c) 2009 Nate Murray - local" 7 | opt :test_primary, "test an option on the primary", :type => String 8 | 9 | action do 10 | @categories = ["sports", "news"] 11 | end 12 | 13 | before_run do |cmd| 14 | puts "before_run command #{cmd}" 15 | end 16 | 17 | after_run do |cmd| 18 | puts "after_run command #{cmd}" 19 | end 20 | 21 | run do |command| 22 | puts "Primary Options: #{command.opts.inspect}" 23 | end 24 | end 25 | 26 | # OR 27 | 28 | # require 'git-style-binary/primary' 29 | # command = GitStyleBinary::primary("wordpress") do 30 | # version "#{$0} 0.0.1 (c) 2009 Nate Murray" 31 | # banner <<-EOS 32 | # usage: #{$0} #{all_options.collect(:&to_s).join(" ")} COMMAND [ARGS] 33 | # 34 | # The wordpress subcommands commands are: 35 | # {subcommand_names.pretty_print} 36 | # 37 | # See 'wordpress help COMMAND' for more information on a specific command. 38 | # EOS 39 | # opt :verbose, "verbose", :default => false 40 | # opt :dry, "dry run", :default => false 41 | # opt :test_global, "a basic global string option", :type => String 42 | # end 43 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/test/fixtures/wordpress-categories: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | $:.unshift(File.dirname(__FILE__) + "/../../lib") 3 | require 'git-style-binary/command' 4 | 5 | GitStyleBinary.command do 6 | short_desc "do something with categories" 7 | banner <<-EOS 8 | SYNOPSIS 9 | #{command.full_name} #{all_options_string} 10 | 11 | Does something with categories 12 | 13 | EOS 14 | run do |command| 15 | puts "does something with categories" 16 | puts @categories.join(" ") 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/test/fixtures/wordpress-list: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | $:.unshift(File.dirname(__FILE__) + "/../../lib") 3 | require 'git-style-binary/command' 4 | 5 | GitStyleBinary.command do 6 | short_desc "list blog postings" 7 | banner <<-EOS 8 | SYNOPSIS 9 | #{command.full_name} #{all_options_string} 10 | 11 | Lists the posts on the blog 12 | 13 | EOS 14 | run do |command| 15 | puts "listing blog posts" 16 | end 17 | end 18 | 19 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/test/fixtures/wordpress-post: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | $:.unshift(File.dirname(__FILE__) + "/../../lib") 3 | require 'git-style-binary/command' 4 | 5 | GitStyleBinary.command do 6 | short_desc "create a blog post" 7 | banner <<-EOS 8 | SYNOPSIS 9 | #{command.full_name} #{all_options_string} {content|STDIN} 10 | 11 | EOS 12 | opt :blog, "short name of the blog to use", :default => 'default' 13 | opt :category, "tag/category. specify multiple times for multiple categories", :type => String, :multi => true 14 | opt :title, "title for the post", :required => true, :type => String 15 | opt :type, "type of the content [html|xhtml|text]", :default => 'html', :type => String 16 | 17 | run do |command| 18 | command.die :type, "type must be one of [html|xhtml|text]" unless command.opts[:type] =~ /^(x?html|text)$/i 19 | 20 | puts "Subcommand name: #{command.name.inspect}" 21 | puts "Options: #{command.opts.inspect}" 22 | puts "Remaining arguments: #{command.argv.inspect}" 23 | end 24 | end 25 | 26 | 27 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/test/git-style-binary/command_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + "/../test_helper.rb" 2 | require 'git-style-binary/command' 3 | 4 | class CommandTest < Test::Unit::TestCase 5 | context "cmd" do 6 | setup do 7 | @c = GitStyleBinary::Command.new 8 | end 9 | 10 | should "be able to easily work with constraints" do 11 | assert_equal @c.constraints, [] 12 | @c.constraints << "foo" 13 | assert_equal @c.constraints, ["foo"] 14 | end 15 | 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/test/git_style_binary_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + "/test_helper.rb" 2 | 3 | class GitStyleBinariesTest < Test::Unit::TestCase 4 | context "parsing basenames" do 5 | should "accurately parse basenames" do 6 | assert_equal "wordpress", GitStyleBinary.basename("bin/wordpress") 7 | assert_equal "wordpress", GitStyleBinary.basename("bin/wordpress-post") 8 | assert_equal "wordpress", GitStyleBinary.basename("wordpress-post") 9 | end 10 | 11 | should "get the current command name" do 12 | # doesn't really apply any more b/c it calls 'current' which is never the 13 | # current when your running rake_test_loader.rb 14 | # 15 | # assert_equal "wordpress", GitStyleBinary.current_command_name("bin/wordpress", ["--help"]) 16 | # assert_equal "post", GitStyleBinary.current_command_name("bin/wordpress-post", ["--help"]) 17 | # assert_equal "post", GitStyleBinary.current_command_name("bin/wordpress post", ["--help"]) 18 | #assert_equal "post", GitStyleBinary.current_command_name("bin/wordpress post", []) 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/test/running_binaries_test.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + "/test_helper.rb" 2 | 3 | THIS_YEAR=Time.now.year # todo 4 | 5 | class RunningBinariesTest < Test::Unit::TestCase 6 | include RunsBinaryFixtures 7 | 8 | context "when running primary" do 9 | ["wordpress -h", "wordpress help"].each do |format| 10 | context "and getting help as a '#{format}'" do 11 | setup { @stdout, @stderr = bin(format) } 12 | 13 | should "have the command name and short description" do 14 | unless format == "wordpress -h" # doesn't apply to wordpress -h 15 | output_matches /NAME\n\s*wordpress\-help \- get help for a specific command/m 16 | end 17 | end 18 | 19 | should "have a local (not default) version string" do 20 | output_matches /0\.0\.1 \(c\) 2009 Nate Murray - local/ 21 | end 22 | 23 | should "get a list of subcommands" do 24 | output_matches /subcommands/mi 25 | end 26 | 27 | should "have subcommand short descriptions" do 28 | output_matches /post\s*create a blog post/ 29 | output_matches /categories\s*do something with categories/ 30 | output_matches /help\s*get help for a specific command/ 31 | output_matches /list\s*list blog postings/ 32 | end 33 | 34 | should "have a usage" do 35 | output_matches /SYNOPSIS/i 36 | output_matches /wordpress(\-help)? \[/ 37 | end 38 | 39 | should "be able to ask for help about help" 40 | end 41 | end 42 | 43 | context "and getting help as subcommand" do 44 | # ["wordpress -h", "wordpress help"].each do |format| 45 | ["wordpress help"].each do |format| 46 | context "'#{format}'" do 47 | should "get help on subcommand post" 48 | end 49 | end 50 | end 51 | 52 | context "with no options" do 53 | setup { @stdout, @stderr = bin("wordpress") } 54 | 55 | should "output the options" do 56 | output_matches /Primary Options:/ 57 | end 58 | 59 | should "have the test_primary option" do 60 | output_matches /test_primary=>nil/ 61 | end 62 | end 63 | should "be able to require 'primary' and run just fine" 64 | end 65 | 66 | context "when running with an action" do 67 | # should be the same for both formats 68 | ["wordpress-categories", "wordpress categories"].each do |bin_format| 69 | context "#{bin_format}" do 70 | 71 | context "with action block" do 72 | setup { @stdout, @stderr = bin("#{bin_format}") } 73 | should "have the parsed action items in the help output" do 74 | output_matches /sports news/m 75 | end 76 | end 77 | end 78 | end 79 | end 80 | 81 | context "callbacks" do 82 | context "on a binary" do 83 | setup { @stdout, @stderr = bin("wordpress") } 84 | 85 | %w(before after).each do |time| 86 | should "run the callback #{time}_run}" do 87 | assert @stdout.match(/#{time}_run command/) 88 | end 89 | end 90 | end 91 | 92 | context "on help" do 93 | setup { @stdout, @stderr = bin("wordpress -h") } 94 | 95 | %w(before after).each do |time| 96 | should "not run the callback #{time}_run" do 97 | assert_nil @stdout.match(/#{time}_run command/) 98 | end 99 | end 100 | end 101 | 102 | end 103 | 104 | 105 | context "when running the subcommand" do 106 | # should be the same for both formats 107 | ["wordpress-post", "wordpress post"].each do |bin_format| 108 | context "#{bin_format}" do 109 | 110 | context "with no options" do 111 | setup { @stdout, @stderr = bin("#{bin_format}") } 112 | should "fail because title is required" do 113 | output_matches /Error: option 'title' must be specified.\s*Try --help for help/m 114 | end 115 | end 116 | 117 | context "with options" do 118 | setup { @stdout, @stderr = bin("#{bin_format} --title='glendale'") } 119 | should "be running the subcommand's run block" do 120 | output_matches /Subcommand name/ 121 | end 122 | should "have some default options" do 123 | output_matches /version=>false/ 124 | output_matches /help=>false/ 125 | end 126 | should "have some primary options" do 127 | output_matches /test_primary=>nil/ 128 | end 129 | should "have some local options" do 130 | output_matches /title=>"glendale"/ 131 | output_matches /type=>"html"/ 132 | end 133 | end 134 | 135 | context "testing die statements" do 136 | setup { @stdout, @stderr = bin("#{bin_format} --title='glendale' --type=yaml") } 137 | 138 | should "die on invalid options" do 139 | output_matches /argument \-\-type type must be one of \[html\|xhtml\|text\]/ 140 | end 141 | end 142 | 143 | end # end bin_format 144 | end # end #each 145 | end 146 | 147 | ["wordpress help post", "wordpress post -h"].each do |format| 148 | context "when calling '#{format}'" do 149 | 150 | setup { @stdout, @stderr = bin(format) } 151 | should "have a description" do 152 | output_matches /create a blog post/ 153 | end 154 | 155 | should "have the proper usage line" do 156 | output_matches /SYNOPSIS\n\s*wordpress\-post/m 157 | output_matches /\[--title\]/ 158 | end 159 | 160 | should "have option flags" do 161 | output_matches /\-\-title(.*)/ 162 | end 163 | 164 | should "have primary option flags" do 165 | output_matches /\-\-test-primary(.*)/ 166 | end 167 | 168 | should "have default option flags" do 169 | output_matches /\-\-verbose/ 170 | end 171 | 172 | should "have trollop default option flags" do 173 | output_matches /\-e, \-\-version/ 174 | end 175 | 176 | should "have the correct binary name and short description" do 177 | output_matches /NAME\n\s*wordpress\-post \- create a blog post/m 178 | end 179 | 180 | should "have a the primaries version string" do 181 | output_matches /0\.0\.1 \(c\) 2009 Nate Murray - local/ 182 | end 183 | 184 | should "have options" do 185 | output_matches /Options/i 186 | 187 | output_matches /\-b, \-\-blog=/ 188 | output_matches /short name of the blog to use/ 189 | 190 | output_matches /-i, \-\-title=/ 191 | output_matches /title for the post/ 192 | end 193 | 194 | end 195 | end 196 | 197 | context "when running a bare primary" do 198 | ["flickr -h", "flickr help"].each do |format| 199 | context format do 200 | setup { @stdout, @stderr = bin(format) } 201 | 202 | should "have the name and short description" do 203 | unless format == "flickr -h" # hmm 204 | output_matches /NAME\n\s*flickr\-help \- get help for a specific command/m 205 | end 206 | end 207 | 208 | should "have a local (not default) version string" do 209 | output_matches /0\.0\.2 \(c\) #{Time.now.year}/ 210 | end 211 | end 212 | end 213 | ["flickr-download -h", "flickr download -h"].each do |format| 214 | context format do 215 | setup { @stdout, @stderr = bin(format) } 216 | 217 | should "match on usage" do 218 | output_matches /SYNOPSIS\n\s*flickr\-download/m 219 | end 220 | end 221 | end 222 | end 223 | 224 | end 225 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/test/shoulda_macros/matching_stdio.rb: -------------------------------------------------------------------------------- 1 | class Test::Unit::TestCase 2 | def output_should_match(regexp) 3 | assert_match regexp, @stdout + @stderr 4 | end 5 | alias_method :output_matches, :output_should_match 6 | 7 | def stdout_should_match(regexp) 8 | assert_match regexp, @stdout 9 | end 10 | def stderr_should_match(regexp) 11 | assert_match regexp, @stderr 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /bin/yadr/lib/git-style-binaries-0.1.11/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'test/unit' 3 | require 'shoulda' 4 | begin require 'redgreen'; rescue LoadError; end 5 | require 'open3' 6 | 7 | $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) 8 | $LOAD_PATH.unshift(File.dirname(__FILE__)) 9 | Dir[File.join(File.dirname(__FILE__), "shoulda_macros", "*.rb")].each {|f| require f} 10 | ENV['NO_COLOR'] = "true" 11 | 12 | require 'git-style-binary' 13 | GitStyleBinary.run = true 14 | 15 | class Test::Unit::TestCase 16 | def fixtures_dir 17 | File.join(File.dirname(__FILE__), "fixtures") 18 | end 19 | end 20 | 21 | module RunsBinaryFixtures 22 | # run the specified cmd returning the string values of [stdout,stderr] 23 | def bin(cmd) 24 | stdin, stdout, stderr = Open3.popen3("#{fixtures_dir}/#{cmd}") 25 | [stdout.read, stderr.read] 26 | end 27 | end 28 | 29 | -------------------------------------------------------------------------------- /bin/yadr/lib/trollop-1.16.2/FAQ.txt: -------------------------------------------------------------------------------- 1 | Trollop FAQ 2 | ----------- 3 | 4 | Q: Why is it called "Trollop"? 5 | A: No reason. 6 | 7 | Q: Why should I use Trollop? 8 | A: Because it will take you FEWER LINES OF CODE to do reasonable option parsing 9 | than any other option parser out there. 10 | 11 | Look at this: 12 | 13 | opts = Trollop::options do 14 | opt :monkey, "Use monkey mode" 15 | opt :goat, "Use goat mode", :default => true 16 | opt :num_limbs, "Set number of limbs", :default => 4 17 | end 18 | 19 | That's it. And opts is a hash and you do whatever you want with it. 20 | Trivial. You don't have to mix option processing code blocks with the 21 | declarations. You don't have to make a class for every option (what is this, 22 | Java?). You don't have to write more than 1 line of code per option. 23 | 24 | Plus, you get a beautiful help screen that detects your terminal width and 25 | wraps appropriately. C'mon, that's hot. 26 | 27 | Q: What is the philosophy behind Trollop? 28 | A: Must a commandline option processor have a philosophy? 29 | 30 | Q: Seriously now. What is it? 31 | A: Ok, it's this: Trollop *just* does the parsing and gives you a hash table 32 | of the result. So whatever fancy logic or constraints you need, you can 33 | implement by operating on that hash table. Options that disable other 34 | options, fancy constraints involving multiple sets of values across multiple 35 | sets of options, etc. are all left for you to do manually. 36 | 37 | (Trollop does support limited constraint setting (see #conflicts and 38 | #depends), but any non-trivial program will need to get fancier.) 39 | 40 | The result is that using Trollop is pretty simple, and whatever bizarre 41 | logic you want, you can write yourself. And don't forget, you can call 42 | Trollop::die to abort the program and give a fancy options-related error 43 | message. 44 | 45 | Q: What happens to the other stuff on the commandline? 46 | A: Anything Trollop doesn't recognize as an option or as an option parameter is 47 | left in ARGV for you to process. 48 | 49 | Q: Does Trollop support multiple-value arguments? 50 | A: Yes. If you set the :type of an option to something plural, like ":ints", 51 | ":strings", ":doubles", ":floats", ":ios", it will accept multiple arguments 52 | on the commandline and the value will be an array of these. 53 | 54 | Q: Does Trollop support arguments that can be given multiple times? 55 | A: Yes. If you set :multi to true, then the argument can appear multiple times 56 | on the commandline, and the value will be an array of the parameters. 57 | 58 | Q: Does Trollop support subcommands? 59 | A: Yes. You get subcommand support by adding a call #stop_on within the options 60 | block, and passing the names of the subcommands to it. (See the third 61 | example on the webpage.) When Trollop encounters one of these subcommands on 62 | the commandline, it stops processing and returns. 63 | 64 | ARGV at that point will contain the subcommand followed by any subcommand 65 | options, since Trollop has contained the rest. So you can consume the 66 | subcommand and call Trollop.options again with the particular options set 67 | for that subcommand. 68 | 69 | If you don't know the subcommands ahead of time, you can call 70 | #stop_on_unknown, which will cause Trollop to stop when it encounters any 71 | unknown token. This might be more trouble than its worth if you're also 72 | passing filenames on the commandline. 73 | 74 | It's probably easier to see the example on the webpage than to read all 75 | that. 76 | 77 | Q: Why does Trollop disallow numeric short argument names, like '-1' and '-9'? 78 | A: Because it's ambiguous whether these are arguments or negative integer or 79 | floating-point parameters to arguments. E.g., what about "-f -3". Is that a 80 | negative three parameter to -f, or two separate parameters? 81 | 82 | I could be very clever and detect when there are no arguments that require 83 | floating-point parameters, and allow such short option names in those cases, 84 | but opted for simplicity and consistency. 85 | -------------------------------------------------------------------------------- /bin/yadr/lib/trollop-1.16.2/History.txt: -------------------------------------------------------------------------------- 1 | == 1.16.2 / 2010-04-06 2 | * Bugfix in Trollop::options. Thanks to Brian C. Thomas for pointing it out. 3 | 4 | == 1.16.1 / 2010-04-05 5 | * Bugfix in Trollop::die method introduced in last release. 6 | 7 | == 1.16 / 2010-04-01 8 | * Add Trollop::with_standard_exception_handling method for easing the use of Parser directly. 9 | * Handle scientific notation in float arguments, thanks to Will Fitzgerald. 10 | * Drop hoe dependency. 11 | 12 | == 1.15 / 2009-09-30 13 | * Don't raise an exception when out of short arguments (thanks to Rafael 14 | Sevilla for pointing out how dumb this behavior was). 15 | 16 | == 1.14 / 2009-06-19 17 | * Make :multi arguments default to [], not nil, when not set on the commandline. 18 | * Minor commenting and error message improvements 19 | 20 | == 1.13 / 2009-03-16 21 | * Fix parsing of "--longarg=". 22 | 23 | == 1.12 / 2009-01-30 24 | * Fix some unit test failures in the last release. Should be more careful. 25 | * Make default short options only be assigned *after* all user-specified 26 | short options. Now there's a little less juggling to do when you just 27 | want to specify a few short options. 28 | 29 | == 1.11 / 2009-01-29 30 | * Set _given keys in the results hash for options that were specified 31 | on the commandline. 32 | 33 | == 1.10.2 / 2008-10-23 34 | * No longer try `stty size` for screen size detection. Just use curses, and 35 | screen users will have to deal with the screen clearing. 36 | 37 | == 1.10.1 / 2008-10-22 38 | * Options hash now responds to method calls as well as standard hash lookup. 39 | * Default values for multi-occurrence parameters now autoboxed. 40 | * The relationship between multi-value, multi-occurrence, and default values 41 | improved and explained. 42 | * Documentation improvements. 43 | 44 | == 1.10 / 2008-10-21 45 | * Added :io type for parameters that point to IO streams (filenames, URIs, etc). 46 | * For screen size detection, first try `stty size` before loading Curses. 47 | * Improved documentation. 48 | 49 | == 1.9 / 2008-08-20 50 | * Added 'stop_on_unknown' command to stop parsing on any unknown argument. 51 | This is useful for handling sub-commands when you don't know the entire 52 | set of commands up front. (E.g. if the initial arguments can change it.) 53 | * Added a :multi option for parameters, signifying that they can be specified 54 | multiple times. 55 | * Added :ints, :strings, :doubles, and :floats option types, which can take 56 | multiple arguments. 57 | 58 | == 1.8.2 / 2008-06-25 59 | * Bugfix for #conflicts and #depends error messages 60 | 61 | == 1.8.1 / 2008-06-24 62 | * Bugfix for short option autocreation 63 | * More aggressive documentation 64 | 65 | == 1.8 / 2008-06-16 66 | * Sub-command support via Parser#stop_on 67 | 68 | == 1.7.2 / 2008-01-16 69 | * Ruby 1.9-ify. Apparently this means replacing :'s with ;'s. 70 | 71 | == 1.7.1 / 2008-01-07 72 | * Documentation improvements 73 | 74 | == 1.7 / 2007-06-17 75 | * Fix incorrect error message for multiple missing required arguments 76 | (thanks to Neill Zero) 77 | 78 | == 1.6 / 2007-04-01 79 | * Don't attempt curses screen-width magic unless running on a terminal. 80 | 81 | == 1.5 / 2007-03-31 82 | * --help and --version do the right thing even if the rest of the 83 | command line is incorrect. 84 | * Added #conflicts and #depends to model dependencies and exclusivity 85 | between arguments. 86 | * Minor bugfixes. 87 | 88 | == 1.4 / 2007-03-26 89 | * Disable short options with :short => :none. 90 | * Minor bugfixes and error message improvements. 91 | 92 | == 1.3 / 2007-01-31 93 | * Wrap at (screen width - 1) instead of screen width. 94 | * User can override --help and --version. 95 | * Bugfix in handling of -v and -h. 96 | * More tests to confirm the above. 97 | 98 | == 1.2 / 2007-01-31 99 | * Minor documentation tweaks. 100 | * Removed hoe dependency. 101 | 102 | == 1.1 / 2007-01-30 103 | * Trollop::options now passes any arguments as block arguments. Since 104 | instance variables are not properly captured by the block, this 105 | makes it slightly less noisy to pass them in as local variables. 106 | (A real-life use for _why's cloaker!) 107 | * Help display now preserves original argument order. 108 | * Trollop::die now also has a single string form in case death is not 109 | due to a single argument. 110 | * Parser#text now an alias for Parser#banner, and can be called 111 | multiple times, with the output being placed in the right position 112 | in the help text. 113 | * Slightly more indicative formatting for parameterized arguments. 114 | 115 | == 1.0 / 2007-01-29 116 | * Initial release. 117 | -------------------------------------------------------------------------------- /bin/yadr/lib/trollop-1.16.2/README.txt: -------------------------------------------------------------------------------- 1 | == trollop 2 | 3 | by William Morgan (http://masanjin.net/) 4 | 5 | Main page: http://trollop.rubyforge.org 6 | 7 | Release announcements and comments: http://all-thing.net/label/trollop 8 | 9 | Documentation quickstart: See Trollop.options and then Trollop::Parser#opt. 10 | Also see the examples at http://trollop.rubyforge.org/. 11 | 12 | == DESCRIPTION 13 | 14 | Trollop is a commandline option parser for Ruby that just gets out of your 15 | way. One line of code per option is all you need to write. For that, you get a 16 | nice automatically-generated help page, robust option parsing, command 17 | subcompletion, and sensible defaults for everything you don't specify. 18 | 19 | == FEATURES/PROBLEMS 20 | 21 | - Dirt-simple usage. 22 | - Sensible defaults. No tweaking necessary, much tweaking possible. 23 | - Support for long options, short options, short option bundling, and 24 | automatic type validation and conversion. 25 | - Support for subcommands. 26 | - Automatic help message generation, wrapped to current screen width. 27 | - Lots of unit tests. 28 | 29 | == REQUIREMENTS 30 | 31 | * A burning desire to write less code. 32 | 33 | == INSTALL 34 | 35 | * gem install trollop 36 | 37 | == SYNOPSIS 38 | 39 | require 'trollop' 40 | opts = Trollop::options do 41 | opt :monkey, "Use monkey mode" # flag --monkey, default false 42 | opt :goat, "Use goat mode", :default => true # flag --goat, default true 43 | opt :num_limbs, "Number of limbs", :default => 4 # integer --num-limbs , default to 4 44 | opt :num_thumbs, "Number of thumbs", :type => :int # integer --num-thumbs , default nil 45 | end 46 | 47 | p opts # a hash: { :monkey => false, :goat => true, :num_limbs => 4, :num_thumbs => nil } 48 | 49 | == LICENSE 50 | 51 | Copyright (c) 2008--2009 William Morgan. Trollop is distributed under the same 52 | terms as Ruby. 53 | -------------------------------------------------------------------------------- /bin/yadr/lib/trollop-1.16.2/release-script.txt: -------------------------------------------------------------------------------- 1 | Just a few simple steps to make a new release. 2 | 3 | vi History.txt # and describe changes 4 | git-rank-contributors -o -h >> www/index.html 5 | vi www/index.html # and integrate contributors 6 | ## git add, git commit, etc 7 | vi lib/trollop.rb # and bump version number 8 | git commit -a -m "bump to..." 9 | git tag release- 10 | rake gem 11 | gem push pkg/ 12 | git push 13 | git push --tags 14 | rake upload_docs 15 | rake upload_webpage 16 | -------------------------------------------------------------------------------- /bin/yadr/vundle.rb: -------------------------------------------------------------------------------- 1 | require 'fileutils' 2 | 3 | module Vundle 4 | @vundles_path = File.expand_path File.join(ENV['HOME'], '.vim', '.vundles.local') 5 | def self.add_plugin_to_vundle(plugin_repo) 6 | return if contains_vundle? plugin_repo 7 | 8 | vundles = vundles_from_file 9 | last_bundle_dir = vundles.rindex{ |line| line =~ /^Bundle / } 10 | last_bundle_dir = last_bundle_dir ? last_bundle_dir+1 : 0 11 | vundles.insert last_bundle_dir, "Bundle \"#{plugin_repo}\"" 12 | write_vundles_to_file vundles 13 | end 14 | 15 | def self.remove_plugin_from_vundle(plugin_repo) 16 | vundles = vundles_from_file 17 | deleted_value = vundles.reject!{ |line| line =~ /Bundle "#{plugin_repo}"/ } 18 | 19 | write_vundles_to_file vundles 20 | 21 | !deleted_value.nil? 22 | end 23 | 24 | def self.vundle_list 25 | vundles_from_file.select{ |line| line =~ /^Bundle .*/ }.map{ |line| line.gsub(/Bundle "(.*)"/, '\1')} 26 | end 27 | 28 | def self.update_vundle 29 | system "vim --noplugin -u #{ENV['HOME']}/.vim/vundles.vim -N \"+set hidden\" \"+syntax on\" \"+let g:session_autosave = 'no'\" +BundleClean +BundleInstall! +qall" 30 | end 31 | 32 | 33 | private 34 | def self.contains_vundle?(vundle_name) 35 | FileUtils.touch(@vundles_path) unless File.exists? @vundles_path 36 | File.read(@vundles_path).include?(vundle_name) 37 | end 38 | 39 | def self.vundles_from_file 40 | FileUtils.touch(@vundles_path) unless File.exists? @vundles_path 41 | File.read(@vundles_path).split("\n") 42 | end 43 | 44 | def self.write_vundles_to_file(vundles) 45 | FileUtils.cp(@vundles_path, "#{@vundles_path}.bak") 46 | vundle_file = File.open(@vundles_path, "w") 47 | vundle_file.write(vundles.join("\n")) 48 | vundle_file.close 49 | end 50 | end 51 | -------------------------------------------------------------------------------- /bin/yadr/yadr: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require File.join(File.dirname(__FILE__), 'default_libs') 4 | -------------------------------------------------------------------------------- /bin/yadr/yadr-init-plugins: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.join(File.dirname(__FILE__), 'default_libs') 3 | 4 | GitStyleBinary.command do 5 | version "yadr-init-plugins 1.0" 6 | short_desc "Initialize all submodules. Run this every time you pull a new yadr version." 7 | 8 | run do |command| 9 | `cd "#{$yadr}" && git submodule update --init` 10 | end 11 | 12 | end 13 | -------------------------------------------------------------------------------- /bin/yadr/yadr-update-plugins: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.join(File.dirname(__FILE__), 'default_libs') 3 | 4 | GitStyleBinary.command do 5 | version "yadr-update-plugins 1.0" 6 | short_desc "Update all plugins to latest versions from github" 7 | 8 | run do |command| 9 | `cd $HOME/.yadr && rake submodules` 10 | end 11 | 12 | end 13 | -------------------------------------------------------------------------------- /bin/yadr/yadr-vim-add-plugin: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # 3 | require File.join(File.dirname(__FILE__), 'default_libs') 4 | require File.join(File.dirname(__FILE__), 'vundle') 5 | 6 | GitStyleBinary.command do 7 | version "yadr-add-vim-plugin 1.0" 8 | 9 | short_desc "Add a vim plugin from a repo" 10 | 11 | opt :url, "Repository URL (see usage)", :required => true, :type => String 12 | 13 | banner <<-'EOS' 14 | Usage: yadr-add-vim-plugin --url [URL] 15 | Specify a plugin repository URL in one of the following forms: 16 | - Custom repository URL (full URL): git://git.wincent.com/command-t.git 17 | - Github repository (username/repo_name): robgleesson/hammer.vim.git 18 | - Vim script repository (plugin_name): FuzzyFinder 19 | EOS 20 | run do |command| 21 | repo=command.opts[:url] 22 | repo=command.opts[:url] 23 | puts "Adding \"#{repo}\" to the plugin list" 24 | bundle_path=repo.gsub(/http.?:\/\/github\.com\//, "") 25 | Vundle::add_plugin_to_vundle repo 26 | Vundle::update_vundle 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /bin/yadr/yadr-vim-delete-plugin: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.join(File.dirname(__FILE__), 'default_libs') 3 | require File.join(File.dirname(__FILE__), 'vundle') 4 | 5 | GitStyleBinary.command do 6 | version "yadr-delete-vim-plugin 1.0" 7 | 8 | short_desc "Removes a vim plugin" 9 | opt :url, "Repository URL (see usage)", :required => true, :type => String 10 | 11 | banner <<-'EOS' 12 | Usage: yadr-delete-vim-plugin --url [URL] 13 | Specify a plugin repository URL in one of the following forms: 14 | - Custom repository URL (full URL): git://git.wincent.com/command-t.git 15 | - Github repository (username/repo_name): robgleesson/hammer.vim.git 16 | - Vim script repository (plugin_name): FuzzyFinder 17 | EOS 18 | run do |command| 19 | repo=command.opts[:url] 20 | puts "Removing \"#{repo}\" from the plugin list" 21 | bundle_path=repo.gsub("https://github.com/", "") 22 | removed=Vundle::remove_plugin_from_vundle repo 23 | if removed 24 | Vundle::update_vundle 25 | puts "Successfully removed\"#{repo}\"" 26 | else 27 | puts "Unable to find \"#{repo}\" among the installed plugins" 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /bin/yadr/yadr-vim-list-plugin: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require File.join(File.dirname(__FILE__), 'default_libs') 3 | require File.join(File.dirname(__FILE__), 'vundle') 4 | 5 | GitStyleBinary.command do 6 | version "yadr-list-vim-plugin 1.0" 7 | 8 | short_desc "List installed vim plugins" 9 | 10 | banner <<-'EOS' 11 | Usage: yadr-list-vim-plugin 12 | EOS 13 | run do |command| 14 | puts "Currently configured plugins:" 15 | i=1 16 | Vundle::vundle_list.each do |plugin| 17 | puts "#{i}. #{plugin}" 18 | i=i+1 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /chrome/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Fix chrome web inspector fonts to be readable. 3 | # http://blog.dotsmart.net/2011/09/30/change-font-size-in-chrome-devtools/ 4 | 5 | # Use: 6 | DIR="$( cd "$( dirname "$0" )" && pwd )" 7 | ln -s -f $DIR/Custom.css $HOME/Library/Application\ Support/Google/Chrome/Default/User\ StyleSheets/Custom.css 8 | -------------------------------------------------------------------------------- /ctags/ctags: -------------------------------------------------------------------------------- 1 | 2 | --langdef=js 3 | --langmap=js:.js 4 | --regex-JavaScript=/([A-Za-z0-9._$\(\)]+)[ \t]*[:=][ \t]*function[ \t]*\(/\1/m,method/ 5 | --regex-JavaScript=/([A-Za-z0-9._$\#\(\)]+)[ \t]*[:][ \t]*([A-Za-z0-9._\-\#\'\"]+)[ \t]*/\1/p,property/ 6 | --regex-JavaScript=/([A-Za-z0-9._$\#\(\)]+)[ \t]*[:][ \t]*([A-Za-z0-9\'\"._\-\#\(]+)[ \t]*\{/\1/p,property/ 7 | --regex-JavaScript=/var ([A-Za-z0-9._$\#]+)[ \t]*[=][ \t]*([A-Za-z0-9._'"\$\#\[\{]+)[,|;]/\1/v,variable/ 8 | --regex-JavaScript=/([A-Za-z0-9._$\#]+)[ \t]*[=][ \t]*([A-Za-z0-9._'"\$\#]+)extend\(/\1/c,class/ 9 | 10 | --regex-ruby=/(^|[:;])[ \t]*([A-Z][[:alnum:]_]+) *=/\2/c,class,constant/ 11 | --regex-ruby=/(^|;)[ \t]*(has_many|belongs_to|has_one|has_and_belongs_to_many)\(? *:([[:alnum:]_]+)/\3/f,function,association/ 12 | --regex-ruby=/(^|;)[ \t]*(named_)?scope\(? *:([[:alnum:]_]+)/\3/f,function,named_scope/ 13 | --regex-ruby=/(^|;)[ \t]*expose\(? *:([[:alnum:]_]+)/\2/f,function,exposure/ 14 | --regex-ruby=/(^|;)[ \t]*event\(? *:([[:alnum:]_]+)/\2/f,function,aasm_event/ 15 | --regex-ruby=/(^|;)[ \t]*event\(? *:([[:alnum:]_]+)/\2!/f,function,aasm_event/ 16 | --regex-ruby=/(^|;)[ \t]*event\(? *:([[:alnum:]_]+)/\2?/f,function,aasm_event/ 17 | 18 | --langdef=markdown 19 | --langmap=markdown:.md.markdown.mdown.mkd.mkdn 20 | --regex-markdown=/^#[ \t]+(.*)/\1/h,heading1/ 21 | --regex-markdown=/^##[ \t]+(.*)/\1/h,heading2/ 22 | --regex-markdown=/^###[ \t]+(.*)/\1/h,heading3/ 23 | 24 | --langdef=coffee 25 | --langmap=coffee:.coffee 26 | --regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=.*->.*$/\1/f,function/ 27 | --regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/v,variable/ 28 | 29 | --langdef=css 30 | --langmap=css:.css 31 | --langmap=css:+.scss 32 | --langmap=css:+.sass 33 | --langmap=css:+.styl 34 | --langmap=css:+.less 35 | --regex-css=/^[ \t]*(([A-Za-z0-9_-]+[ \t\n,]+)+)\{/\1/t,tag,tags/ 36 | --regex-css=/^[ \t]*#([A-Za-z0-9_-]+)/#\1/i,id,ids/ 37 | --regex-css=/^[ \t]*\.([A-Za-z0-9_-]+)/.\1/c,class,classes/ 38 | 39 | --langdef=less 40 | --langmap=less:.less 41 | --regex-less=/^[ t]*.([A-Za-z0-9_-]+)/1/c,class,classes/ 42 | --regex-less=/^[ t]*#([A-Za-z0-9_-]+)/1/i,id,ids/ 43 | --regex-less=/^[ t]*(([A-Za-z0-9_-]+[ tn,]+)+){/1/t,tag,tags/ 44 | --regex-less=/^[ t]*@medias+([A-Za-z0-9_-]+)/1/m,media,medias/ 45 | -------------------------------------------------------------------------------- /doc/credits.md: -------------------------------------------------------------------------------- 1 | I can't take credit for all of this. The vim files are a combination of 2 | work by tpope, scrooloose, and many hours of scouring blogs, vimscripts, 3 | and other places for the cream of the crop of vim awesomeness. 4 | 5 | * http://ethanschoonover.com/solarized - a scientifically calibrated color scheme 6 | * https://github.com/astrails/dotvim 7 | * https://github.com/carlhuda/janus 8 | * https://github.com/tpope 9 | * https://github.com/scrooloose 10 | * https://github.com/kana 11 | * https://github.com/sorin-ionescu 12 | * https://github.com/nelstrom 13 | 14 | And everything that's in the modules included in vim/bundle of course. 15 | Please explore these people's work. 16 | 17 | 18 | ### Contributors 19 | 20 | Yadr is made possible by many awesome people, too many to list :) But here are a few of the bigger contributors and core committers. 21 | 22 | * Initial Version: @[skwp](https://github.com/skwp) 23 | * Cleanup, auto installer: @[kylewest](https://github.com/kylewest) 24 | * Switch from oh-my-zsh to Presto: @[JeanMertz](https://github.com/JeanMertz) 25 | * Vundle migration: @[duhanebel](https://github.com/duhanebel) 26 | * Docker support: @[lfilho](https://github.com/lfilho) 27 | -------------------------------------------------------------------------------- /doc/macos_tools.md: -------------------------------------------------------------------------------- 1 | ## Recommended OSX Tools 2 | 3 | * NValt - Notational Velocity alternative fork - http://brettterpstra.com/project/nvalt/ - syncs with SimpleNote 4 | * Vimium for Chrome - vim style browsing. The `f` to type the two char alias of any link is worth it. 5 | * QuickCursor - gives you Apple-Shift-E to edit any macOS text field in vim. 6 | -------------------------------------------------------------------------------- /doc/pry.md: -------------------------------------------------------------------------------- 1 | ### Install the gem 2 | 3 | ```bash 4 | gem install jazz_hands 5 | ``` 6 | 7 | [Jazz hands](https://github.com/nixme/jazz_hands) is a nice bundling of all pry-related gems. 8 | 9 | ### Use pry 10 | 11 | * as irb: `pry` 12 | * as rails console: `script/console --irb=pry` 13 | * as a debugger: `require 'pry'; binding.pry` in your code (or just type `pry!` to make vim do it) 14 | 15 | ### Pry Customizations: 16 | 17 | * `clear` command to clear screen 18 | * `sql` command to execute something (within a rails console) 19 | * `c` (continue) `n` (next) `s` (step) commands for debugging using pry-nav 20 | * all objects displayed in readable format (colorized, sorted hash keys) - via awesome_print 21 | * a few color modifications to make it more useable 22 | * type `help` to see all the commands 23 | -------------------------------------------------------------------------------- /doc/vim/coding.md: -------------------------------------------------------------------------------- 1 | * tComment - gcc to comment a line, gcp to comment blocks, nuff said 2 | * rails.vim - syntax highlighting, gf (goto file) enhancements, and lots more. should be required for any rails dev 3 | * rake.vim - like rails.vim but for non-rails projects. makes `:Rtags` and other commands just work 4 | * ruby.vim - lots of general enhancements for ruby dev 5 | * necomplcache - intelligent and fast complete as you type, and added Command-Space to select a completion (same as Ctrl-N) 6 | * snipMate - offers textmate-like snippet expansion + snippets collection (honza/vim-snippets). Try hitting TAB after typing a snippet 7 | * jasmine.vim - support for jasmine javascript unit testing, including snippets for it, before, etc.. 8 | * vim-javascript-syntax, vim-jquery - better highlighting 9 | * TagHighlight - highlights class names and method names 10 | * vim-coffeescript - support for coffeescript, highlighting 11 | * vim-stylus - support for stylus css language 12 | * vim-bundler - work with bundled gems 13 | * fugitive - "a git wrapper so awesome, it should be illegal...". Try `:Gstatus` and hit `-` to toggle files in and out of the index. Git `d` to see a diff. Use `git mergetool` or `gmt` to launch vim as a mergetool. The left buffer is your branch, the right is the incoming change, and in the middle is the working copy. Move to the left or right and use `dp` to put the change into the middle. Learn more: http://vimcasts.org/blog/2011/05/the-fugitive-series/ 14 | * gitv - use `:gitv` for a better git log browser 15 | -------------------------------------------------------------------------------- /doc/vim/enhancements.md: -------------------------------------------------------------------------------- 1 | * IndexedSearch - when you do searches will show you "Match 2 of 4" in the status line 2 | * delimitMate - automatically closes quotes 3 | * SearchComplete - tab completion in the / search window 4 | * syntastic - automatic syntax checking when you save the file 5 | * repeat - adds `.` (repeat command) support for complex commands like surround.vim. i.e. if you perform a surround and hit `.`, it will Just Work (vim by default will only repeat the last piece of the complex command) 6 | * endwise - automatically closes blocks (if/end) 7 | * autotag - automatically creates tags for fast sourcecode browsing. use `,f` over a symbol name to go to its definition 8 | * matchit - helps with matching brackets, improves other plugins 9 | * AnsiEsc - inteprets ansi color codes inside log files. great for looking at Rails logs 10 | * solarized - a color scheme scientifically calibrated for awesomeness (including skwp mods for ShowMarks) 11 | * Lightline - Improved status bar. Requires patched fonts (installed from fonts/ directory) 12 | -------------------------------------------------------------------------------- /doc/vim/keymaps.md: -------------------------------------------------------------------------------- 1 | The files in `vim/settings` are customizations stored on a per-plugin 2 | basis. The main keymap is available in yadr-keymap.vim, but some of the vim 3 | files contain key mappings as well. 4 | 5 | If you are having unexpected behavior, wondering why a particular key works the way it does, 6 | use: `:map [keycombo]` (e.g. `:map `) to see what the key is mapped to. For bonus points, you can see where the mapping was set by using `:verbose map [keycombo]`. 7 | If you omit the key combo, you'll get a list of all the maps. You can do the same thing with nmap, imap, vmap, etc. 8 | -------------------------------------------------------------------------------- /doc/vim/manage_plugins.md: -------------------------------------------------------------------------------- 1 | YADR comes with a dead simple plugin manager that just uses vundles and submodules, without any fancy config files. 2 | 3 | Add a plugin 4 | 5 | yav -u https://github.com/airblade/vim-rooter 6 | 7 | Delete a plugin 8 | 9 | ydv -u airblade/vim-rooter 10 | 11 | The aliases (yav=yadr vim-add-plugin), (ydp=yadr vim-delete-plugin) and (yuv=yadr vim-update-all-plugins) live in the aliases file. 12 | You can then commit the change. It's good to have your own fork of this project to do that. 13 | -------------------------------------------------------------------------------- /doc/vim/navigation.md: -------------------------------------------------------------------------------- 1 | * NERDTree - everyone's favorite tree browser 2 | * NERDTree-tabs - makes NERDTree play nice with MacVim tabs so that it's on every tab 3 | * ShowMarks - creates a visual gutter to the left of the number column showing you your marks 4 | * EasyMotion - hit , esc (forward) or , Shift Esc (back) and watch the magic happen. Just type the letters and jump directly to your target - in the provided vimrc the keys are optimized for home row mostly. Using @skwp modified EasyMotion which uses vimperator-style two character targets. 5 | * CtrlP - , t to find a file 6 | * Visual-star-search - make the * (star) search in visual mode behave like expected: searching for the whole selection instead of just the word under the cursor. 7 | * Ag - super fast search by Silver Searcher. hit ,K to grep current word 8 | * vim-tmux-navigator - nagivate between vim and tmux splits in the same way you move between normal vim splits. 9 | -------------------------------------------------------------------------------- /doc/vim/override.md: -------------------------------------------------------------------------------- 1 | You may use `~/.vimrc.before` for settings like the __leader__ setting. 2 | You may use `~/.vimrc.after` (for those transitioning from janus) or `~/.yadr/vim/after/.vimrc.after` for any additional overrides/settings. 3 | If you didn't have janus before, it is recommended to just put it in `~/.yadr/vim/after` so you can better manage your overrides. 4 | -------------------------------------------------------------------------------- /doc/vim/textobjects.md: -------------------------------------------------------------------------------- 1 | * textobj-rubyblock - ruby blocks become vim textobjects denoted with `r`. try var/vir to select a ruby block, dar/dir for delete car/cir for change, =ar/=ir for formatting, etc 2 | * vim-indentobject - manipulate chunks of code by indentation level (great for yaml) use vai/vii to select around an indent block, same as above applies 3 | * argtextobj - manipulation of function arguments as an "a" object, so vaa/via, caa/cia, daa/dia, etc.. 4 | * textobj-datetime - gives you `da` (date), `df` (date full) and so on text objects. useable with all standard verbs 5 | * vim-textobj-entire - gives you `e` for entire document. so vae (visual around entire document), and etc 6 | * vim-textobj-rubysymbol - gives you `:` textobj. so va: to select a ruby symbol. da: to delete a symbol..etc 7 | * vim-textobj-function - gives you `f` textobj. so vaf to select a function 8 | * vim-textobj-function-javascript - same as above, but for javascript functions 9 | * vim-textobj-underscore - gives you `_` textobj. So vi_ selects what's inside a pair of underscores 10 | * next-textobject - from Steve Losh, ability to use `n` such as vinb (visual inside (n)ext set of parens) 11 | * textobj-word-column - gives you `c` (word) and `C` (WORD) for handling columns/blocks. 12 | -------------------------------------------------------------------------------- /doc/vim/utils.md: -------------------------------------------------------------------------------- 1 | * SplitJoin - easily split up things like ruby hashes into multiple lines or join them back together. Try :SplitjoinJoin and :SplitjoinSplit or use the bindings sj(split) and sk(unsplit) - mnemonically j and k are directions down and up 2 | * tabularize - align code effortlessly by using :Tabularize /[character] to align by a character, or try the keymaps 3 | * yankring - effortless sanity for pasting. every time you yank something it goes into a buffer. after hitting p to paste, use ctrl-p or ctrl-n to cycle through the paste options. great for when you accidentally overwrite your yank with a delete. 4 | * surround - super easy quote and tag manipulation - ysiw" - sourround inner word with quotes. ci"' - change inner double quotes to single quotes, etc 5 | * greplace - use :Gsearch to find across many files, replace inside the changes, then :Greplace to do a replace across all matches - made lightning fast with Silver Searcher 6 | * vim-markdown-preview - :Mm to view your README.md as html 7 | * html-escape - ,he and ,hu to escape and unescape html 8 | * Gundo - visualize your undos - pretty amazing plugin. Hit ,u with my keymappings to trigger it, very user friendly 9 | * vim-indent-guides - visual indent guides, off by default 10 | * color_highlight - use :ColorCodes to see hex colors highlighted 11 | * change-inside-surroundings - change content inside delimiters like quotes/brackets 12 | * rspec.vim - used for color highlighting rspec correctly even if specs live outside of spec/ (rails.vim doesn't handle this) 13 | * Ag - use :Ag to search across multiple files. Faster than Grep and Ack. 14 | * vim-session: use `:SaveSession` and `:OpenSession` to come back to your saved window layout 15 | -------------------------------------------------------------------------------- /doc/zsh/themes.md: -------------------------------------------------------------------------------- 1 | ### Adding your own ZSH theme 2 | 3 | If you want to add your own zsh theme, you can place it in `~/.zsh.prompts` and it will automatically be picked up by the prompt loader. 4 | 5 | Make sure you follow the naming convention of `prompt_[name]_setup` 6 | 7 | ``` 8 | touch ~/.zsh.prompts/prompt_mytheme_setup 9 | ``` 10 | 11 | See also the [Prezto](https://github.com/sorin-ionescu/prezto) project for more info on themes. 12 | 13 | ### Customizing ZSH with ~/.zsh.after/ and ~/.zsh.before/ 14 | 15 | If you want to customize your zsh experience, yadr provides two hooks via `~/.zsh.after/` and `~/.zsh.before/` directories. 16 | In these directories, you can place files to customize things that load before and after other zsh customizations that come from `~/.yadr/zsh/*` 17 | 18 | 19 | ### Overriding the theme 20 | 21 | To override the theme, you can do something like this: 22 | 23 | ``` 24 | echo "prompt yourprompt" > ~/.zsh.after/prompt.zsh 25 | ``` 26 | 27 | Next time you load your shell, this file will be read and your prompt will be the youprompt prompt. Use `prompt -l` to see the available prompts. 28 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | dotfiles: 4 | build: 5 | context: . 6 | image: yadr 7 | volumes: 8 | - ./:/root/.yadr/ 9 | -------------------------------------------------------------------------------- /fonts/Inconsolata XL Bold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skwp/dotfiles/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/fonts/Inconsolata XL Bold.otf -------------------------------------------------------------------------------- /fonts/Inconsolata XL.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skwp/dotfiles/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/fonts/Inconsolata XL.otf -------------------------------------------------------------------------------- /fonts/Inconsolata-dz-Powerline.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skwp/dotfiles/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/fonts/Inconsolata-dz-Powerline.otf -------------------------------------------------------------------------------- /fonts/Menlo-Powerline.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skwp/dotfiles/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/fonts/Menlo-Powerline.otf -------------------------------------------------------------------------------- /fonts/mensch-Powerline.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skwp/dotfiles/9e3425d11dcde7706fbeabc3e9c3f7a7bdc63e23/fonts/mensch-Powerline.otf -------------------------------------------------------------------------------- /git/gitconfig: -------------------------------------------------------------------------------- 1 | # set your user tokens as environment variables, such as ~/.secrets 2 | # See the README for examples. 3 | [color] 4 | ui = true 5 | [color "branch"] 6 | current = yellow reverse 7 | local = yellow 8 | remote = green 9 | [color "diff"] 10 | meta = yellow bold 11 | frag = magenta bold 12 | old = red 13 | new = green 14 | [alias] 15 | # add 16 | a = add # add 17 | chunkyadd = add --patch # stage commits chunk by chunk 18 | # Shows list of contributors of a repository. 19 | contributors = shortlog --summary --numbered --email 20 | 21 | # via http://philjackson.github.io/2013/04/07/handy-git-tips-to-stop-you-getting-fired.html 22 | snapshot = !git stash save "snapshot: $(date)" && git stash apply "stash@{0}" 23 | snapshots = !git stash list --grep snapshot 24 | 25 | #via http://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit 26 | recent-branches = !git for-each-ref --count=15 --sort=-committerdate refs/heads/ --format='%(refname:short)' 27 | 28 | # branch 29 | b = branch -v # branch (verbose) 30 | 31 | # commit 32 | c = commit -m # commit with message 33 | ca = commit -am # commit all with message 34 | ci = commit # commit 35 | amend = commit --amend # ammend your last commit 36 | ammend = commit --amend # ammend your last commit 37 | 38 | # checkout 39 | co = checkout # checkout 40 | nb = checkout -b # create and switch to a new branch (mnemonic: "git new branch branchname...") 41 | 42 | # cherry-pick 43 | cp = cherry-pick -x # grab a change from a branch 44 | 45 | # diff 46 | d = diff # diff unstaged changes 47 | dc = diff --cached # diff staged changes 48 | last = diff HEAD^ # diff last committed change 49 | 50 | # log 51 | l = log --graph --date=short 52 | changes = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\" --name-status 53 | short = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\" 54 | simple = log --pretty=format:\" * %s\" 55 | shortnocolor = log --pretty=format:\"%h %cr %cn %s\" 56 | 57 | # pull 58 | pl = pull # pull 59 | 60 | # push 61 | ps = push # push 62 | 63 | # rebase 64 | rc = rebase --continue # continue rebase 65 | rs = rebase --skip # skip rebase 66 | 67 | # remote 68 | r = remote -v # show remotes (verbose) 69 | 70 | # reset 71 | unstage = reset HEAD # remove files from index (tracking) 72 | uncommit = reset --soft HEAD^ # go back before last commit, with files in uncommitted state 73 | filelog = log -u # show changes to a file 74 | mt = mergetool # fire up the merge tool 75 | 76 | # stash 77 | ss = stash # stash changes 78 | sl = stash list # list stashes 79 | sa = stash apply # apply stash (restore changes) 80 | sd = stash drop # drop stashes (destory changes) 81 | 82 | # status 83 | s = status # status 84 | st = status # status 85 | stat = status # status 86 | 87 | # tag 88 | t = tag -n # show tags with lines of each tag message 89 | 90 | # svn helpers 91 | svnr = svn rebase 92 | svnd = svn dcommit 93 | svnl = svn log --oneline --show-commit 94 | [format] 95 | pretty = format:%C(blue)%ad%Creset %C(yellow)%h%C(green)%d%Creset %C(blue)%s %C(magenta) [%an]%Creset 96 | [mergetool] 97 | prompt = false 98 | [mergetool "mvimdiff"] 99 | cmd="mvim -c 'Gdiff' $MERGED" # use fugitive.vim for 3-way merge 100 | keepbackup=false 101 | [merge] 102 | summary = true 103 | verbosity = 1 104 | tool = mvimdiff 105 | [apply] 106 | whitespace = nowarn 107 | [branch] 108 | autosetupmerge = true 109 | [push] 110 | # 'git push' will push the current branch to its tracking branch 111 | # the usual default is to push all branches 112 | default = upstream 113 | [core] 114 | autocrlf = false 115 | editor = vim 116 | excludesfile = ~/.yadr/git/gitignore 117 | [advice] 118 | statusHints = false 119 | [diff] 120 | # Git diff will use (i)ndex, (w)ork tree, (c)ommit and (o)bject 121 | # instead of a/b/c/d as prefixes for patches 122 | mnemonicprefix = true 123 | algorithm = patience 124 | [rerere] 125 | # Remember my merges 126 | # http://gitfu.wordpress.com/2008/04/20/git-rerere-rereremember-what-you-did-last-time/ 127 | enabled = true 128 | [include] 129 | path = .gitconfig.user 130 | -------------------------------------------------------------------------------- /git/gitignore: -------------------------------------------------------------------------------- 1 | # OSX taken from: https://github.com/github/gitignore/blob/master/Global/OSX.gitignore 2 | # ---------------------------------------------------------------------------------------------- 3 | .DS_Store 4 | # Thumbnails 5 | ._* 6 | # Files that might appear on external disk 7 | .Spotlight-V100 8 | .Trashes 9 | 10 | # Windows taken from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore 11 | # ---------------------------------------------------------------------------------------------- 12 | # Windows image file caches 13 | Thumbs.db 14 | 15 | # Folder config file 16 | Desktop.ini 17 | 18 | # Tags taken from: https://github.com/github/gitignore/blob/master/Global/Tags.gitignore 19 | # ---------------------------------------------------------------------------------------------- 20 | # Ignore tags created by etags, ctags, gtags (GNU global) and cscope 21 | TAGS 22 | !TAGS/ 23 | tags 24 | !tags/ 25 | .tags 26 | .tags1 27 | gtags.files 28 | GTAGS 29 | GRTAGS 30 | GPATH 31 | cscope.files 32 | cscope.out 33 | cscope.in.out 34 | cscope.po.out 35 | 36 | # Vim taken from: https://github.com/github/gitignore/blob/master/Global/vim.gitignore 37 | # ---------------------------------------------------------------------------------------------- 38 | [._]*.s[a-w][a-z] 39 | [._]s[a-w][a-z] 40 | *.un~ 41 | Session.vim 42 | .netrwhist 43 | *~ 44 | 45 | # SASS 46 | # ---------------------------------------------------------------------------------------------- 47 | .sass-cache 48 | -------------------------------------------------------------------------------- /iTerm2/Solarized Dark.itermcolors: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ansi 0 Color 6 | 7 | Blue Component 8 | 0.19370138645172119 9 | Green Component 10 | 0.15575926005840302 11 | Red Component 12 | 0.0 13 | 14 | Ansi 1 Color 15 | 16 | Blue Component 17 | 0.14145714044570923 18 | Green Component 19 | 0.10840655118227005 20 | Red Component 21 | 0.81926977634429932 22 | 23 | Ansi 10 Color 24 | 25 | Blue Component 26 | 0.38298487663269043 27 | Green Component 28 | 0.35665956139564514 29 | Red Component 30 | 0.27671992778778076 31 | 32 | Ansi 11 Color 33 | 34 | Blue Component 35 | 0.43850564956665039 36 | Green Component 37 | 0.40717673301696777 38 | Red Component 39 | 0.32436618208885193 40 | 41 | Ansi 12 Color 42 | 43 | Blue Component 44 | 0.51685798168182373 45 | Green Component 46 | 0.50962930917739868 47 | Red Component 48 | 0.44058024883270264 49 | 50 | Ansi 13 Color 51 | 52 | Blue Component 53 | 0.72908437252044678 54 | Green Component 55 | 0.33896297216415405 56 | Red Component 57 | 0.34798634052276611 58 | 59 | Ansi 14 Color 60 | 61 | Blue Component 62 | 0.56363654136657715 63 | Green Component 64 | 0.56485837697982788 65 | Red Component 66 | 0.50599193572998047 67 | 68 | Ansi 15 Color 69 | 70 | Blue Component 71 | 0.86405980587005615 72 | Green Component 73 | 0.95794391632080078 74 | Red Component 75 | 0.98943418264389038 76 | 77 | Ansi 2 Color 78 | 79 | Blue Component 80 | 0.020208755508065224 81 | Green Component 82 | 0.54115492105484009 83 | Red Component 84 | 0.44977453351020813 85 | 86 | Ansi 3 Color 87 | 88 | Blue Component 89 | 0.023484811186790466 90 | Green Component 91 | 0.46751424670219421 92 | Red Component 93 | 0.64746475219726562 94 | 95 | Ansi 4 Color 96 | 97 | Blue Component 98 | 0.78231418132781982 99 | Green Component 100 | 0.46265947818756104 101 | Red Component 102 | 0.12754884362220764 103 | 104 | Ansi 5 Color 105 | 106 | Blue Component 107 | 0.43516635894775391 108 | Green Component 109 | 0.10802463442087173 110 | Red Component 111 | 0.77738940715789795 112 | 113 | Ansi 6 Color 114 | 115 | Blue Component 116 | 0.52502274513244629 117 | Green Component 118 | 0.57082360982894897 119 | Red Component 120 | 0.14679534733295441 121 | 122 | Ansi 7 Color 123 | 124 | Blue Component 125 | 0.79781103134155273 126 | Green Component 127 | 0.89001238346099854 128 | Red Component 129 | 0.91611063480377197 130 | 131 | Ansi 8 Color 132 | 133 | Blue Component 134 | 0.15170273184776306 135 | Green Component 136 | 0.11783610284328461 137 | Red Component 138 | 0.0 139 | 140 | Ansi 9 Color 141 | 142 | Blue Component 143 | 0.073530435562133789 144 | Green Component 145 | 0.21325300633907318 146 | Red Component 147 | 0.74176257848739624 148 | 149 | Background Color 150 | 151 | Blue Component 152 | 0.15170273184776306 153 | Green Component 154 | 0.11783610284328461 155 | Red Component 156 | 0.0 157 | 158 | Bold Color 159 | 160 | Blue Component 161 | 0.56363654136657715 162 | Green Component 163 | 0.56485837697982788 164 | Red Component 165 | 0.50599193572998047 166 | 167 | Cursor Color 168 | 169 | Blue Component 170 | 0.51685798168182373 171 | Green Component 172 | 0.50962930917739868 173 | Red Component 174 | 0.44058024883270264 175 | 176 | Cursor Text Color 177 | 178 | Blue Component 179 | 0.19370138645172119 180 | Green Component 181 | 0.15575926005840302 182 | Red Component 183 | 0.0 184 | 185 | Foreground Color 186 | 187 | Blue Component 188 | 0.51685798168182373 189 | Green Component 190 | 0.50962930917739868 191 | Red Component 192 | 0.44058024883270264 193 | 194 | Selected Text Color 195 | 196 | Blue Component 197 | 0.56363654136657715 198 | Green Component 199 | 0.56485837697982788 200 | Red Component 201 | 0.50599193572998047 202 | 203 | Selection Color 204 | 205 | Blue Component 206 | 0.19370138645172119 207 | Green Component 208 | 0.15575926005840302 209 | Red Component 210 | 0.0 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /iTerm2/Solarized Light.itermcolors: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ansi 0 Color 6 | 7 | Blue Component 8 | 0.19370138645172119 9 | Green Component 10 | 0.15575926005840302 11 | Red Component 12 | 0.0 13 | 14 | Ansi 1 Color 15 | 16 | Blue Component 17 | 0.14145712554454803 18 | Green Component 19 | 0.10840645432472229 20 | Red Component 21 | 0.81926983594894409 22 | 23 | Ansi 10 Color 24 | 25 | Blue Component 26 | 0.38298487663269043 27 | Green Component 28 | 0.35665956139564514 29 | Red Component 30 | 0.27671992778778076 31 | 32 | Ansi 11 Color 33 | 34 | Blue Component 35 | 0.43850564956665039 36 | Green Component 37 | 0.40717673301696777 38 | Red Component 39 | 0.32436618208885193 40 | 41 | Ansi 12 Color 42 | 43 | Blue Component 44 | 0.51685798168182373 45 | Green Component 46 | 0.50962930917739868 47 | Red Component 48 | 0.44058024883270264 49 | 50 | Ansi 13 Color 51 | 52 | Blue Component 53 | 0.72908437252044678 54 | Green Component 55 | 0.33896297216415405 56 | Red Component 57 | 0.34798634052276611 58 | 59 | Ansi 14 Color 60 | 61 | Blue Component 62 | 0.56363654136657715 63 | Green Component 64 | 0.56485837697982788 65 | Red Component 66 | 0.50599193572998047 67 | 68 | Ansi 15 Color 69 | 70 | Blue Component 71 | 0.86405980587005615 72 | Green Component 73 | 0.95794391632080078 74 | Red Component 75 | 0.98943418264389038 76 | 77 | Ansi 2 Color 78 | 79 | Blue Component 80 | 0.020208755508065224 81 | Green Component 82 | 0.54115492105484009 83 | Red Component 84 | 0.44977453351020813 85 | 86 | Ansi 3 Color 87 | 88 | Blue Component 89 | 0.023484811186790466 90 | Green Component 91 | 0.46751424670219421 92 | Red Component 93 | 0.64746475219726562 94 | 95 | Ansi 4 Color 96 | 97 | Blue Component 98 | 0.78231418132781982 99 | Green Component 100 | 0.46265947818756104 101 | Red Component 102 | 0.12754884362220764 103 | 104 | Ansi 5 Color 105 | 106 | Blue Component 107 | 0.43516635894775391 108 | Green Component 109 | 0.10802463442087173 110 | Red Component 111 | 0.77738940715789795 112 | 113 | Ansi 6 Color 114 | 115 | Blue Component 116 | 0.52502274513244629 117 | Green Component 118 | 0.57082360982894897 119 | Red Component 120 | 0.14679534733295441 121 | 122 | Ansi 7 Color 123 | 124 | Blue Component 125 | 0.79781103134155273 126 | Green Component 127 | 0.89001238346099854 128 | Red Component 129 | 0.91611063480377197 130 | 131 | Ansi 8 Color 132 | 133 | Blue Component 134 | 0.15170273184776306 135 | Green Component 136 | 0.11783610284328461 137 | Red Component 138 | 0.0 139 | 140 | Ansi 9 Color 141 | 142 | Blue Component 143 | 0.073530435562133789 144 | Green Component 145 | 0.21325300633907318 146 | Red Component 147 | 0.74176257848739624 148 | 149 | Background Color 150 | 151 | Blue Component 152 | 0.86405980587005615 153 | Green Component 154 | 0.95794391632080078 155 | Red Component 156 | 0.98943418264389038 157 | 158 | Bold Color 159 | 160 | Blue Component 161 | 0.38298487663269043 162 | Green Component 163 | 0.35665956139564514 164 | Red Component 165 | 0.27671992778778076 166 | 167 | Cursor Color 168 | 169 | Blue Component 170 | 0.43850564956665039 171 | Green Component 172 | 0.40717673301696777 173 | Red Component 174 | 0.32436618208885193 175 | 176 | Cursor Text Color 177 | 178 | Blue Component 179 | 0.79781103134155273 180 | Green Component 181 | 0.89001238346099854 182 | Red Component 183 | 0.91611063480377197 184 | 185 | Foreground Color 186 | 187 | Blue Component 188 | 0.43850564956665039 189 | Green Component 190 | 0.40717673301696777 191 | Red Component 192 | 0.32436618208885193 193 | 194 | Selected Text Color 195 | 196 | Blue Component 197 | 0.38298487663269043 198 | Green Component 199 | 0.35665956139564514 200 | Red Component 201 | 0.27671992778778076 202 | 203 | Selection Color 204 | 205 | Blue Component 206 | 0.79781103134155273 207 | Green Component 208 | 0.89001238346099854 209 | Red Component 210 | 0.91611063480377197 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! -d "$HOME/.yadr" ]; then 4 | echo "Installing YADR for the first time" 5 | git clone --depth=1 https://github.com/skwp/dotfiles.git "$HOME/.yadr" 6 | cd "$HOME/.yadr" 7 | [ "$1" = "ask" ] && export ASK="true" 8 | rake install 9 | else 10 | echo "YADR is already installed" 11 | fi 12 | -------------------------------------------------------------------------------- /irb/pryrc: -------------------------------------------------------------------------------- 1 | # == JazzFingers === 2 | # jazz_fingers gem: great syntax colorized printing 3 | begin 4 | require 'jazz_fingers' 5 | # The following line enables awesome_print for all pry output, 6 | # and it also enables paging 7 | 8 | JazzFingers.configure do |config| 9 | config.colored_prompt = true 10 | config.amazing_print = true 11 | config.coolline = false 12 | config.application_name = MyAwesomeProject 13 | end 14 | rescue LoadError => error 15 | puts "gem install jazz_fingers # <-- highly recommended" 16 | end 17 | -------------------------------------------------------------------------------- /ruby/gemrc: -------------------------------------------------------------------------------- 1 | --- 2 | :update_sources: true 3 | :sources: 4 | - http://rubygems.org 5 | :benchmark: false 6 | :backtrace: false 7 | :verbose: true 8 | gem: --no-document 9 | -------------------------------------------------------------------------------- /ruby/rdebugrc: -------------------------------------------------------------------------------- 1 | set autolist 2 | set autoeval 3 | set autoreload 4 | set forcestep 5 | -------------------------------------------------------------------------------- /tmux/tmux.conf: -------------------------------------------------------------------------------- 1 | # Ring the bell if any background window rang a bell 2 | set -g bell-action any 3 | 4 | # Default termtype. If the rcfile sets $TERM, that overrides this value. 5 | set -g default-terminal screen-256color 6 | 7 | # Keep your finger on ctrl, or don't 8 | bind-key ^D detach-client 9 | 10 | # Create splits and vertical splits 11 | bind-key v split-window -h -p 50 -c "#{pane_current_path}" 12 | bind-key ^V split-window -h -p 50 -c "#{pane_current_path}" 13 | bind-key s split-window -p 50 -c "#{pane_current_path}" 14 | bind-key ^S split-window -p 50 -c "#{pane_current_path}" 15 | 16 | # Pane resize in all four directions using vi bindings. 17 | # Can use these raw but I map them to shift-ctrl- in iTerm. 18 | bind -r H resize-pane -L 5 19 | bind -r J resize-pane -D 5 20 | bind -r K resize-pane -U 5 21 | bind -r L resize-pane -R 5 22 | 23 | # Smart pane switching with awareness of Vim splits. 24 | # See: https://github.com/christoomey/vim-tmux-navigator 25 | is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ 26 | | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" 27 | bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L' 28 | bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D' 29 | bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U' 30 | bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R' 31 | 32 | tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")' 33 | if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \ 34 | "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'" 35 | if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \ 36 | "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'" 37 | 38 | bind-key -T copy-mode-vi 'C-h' select-pane -L 39 | bind-key -T copy-mode-vi 'C-j' select-pane -D 40 | bind-key -T copy-mode-vi 'C-k' select-pane -U 41 | bind-key -T copy-mode-vi 'C-l' select-pane -R 42 | bind-key -T copy-mode-vi 'C-\' select-pane -l 43 | 44 | # Use vi keybindings for tmux commandline input. 45 | # Note that to get command mode you need to hit ESC twice... 46 | set -g status-keys vi 47 | 48 | # Use vi keybindings in copy and choice modes 49 | setw -g mode-keys vi 50 | 51 | # easily toggle synchronization (mnemonic: e is for echo) 52 | # sends input to all panes in a given window. 53 | bind e setw synchronize-panes on 54 | bind E setw synchronize-panes off 55 | 56 | # set first window to index 1 (not 0) to map more to the keyboard layout... 57 | set-option -g base-index 1 58 | set-window-option -g pane-base-index 1 59 | set-window-option -g mouse on 60 | 61 | # color scheme (styled as vim-powerline) 62 | set -g status-left-length 52 63 | set -g status-right-length 451 64 | set -g status-style fg=white,bg=colour234 65 | set -g pane-border-style fg=colour245 66 | set -g pane-active-border-style fg=colour39 67 | set -g message-style fg=colour16,bg=colour221,bold 68 | set -g status-left '#[fg=colour235,bg=colour252,bold] ❐ #S #[fg=colour252,bg=colour238,nobold]⮀#[fg=colour245,bg=colour238,bold] #(whoami) #[fg=colour238,bg=colour234,nobold]⮀' 69 | set -g window-status-format '#[fg=colour235,bg=colour252,bold] #I #(pwd="#{pane_current_path}"; echo ${pwd####*/}) #W ' 70 | set -g window-status-current-format '#[fg=colour234,bg=colour39]⮀#[fg=black,bg=colour39,noreverse,bold] #{?window_zoomed_flag,#[fg=colour228],} #I #(pwd="#{pane_current_path}"; echo ${pwd####*/}) #W #[fg=colour39,bg=colour234,nobold]⮀' 71 | set-option -g status-interval 2 72 | 73 | # Patch for OS X pbpaste and pbcopy under tmux. 74 | set-option -g default-command "which reattach-to-user-namespace > /dev/null && reattach-to-user-namespace -l $SHELL || $SHELL" 75 | 76 | # Screen like binding 77 | unbind C-b 78 | set -g prefix C-a 79 | bind a send-prefix 80 | 81 | # No escape time for vi mode 82 | set -sg escape-time 0 83 | 84 | # Screen like binding for last window 85 | unbind l 86 | bind C-a last-window 87 | 88 | # Bigger history 89 | set -g history-limit 10000 90 | 91 | # New windows/pane in $PWD 92 | bind c new-window -c "#{pane_current_path}" 93 | 94 | # Fix key bindings broken in tmux 2.1 95 | set -g assume-paste-time 0 96 | 97 | # force a reload of the config file 98 | unbind r 99 | bind r source-file ~/.tmux.conf \; display "Reloaded!" 100 | 101 | # Local config 102 | if-shell "[ -f ~/.tmux.conf.user ]" 'source ~/.tmux.conf.user' 103 | -------------------------------------------------------------------------------- /vim/.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | *~ 3 | *.swp 4 | .VimballRecord 5 | view 6 | -------------------------------------------------------------------------------- /vim/after/plugin/vimrc_after.vim: -------------------------------------------------------------------------------- 1 | " This loads after the yadr plugins so that plugin mappings can 2 | " be overwritten. 3 | 4 | if filereadable(expand("~/.yadr/vim/after/.vimrc.after")) 5 | source ~/.yadr/vim/after/.vimrc.after 6 | endif 7 | 8 | if filereadable(expand("~/.vimrc.after")) 9 | source ~/.vimrc.after 10 | endif 11 | -------------------------------------------------------------------------------- /vim/ftplugin/gitcommit.vim: -------------------------------------------------------------------------------- 1 | if exists("b:did_ftplugin") 2 | finish 3 | endif 4 | 5 | let b:did_ftplugin = 1 " Don't load twice in one buffer 6 | 7 | setlocal spell 8 | -------------------------------------------------------------------------------- /vim/settings.vim: -------------------------------------------------------------------------------- 1 | let vimsettings = '~/.vim/settings' 2 | let uname = system("uname -s") 3 | 4 | for fpath in split(globpath(vimsettings, '*.vim'), '\n') 5 | 6 | if (fpath == expand(vimsettings) . "/yadr-keymap-mac.vim") && uname[:4] ==? "linux" 7 | continue " skip mac mappings for linux 8 | endif 9 | 10 | if (fpath == expand(vimsettings) . "/yadr-keymap-linux.vim") && uname[:4] !=? "linux" 11 | continue " skip linux mappings for mac 12 | endif 13 | 14 | exe 'source' fpath 15 | endfor 16 | -------------------------------------------------------------------------------- /vim/settings/NERDtree-tabs.vim: -------------------------------------------------------------------------------- 1 | " Auto open nerd tree on startup 2 | let g:nerdtree_tabs_open_on_gui_startup = 0 3 | " Focus in the main content window 4 | let g:nerdtree_tabs_focus_on_files = 1 5 | -------------------------------------------------------------------------------- /vim/settings/NERDtree.vim: -------------------------------------------------------------------------------- 1 | " Make nerdtree look nice 2 | let NERDTreeMinimalUI = 1 3 | let NERDTreeDirArrows = 1 4 | let g:NERDTreeWinSize = 30 5 | -------------------------------------------------------------------------------- /vim/settings/README.md: -------------------------------------------------------------------------------- 1 | This directory contains settings for various vim plugins and vim itself. 2 | 3 | ## Plugin Settings 4 | 5 | Each plugin's overrides/settings should be put in a separate file named `{plugin-name}.vim`. 6 | 7 | ## Vim Settings 8 | 9 | General vim overrides/settings should be put in a separate file named `yadr-{descriptive-name}.vim`. 10 | -------------------------------------------------------------------------------- /vim/settings/abbr.vim: -------------------------------------------------------------------------------- 1 | "Abbreviations, trigger by typing the abbreviation and hitting space 2 | 3 | abbr rlb Rails.logger.banner 4 | abbr rld Rails.logger.debug 5 | abbr pry! require 'pry'; binding.pry 6 | abbr cl! console.log( ) 7 | 8 | " Rspec Before 9 | abbr rbf before { } 10 | -------------------------------------------------------------------------------- /vim/settings/ag.vim: -------------------------------------------------------------------------------- 1 | " Open the Ag command and place the cursor into the quotes 2 | nmap ,ag :Ag "" 3 | nmap ,af :AgFile "" 4 | -------------------------------------------------------------------------------- /vim/settings/autotag.vim: -------------------------------------------------------------------------------- 1 | " AutoTag 2 | " Seems to have problems with some vim files 3 | let g:autotagExcludeSuffixes="tml.xml.text.txt.vim" 4 | -------------------------------------------------------------------------------- /vim/settings/camelcasemotion.vim: -------------------------------------------------------------------------------- 1 | map W CamelCaseMotion_w 2 | map B CamelCaseMotion_b 3 | map E CamelCaseMotion_e 4 | 5 | sunmap W 6 | sunmap B 7 | sunmap E -------------------------------------------------------------------------------- /vim/settings/ctrlp.vim: -------------------------------------------------------------------------------- 1 | if exists("g:ctrlp_user_command") 2 | unlet g:ctrlp_user_command 3 | endif 4 | if executable('ag') 5 | " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore 6 | let g:ctrlp_user_command = 7 | \ 'ag %s --files-with-matches -g "" --ignore "\.git$\|\.hg$\|\.svn$"' 8 | 9 | " ag is fast enough that CtrlP doesn't need to cache 10 | let g:ctrlp_use_caching = 0 11 | else 12 | " Fall back to using git ls-files if Ag is not available 13 | let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$' 14 | let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others'] 15 | endif 16 | 17 | " Default to filename searches - so that appctrl will find application 18 | " controller 19 | let g:ctrlp_by_filename = 1 20 | 21 | " Don't jump to already open window. This is annoying if you are maintaining 22 | " several Tab workspaces and want to open two windows into the same file. 23 | let g:ctrlp_switch_buffer = 0 24 | 25 | " We don't want to use Ctrl-p as the mapping because 26 | " it interferes with YankRing (paste, then hit ctrl-p) 27 | let g:ctrlp_map = ',t' 28 | nnoremap ,t :CtrlP 29 | 30 | " Additional mapping for buffer search 31 | nnoremap ,b :CtrlPBuffer 32 | 33 | " Cmd-Shift-P to clear the cache 34 | nnoremap :ClearCtrlPCache 35 | 36 | " Idea from : http://www.charlietanksley.net/blog/blog/2011/10/18/vim-navigation-with-lustyexplorer-and-lustyjuggler/ 37 | " Open CtrlP starting from a particular path, making it much 38 | " more likely to find the correct thing first. mnemonic 'jump to [something]' 39 | map ,ja :CtrlP app/assets 40 | map ,jm :CtrlP app/models 41 | map ,jc :CtrlP app/controllers 42 | map ,jv :CtrlP app/views 43 | map ,jj :CtrlP app/assets/javascripts 44 | map ,jh :CtrlP app/helpers 45 | map ,jl :CtrlP lib 46 | map ,jp :CtrlP public 47 | map ,js :CtrlP spec 48 | map ,jf :CtrlP fast_spec 49 | map ,jd :CtrlP db 50 | map ,jC :CtrlP config 51 | map ,jV :CtrlP vendor 52 | map ,jF :CtrlP factories 53 | map ,jT :CtrlP test 54 | 55 | "Cmd-Shift-(M)ethod - jump to a method (tag in current file) 56 | "Ctrl-m is not good - it overrides behavior of Enter 57 | nnoremap :CtrlPBufTag 58 | -------------------------------------------------------------------------------- /vim/settings/easymotion.vim: -------------------------------------------------------------------------------- 1 | " These keys are easier to type than the default set 2 | " We exclude semicolon because it's hard to read and 3 | " i and l are too easy to mistake for each other slowing 4 | " down recognition. The home keys and the immediate keys 5 | " accessible by middle fingers are available 6 | let g:EasyMotion_keys='asdfjkoweriop' 7 | nmap , ,,w 8 | nmap , ,,b 9 | -------------------------------------------------------------------------------- /vim/settings/es6.vim: -------------------------------------------------------------------------------- 1 | " Automatically treat .es6 extension files as javascript 2 | autocmd BufRead,BufNewFile *.es6 setfiletype javascript 3 | -------------------------------------------------------------------------------- /vim/settings/fugitive.vim: -------------------------------------------------------------------------------- 1 | " fugitive.git 2 | " ======================================== 3 | " For fugitive.git, dp means :diffput. Define dg to mean :diffget 4 | nnoremap ,dg :diffget 5 | nnoremap ,dp :diffput 6 | -------------------------------------------------------------------------------- /vim/settings/gh-markdown.vim: -------------------------------------------------------------------------------- 1 | " Support for github flavored markdown 2 | " via https://github.com/jtratner/vim-flavored-markdown 3 | augroup markdown 4 | au! 5 | au BufNewFile,BufRead *.md,*.markdown setlocal filetype=ghmarkdown 6 | augroup END 7 | -------------------------------------------------------------------------------- /vim/settings/gotofile.vim: -------------------------------------------------------------------------------- 1 | " Automatically jump to a file at the correct line number 2 | " i.e. if your cursor is over /some/path.rb:50 then using 'gf' on it will take 3 | " you to that line 4 | 5 | " use ,gf to go to file in a vertical split 6 | nnoremap ,gf :vertical botright wincmd F 7 | -------------------------------------------------------------------------------- /vim/settings/grep.vim: -------------------------------------------------------------------------------- 1 | "Use the silver searcher for lightning fast Gsearch command 2 | set grepprg=git\ grep 3 | let g:grep_cmd_opts = '--line-number' 4 | -------------------------------------------------------------------------------- /vim/settings/gundo.vim: -------------------------------------------------------------------------------- 1 | nmap ,u :GundoToggle 2 | 3 | " open on the right so as not to compete with the nerdtree 4 | let g:gundo_right = 1 5 | 6 | " a little wider for wider screens 7 | let g:gundo_width = 60 8 | -------------------------------------------------------------------------------- /vim/settings/iterm-rspec.vim: -------------------------------------------------------------------------------- 1 | nnoremap ,rs :RunItermSpec 2 | nnoremap ,rl :RunItermSpecLine 3 | nnoremap ,ss :RunItermSpringSpec 4 | nnoremap ,sl :RunItermSpringSpecLine 5 | nnoremap zl :RunItermZeusSpecLine 6 | nnoremap zs :RunItermZeusSpec 7 | -------------------------------------------------------------------------------- /vim/settings/lightline.vim: -------------------------------------------------------------------------------- 1 | let g:lightline = { 2 | \ 'colorscheme': 'solarized', 3 | \ 'active': { 4 | \ 'left': [ [ 'mode', 'paste' ], 5 | \ [ 'fugitive', 'readonly', 'filename', 'modified' ] ] 6 | \ }, 7 | \ 'component_function': { 8 | \ 'fugitive': 'MyFugitive', 9 | \ 'readonly': 'MyReadonly', 10 | \ 'filename': 'MyFilename', 11 | \ }, 12 | \ 'separator': { 'left': '⮀', 'right': '⮂' }, 13 | \ 'subseparator': { 'left': '⮁', 'right': '⮃' } 14 | \ } 15 | 16 | function! MyReadonly() 17 | if &filetype == "help" 18 | return "" 19 | elseif &readonly 20 | return "⭤ " 21 | else 22 | return "" 23 | endif 24 | endfunction 25 | 26 | function! MyFugitive() 27 | if exists("*fugitive#head") 28 | let _ = fugitive#head() 29 | return strlen(_) ? '⭠ '._ : '' 30 | endif 31 | return '' 32 | endfunction 33 | 34 | function! MyFilename() 35 | return ('' != MyReadonly() ? MyReadonly() . ' ' : '') . 36 | \ ('' != expand('%') ? expand('%') : '[NoName]') 37 | endfunction 38 | 39 | " Use status bar even with single buffer 40 | set laststatus=2 41 | -------------------------------------------------------------------------------- /vim/settings/neocomplete.vim: -------------------------------------------------------------------------------- 1 | " neocomplete 2 | " Next generation completion framework. 3 | 4 | let g:acp_enableAtStartup = 0 5 | let g:neocomplete#enable_at_startup = 1 6 | let g:neocomplete#enable_camel_case = 1 7 | let g:neocomplete#enable_smart_case = 1 8 | 9 | " Default # of completions is 100, that's crazy. 10 | let g:neocomplete#max_list = 5 11 | 12 | " Set minimum syntax keyword length. 13 | let g:neocomplete#auto_completion_start_length = 3 14 | 15 | " Map standard Ctrl-N completion to Ctrl-Space 16 | inoremap 17 | 18 | " This makes sure we use neocomplete completefunc instead of 19 | " the one in rails.vim, otherwise this plugin will crap out. 20 | let g:neocomplete#force_overwrite_completefunc = 1 21 | 22 | " Define keyword. 23 | if !exists('g:neocomplete#keyword_patterns') 24 | let g:neocomplete#keyword_patterns = {} 25 | endif 26 | let g:neocomplete#keyword_patterns['default'] = '\h\w*' 27 | 28 | " Enable omni completion. 29 | autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS 30 | autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags 31 | autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS 32 | autocmd FileType python setlocal omnifunc=pythoncomplete#Complete 33 | autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags 34 | autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete 35 | -------------------------------------------------------------------------------- /vim/settings/next-textobject.vim: -------------------------------------------------------------------------------- 1 | " Stolen from Steve Losh 2 | " https://github.com/sjl/dotfiles/blob/master/vim/vimrc#L1380 3 | " 4 | " Motion for "next/last object". "Last" here means "previous", not "final". 5 | " Unfortunately the "p" motion was already taken for paragraphs. 6 | " 7 | " Next acts on the next object of the given type, last acts on the previous 8 | " object of the given type. These don't necessarily have to be in the current 9 | " line. 10 | " 11 | " Currently works for (, [, {, and their shortcuts b, r, B. 12 | " 13 | " Next kind of works for ' and " as long as there are no escaped versions of 14 | " them in the string (TODO: fix that). Last is currently broken for quotes 15 | " (TODO: fix that). 16 | " 17 | " Some examples (C marks cursor positions, V means visually selected): 18 | " 19 | " din' -> delete in next single quotes foo = bar('spam') 20 | " C 21 | " foo = bar('') 22 | " C 23 | " 24 | " canb -> change around next parens foo = bar('spam') 25 | " C 26 | " foo = bar 27 | " C 28 | " 29 | " vin" -> select inside next double quotes print "hello ", name 30 | " C 31 | " print "hello ", name 32 | " VVVVVV 33 | 34 | onoremap an :call NextTextObject('a', '/') 35 | xnoremap an :call NextTextObject('a', '/') 36 | onoremap in :call NextTextObject('i', '/') 37 | xnoremap in :call NextTextObject('i', '/') 38 | 39 | onoremap al :call NextTextObject('a', '?') 40 | xnoremap al :call NextTextObject('a', '?') 41 | onoremap il :call NextTextObject('i', '?') 42 | xnoremap il :call NextTextObject('i', '?') 43 | 44 | 45 | function! s:NextTextObject(motion, dir) 46 | let c = nr2char(getchar()) 47 | let d = '' 48 | 49 | if c ==# "b" || c ==# "(" || c ==# ")" 50 | let c = "(" 51 | elseif c ==# "B" || c ==# "{" || c ==# "}" 52 | let c = "{" 53 | elseif c ==# "r" || c ==# "[" || c ==# "]" 54 | let c = "[" 55 | elseif c ==# "'" 56 | let c = "'" 57 | elseif c ==# '"' 58 | let c = '"' 59 | else 60 | return 61 | endif 62 | 63 | " Find the next opening-whatever. 64 | execute "normal! " . a:dir . c . "\" 65 | 66 | if a:motion ==# 'a' 67 | " If we're doing an 'around' method, we just need to select around it 68 | " and we can bail out to Vim. 69 | execute "normal! va" . c 70 | else 71 | " Otherwise we're looking at an 'inside' motion. Unfortunately these 72 | " get tricky when you're dealing with an empty set of delimiters because 73 | " Vim does the wrong thing when you say vi(. 74 | 75 | let open = '' 76 | let close = '' 77 | 78 | if c ==# "(" 79 | let open = "(" 80 | let close = ")" 81 | elseif c ==# "{" 82 | let open = "{" 83 | let close = "}" 84 | elseif c ==# "[" 85 | let open = "\\[" 86 | let close = "\\]" 87 | elseif c ==# "'" 88 | let open = "'" 89 | let close = "'" 90 | elseif c ==# '"' 91 | let open = '"' 92 | let close = '"' 93 | endif 94 | 95 | " We'll start at the current delimiter. 96 | let start_pos = getpos('.') 97 | let start_l = start_pos[1] 98 | let start_c = start_pos[2] 99 | 100 | " Then we'll find it's matching end delimiter. 101 | if c ==# "'" || c ==# '"' 102 | " searchpairpos() doesn't work for quotes, because fuck me. 103 | let end_pos = searchpos(open) 104 | else 105 | let end_pos = searchpairpos(open, '', close) 106 | endif 107 | 108 | let end_l = end_pos[0] 109 | let end_c = end_pos[1] 110 | 111 | call setpos('.', start_pos) 112 | 113 | if start_l == end_l && start_c == (end_c - 1) 114 | " We're in an empty set of delimiters. We'll append an "x" 115 | " character and select that so most Vim commands will do something 116 | " sane. v is gonna be weird, and so is y. Oh well. 117 | execute "normal! ax\\" 118 | execute "normal! vi" . c 119 | elseif start_l == end_l && start_c == (end_c - 2) 120 | " We're on a set of delimiters that contain a single, non-newline 121 | " character. We can just select that and we're done. 122 | execute "normal! vi" . c 123 | else 124 | " Otherwise these delimiters contain something. But we're still not 125 | " sure Vim's gonna work, because if they contain nothing but 126 | " newlines Vim still does the wrong thing. So we'll manually select 127 | " the guts ourselves. 128 | let whichwrap = &whichwrap 129 | set whichwrap+=h,l 130 | 131 | execute "normal! va" . c . "hol" 132 | 133 | let &whichwrap = whichwrap 134 | endif 135 | endif 136 | endfunction 137 | -------------------------------------------------------------------------------- /vim/settings/open-changed-files.vim: -------------------------------------------------------------------------------- 1 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 2 | " OpenChangedFiles COMMAND 3 | " Open a split for each dirty file in git 4 | " 5 | " Shamelessly stolen from Gary Bernhardt: https://github.com/garybernhardt/dotfiles 6 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 7 | function! OpenChangedFiles() 8 | only " Close all windows, unless they're modified 9 | let status = system('git status -s | grep "^ \?\(M\|A\)" | cut -d " " -f 3') 10 | let filenames = split(status, "\n") 11 | if len(filenames) > 0 12 | exec "edit " . filenames[0] 13 | for filename in filenames[1:] 14 | exec "sp " . filename 15 | endfor 16 | end 17 | endfunction 18 | command! OpenChangedFiles :call OpenChangedFiles() 19 | 20 | nnoremap ,ocf :OpenChangedFiles 21 | -------------------------------------------------------------------------------- /vim/settings/outerblock.vim: -------------------------------------------------------------------------------- 1 | " Navigate to the block surrounding this one 2 | " For example if you're inside 3 | " foo do 4 | " bar do 5 | " # you are here 6 | " end 7 | " end 8 | " 9 | " Then hitting ,orb ("outer ruby block") will take you to 'foo do' 10 | " 11 | " This is relying on the textobj-rubyblock which gives us 'ar' around ruby 12 | " and matchit.vim which gives us jumping to the matching 13 | nnoremap ,orb :normal varar% 14 | -------------------------------------------------------------------------------- /vim/settings/path.vim: -------------------------------------------------------------------------------- 1 | " Set the shell to bash so we inherit its path, to make sure 2 | " we inherit its path. This affects :Rtags finding the right 3 | " path to homebrewed ctags rather than the XCode version of ctags 4 | " 5 | " Use login Shell instead of interactive shell to avoid 6 | " vimdiff suspended at startup 7 | if has("gui_running") 8 | set shell=bash\ -i 9 | else 10 | set shell=bash\ -l 11 | endif 12 | -------------------------------------------------------------------------------- /vim/settings/quickfix-search.vim: -------------------------------------------------------------------------------- 1 | " Stolen from Steve Losh vimrc: https://bitbucket.org/sjl/dotfiles/src/tip/vim/.vimrc 2 | " Open a Quickfix window for the last search. 3 | nnoremap q/ :execute 'vimgrep /'.@/.'/g %':copen 4 | 5 | " Ag for the last search. 6 | nnoremap qa/ :execute "Ag! '" . substitute(substitute(substitute(@/, "\\\\<", "\\\\b", ""), "\\\\>", "\\\\b", ""), "\\\\v", "", "") . "'" 7 | -------------------------------------------------------------------------------- /vim/settings/rails.vim: -------------------------------------------------------------------------------- 1 | " Better key maps for switching between controller and view 2 | nnoremap ,vv :Eview 3 | nnoremap ,cc :Econtroller 4 | -------------------------------------------------------------------------------- /vim/settings/rspec.vim: -------------------------------------------------------------------------------- 1 | " Does not work on pending 'blocks', only single lines 2 | " 3 | " Given: 4 | " it "foo bar" do 5 | " pending("bla bla" 6 | " 7 | " Produce: 8 | " xit "foo bar" do 9 | " 10 | function! ChangePendingRspecToXit() 11 | " Find the next occurrence of pending 12 | while(search("pending(") > 0) 13 | " Delete it 14 | normal dd 15 | " Search backwards to the it block 16 | ?it\s 17 | " add an 'x' to the 'it' to make it 'xit' 18 | normal ix 19 | endwhile 20 | endfunction 21 | 22 | nnoremap ,rxit :call ChangePendingRspecToXit() 23 | 24 | " insert a before { } block around a line 25 | nnoremap \bf ^ibefore { $a } 26 | 27 | " insert a specify { } block around a line 28 | nnoremap \sp ^ispecify { $a } 29 | 30 | -------------------------------------------------------------------------------- /vim/settings/search.vim: -------------------------------------------------------------------------------- 1 | function! GetVisual() 2 | let reg_save = getreg('"') 3 | let regtype_save = getregtype('"') 4 | let cb_save = &clipboard 5 | set clipboard& 6 | normal! ""gvy 7 | let selection = getreg('"') 8 | call setreg('"', reg_save, regtype_save) 9 | let &clipboard = cb_save 10 | return selection 11 | endfunction 12 | 13 | "grep the current word using ,k (mnemonic Kurrent) 14 | nnoremap ,k :Ag 15 | 16 | "grep visual selection 17 | vnoremap ,k :execute "Ag " . GetVisual() 18 | 19 | "grep current word up to the next exclamation point using ,K 20 | nnoremap ,K viwf!:execute "Ag " . GetVisual() 21 | 22 | "grep for 'def foo' 23 | nnoremap ,gd :Ag 'def ' 24 | 25 | ",gg = Grep! - using Ag the silver searcher 26 | " open up a grep line, with a quote started for the search 27 | nnoremap ,gg :Ag "" 28 | 29 | "Grep for usages of the current file 30 | nnoremap ,gcf :exec "Ag " . expand("%:t:r") 31 | -------------------------------------------------------------------------------- /vim/settings/showmarks.vim: -------------------------------------------------------------------------------- 1 | " Tell showmarks to not include the various brace marks (),{}, etc 2 | let g:showmarks_include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY" 3 | -------------------------------------------------------------------------------- /vim/settings/smart_jump_to_tag.vim: -------------------------------------------------------------------------------- 1 | " hit ,f to find the definition of the current class 2 | " this uses ctags. the standard way to get this is Ctrl-] 3 | nnoremap ,f 4 | 5 | " use ,F to jump to tag in a vertical split 6 | nnoremap ,F :let word=expand(""):vsp:wincmd w:exec("tag ". word) 7 | -------------------------------------------------------------------------------- /vim/settings/sneak.vim: -------------------------------------------------------------------------------- 1 | nmap SneakForward 2 | -------------------------------------------------------------------------------- /vim/settings/snipmate.vim: -------------------------------------------------------------------------------- 1 | " Explicitly set g:snipMate.snippet_version to remove start up message 2 | let g:snipMate = { 'snippet_version' : 0 } 3 | -------------------------------------------------------------------------------- /vim/settings/solarized.vim: -------------------------------------------------------------------------------- 1 | if !exists("g:yadr_disable_solarized_enhancements") 2 | hi! link txtBold Identifier 3 | hi! link zshVariableDef Identifier 4 | hi! link zshFunction Function 5 | hi! link rubyControl Statement 6 | hi! link rspecGroupMethods rubyControl 7 | hi! link rspecMocks Identifier 8 | hi! link rspecKeywords Identifier 9 | hi! link rubyLocalVariableOrMethod Normal 10 | hi! link rubyStringDelimiter Constant 11 | hi! link rubyString Constant 12 | hi! link rubyAccess Todo 13 | hi! link rubySymbol Identifier 14 | hi! link rubyPseudoVariable Type 15 | hi! link rubyRailsARAssociationMethod Title 16 | hi! link rubyRailsARValidationMethod Title 17 | hi! link rubyRailsMethod Title 18 | hi! link rubyDoBlock Normal 19 | hi! link MatchParen DiffText 20 | 21 | hi! link CTagsModule Type 22 | hi! link CTagsClass Type 23 | hi! link CTagsMethod Identifier 24 | hi! link CTagsSingleton Identifier 25 | 26 | hi! link javascriptFuncName Type 27 | hi! link jsFuncCall jsFuncName 28 | hi! link javascriptFunction Statement 29 | hi! link javascriptThis Statement 30 | hi! link javascriptParens Normal 31 | hi! link jOperators javascriptStringD 32 | hi! link jId Title 33 | hi! link jClass Title 34 | 35 | " Javascript language support 36 | hi! link javascriptJGlobalMethod Statement 37 | 38 | " Make the braces and other noisy things slightly less noisy 39 | hi! jsParens guifg=#005F78 cterm=NONE term=NONE ctermfg=NONE ctermbg=NONE 40 | hi! link jsFuncParens jsParens 41 | hi! link jsFuncBraces jsParens 42 | hi! link jsBraces jsParens 43 | hi! link jsParens jsParens 44 | hi! link jsNoise jsParens 45 | 46 | hi! link NERDTreeFile Constant 47 | hi! link NERDTreeDir Identifier 48 | 49 | hi! link sassMixinName Function 50 | hi! link sassDefinition Function 51 | hi! link sassProperty Type 52 | hi! link htmlTagName Type 53 | 54 | hi! PreProc gui=bold 55 | 56 | " Solarized separators are a little garish. 57 | " This moves separators, comments, and normal 58 | " text into the same color family as the background. 59 | " Using the http://drpeterjones.com/colorcalc/, 60 | " they are now just differently saturated and 61 | " valued riffs on the background color, making 62 | " everything play together just a little more nicely. 63 | hi! VertSplit guifg=#003745 cterm=NONE term=NONE ctermfg=NONE ctermbg=NONE 64 | hi! LineNR guifg=#004C60 gui=bold guibg=#002B36 ctermfg=146 65 | hi! link NonText VertSplit 66 | hi! Normal guifg=#77A5B1 67 | hi! Constant guifg=#00BCE0 68 | hi! Comment guifg=#52737B 69 | hi! link htmlLink Include 70 | hi! CursorLine cterm=NONE gui=NONE 71 | hi! Visual ctermbg=233 72 | hi! Type gui=bold 73 | hi! EasyMotionTarget ctermfg=100 guifg=#4CE660 gui=bold 74 | 75 | " Make sure this file loads itself on top of any other color settings 76 | au VimEnter * so ~/.vim/settings/solarized.vim 77 | endif 78 | -------------------------------------------------------------------------------- /vim/settings/surround.vim: -------------------------------------------------------------------------------- 1 | " via: http://whynotwiki.com/Vim 2 | " Ruby 3 | " Use v or # to get a variable interpolation (inside of a string)} 4 | " ysiw# Wrap the token under the cursor in #{} 5 | " v...s# Wrap the selection in #{} 6 | let g:surround_113 = "#{\r}" " v 7 | let g:surround_35 = "#{\r}" " # 8 | 9 | " Select text in an ERb file with visual mode and then press s- or s= 10 | " Or yss- to do entire line. 11 | let g:surround_45 = "<% \r %>" " - 12 | let g:surround_61 = "<%= \r %>" " = 13 | -------------------------------------------------------------------------------- /vim/settings/syntastic.vim: -------------------------------------------------------------------------------- 1 | "mark syntax errors with :signs 2 | let g:syntastic_enable_signs=1 3 | "automatically jump to the error when saving the file 4 | let g:syntastic_auto_jump=0 5 | "show the error list automatically 6 | let g:syntastic_auto_loc_list=1 7 | "don't care about warnings 8 | let g:syntastic_quiet_messages = {'level': 'warnings'} 9 | 10 | " Default to eslint. If you need jshint, you can override this in 11 | " ~/.vimrc.after 12 | let g:syntastic_javascript_checkers = ['eslint'] 13 | 14 | " I have no idea why this is not working, as it used to 15 | " be a part of syntastic code but was apparently removed 16 | " This will make syntastic find the correct ruby specified by mri 17 | function! s:FindRubyExec() 18 | if executable("rvm") 19 | return system("rvm tools identifier") 20 | endif 21 | 22 | return "ruby" 23 | endfunction 24 | 25 | if !exists("g:syntastic_ruby_exec") 26 | let g:syntastic_ruby_exec = s:FindRubyExec() 27 | endif 28 | -------------------------------------------------------------------------------- /vim/settings/tComment.vim: -------------------------------------------------------------------------------- 1 | " tComment 2 | " ======================================== 3 | " extensions for tComment plugin. Normally 4 | " tComment maps 'gcc' to comment current line 5 | " this adds 'gcp' comment current paragraph (block) 6 | " using tComment's built in p mapping 7 | nmap gcp p 8 | 9 | -------------------------------------------------------------------------------- /vim/settings/tidy.vim: -------------------------------------------------------------------------------- 1 | :vmap ,gt :!tidy -q -i --show-errors 0 2 | -------------------------------------------------------------------------------- /vim/settings/unimpaired.vim: -------------------------------------------------------------------------------- 1 | " https://github.com/carlhuda/janus/blob/master/vimrc 2 | 3 | " Unimpaired configuration 4 | " Bubble single lines 5 | nmap [e 6 | nmap ]e 7 | 8 | " Bubble multiple lines 9 | vmap [egv 10 | vmap ]egv 11 | -------------------------------------------------------------------------------- /vim/settings/vim-fugitive.vim: -------------------------------------------------------------------------------- 1 | " The tree buffer makes it easy to drill down through the directories of your 2 | " git repository, but it’s not obvious how you could go up a level to the 3 | " parent directory. Here’s a mapping of .. to the above command, but 4 | " only for buffers containing a git blob or tree 5 | autocmd User fugitive 6 | \ if get(b:, 'fugitive_type', '') =~# '^\%(tree\|blob\)$' | 7 | \ nnoremap .. :edit %:h | 8 | \ endif 9 | 10 | " Every time you open a git object using fugitive it creates a new buffer. 11 | " This means that your buffer listing can quickly become swamped with 12 | " fugitive buffers. This prevents this from becomming an issue: 13 | 14 | autocmd BufReadPost fugitive://* set bufhidden=delete 15 | 16 | -------------------------------------------------------------------------------- /vim/settings/vim-indent-guides.vim: -------------------------------------------------------------------------------- 1 | let g:indent_guides_auto_colors = 1 2 | let g:indent_guides_start_level = 2 3 | let g:indent_guides_guide_size = 1 4 | -------------------------------------------------------------------------------- /vim/settings/vim-multiple-cursors.vim: -------------------------------------------------------------------------------- 1 | " Turn off default key mappings 2 | let g:multi_cursor_use_default_mapping=0 3 | 4 | " Switch to multicursor mode with ,mc 5 | let g:multi_cursor_start_key=',mc' 6 | 7 | " Ctrl-n, Ctrl-p, Ctrl-x, and are mapped in the special multicursor 8 | " mode once you've added at least one virtual cursor to the buffer 9 | let g:multi_cursor_next_key='' 10 | let g:multi_cursor_prev_key='' 11 | let g:multi_cursor_skip_key='' 12 | let g:multi_cursor_quit_key='' 13 | 14 | -------------------------------------------------------------------------------- /vim/settings/vim-session.vim: -------------------------------------------------------------------------------- 1 | " Prevent vim-session from asking us to load the session. 2 | " If you want to load the session, use :SaveSession and :OpenSession 3 | let g:session_autosave = 'no' 4 | let g:session_autoload = 'no' 5 | -------------------------------------------------------------------------------- /vim/settings/vim-tmux-navigator.vim: -------------------------------------------------------------------------------- 1 | " Don't allow any default key-mappings. 2 | let g:tmux_navigator_no_mappings = 1 3 | 4 | " Re-enable tmux_navigator.vim default bindings, minus . 5 | " conflicts with NERDTree "current file". 6 | 7 | nnoremap :TmuxNavigateLeft 8 | nnoremap :TmuxNavigateDown 9 | nnoremap :TmuxNavigateUp 10 | nnoremap :TmuxNavigateRight 11 | -------------------------------------------------------------------------------- /vim/settings/yadr-appearance.vim: -------------------------------------------------------------------------------- 1 | " Make it beautiful - colors and fonts 2 | 3 | if has("gui_running") 4 | "tell the term has 256 colors 5 | set t_Co=256 6 | 7 | " Show tab number (useful for Cmd-1, Cmd-2.. mapping) 8 | " For some reason this doesn't work as a regular set command, 9 | " (the numbers don't show up) so I made it a VimEnter event 10 | autocmd VimEnter * set guitablabel=%N:\ %t\ %M 11 | 12 | set lines=60 13 | set columns=190 14 | 15 | if has("gui_gtk2") 16 | set guifont=Inconsolata\ XL\ 12,Inconsolata\ 15,Monaco\ 12 17 | else 18 | set guifont=Inconsolata\ XL:h17,Inconsolata:h20,Monaco:h17 19 | end 20 | else 21 | let g:CSApprox_loaded = 1 22 | 23 | " For people using a terminal that is not Solarized 24 | if exists("g:yadr_using_unsolarized_terminal") 25 | let g:solarized_termcolors=256 26 | let g:solarized_termtrans=1 27 | end 28 | endif 29 | 30 | colorscheme solarized 31 | set background=dark 32 | -------------------------------------------------------------------------------- /vim/settings/yadr-guioptions.vim: -------------------------------------------------------------------------------- 1 | " Disable the scrollbars (NERDTree) 2 | set guioptions-=r 3 | set guioptions-=L 4 | 5 | " Disable the macvim toolbar 6 | set guioptions-=T 7 | -------------------------------------------------------------------------------- /vim/settings/yadr-keymap-linux.vim: -------------------------------------------------------------------------------- 1 | " ======================================== 2 | " Linux specific General vim sanity improvements 3 | " ======================================== 4 | " 5 | " ======================================== 6 | " RSI Prevention - keyboard remaps 7 | " ======================================== 8 | " Certain things we do every day as programmers stress 9 | " out our hands. For example, typing underscores and 10 | " dashes are very common, and in position that require 11 | " a lot of hand movement. Vim to the rescue 12 | " 13 | " Now using the middle finger of either hand you can type 14 | " underscores with Alt-k or Alt-d, and add Shift 15 | " to type dashes 16 | imap _ 17 | imap _ 18 | imap - 19 | imap - 20 | 21 | " Change inside various enclosures with Alt-" and Alt-' 22 | " The f makes it find the enclosure so you don't have 23 | " to be standing inside it 24 | nnoremap f'ci' 25 | nnoremap f"ci" 26 | nnoremap f(ci( 27 | nnoremap f)ci) 28 | nnoremap f[ci[ 29 | nnoremap f]ci] 30 | 31 | " ==== NERD tree 32 | " Alt-Shift-N for nerd tree 33 | nmap :NERDTreeToggle 34 | 35 | " move up/down quickly by using Alt-j, Alt-k 36 | " which will move us around by functions 37 | nnoremap } 38 | nnoremap { 39 | autocmd FileType ruby map ]m 40 | autocmd FileType ruby map [m 41 | autocmd FileType rspec map } 42 | autocmd FileType rspec map { 43 | autocmd FileType javascript map } 44 | autocmd FileType javascript map { 45 | 46 | " Command-/ to toggle comments 47 | map :TComment 48 | imap :TCommenti 49 | 50 | " Use Alt- numbers to pick the tab you want 51 | map :tabn 1 52 | map :tabn 2 53 | map :tabn 3 54 | map :tabn 4 55 | map :tabn 5 56 | map :tabn 6 57 | map :tabn 7 58 | map :tabn 8 59 | map :tabn 9 60 | 61 | " Resize windows with arrow keys 62 | nnoremap + 63 | nnoremap - 64 | nnoremap < 65 | nnoremap > 66 | 67 | " ============================ 68 | " Tabularize - alignment 69 | " ============================ 70 | " Hit Alt-Shift-A then type a character you want to align by 71 | nmap :Tabularize / 72 | vmap :Tabularize / 73 | 74 | " Source current file Alt-% (good for vim development) 75 | map :so % 76 | -------------------------------------------------------------------------------- /vim/settings/yadr-keymap-mac.vim: -------------------------------------------------------------------------------- 1 | " ======================================== 2 | " Mac specific General vim sanity improvements 3 | " ======================================== 4 | " 5 | " ======================================== 6 | " RSI Prevention - keyboard remaps 7 | " ======================================== 8 | " Certain things we do every day as programmers stress 9 | " out our hands. For example, typing underscores and 10 | " dashes are very common, and in position that require 11 | " a lot of hand movement. Vim to the rescue 12 | " 13 | " Now using the middle finger of either hand you can type 14 | " underscores with apple-k or apple-d, and add Shift 15 | " to type dashes 16 | imap _ 17 | imap _ 18 | imap - 19 | imap - 20 | 21 | " Change inside various enclosures with Cmd-" and Cmd-' 22 | " The f makes it find the enclosure so you don't have 23 | " to be standing inside it 24 | nnoremap f'ci' 25 | nnoremap f"ci" 26 | nnoremap f(ci( 27 | nnoremap f)ci) 28 | nnoremap f[ci[ 29 | nnoremap f]ci] 30 | 31 | " ==== NERD tree 32 | " Cmd-Shift-N for nerd tree 33 | nmap :NERDTreeToggle 34 | 35 | " move up/down quickly by using Cmd-j, Cmd-k 36 | " which will move us around by functions 37 | nnoremap } 38 | nnoremap { 39 | autocmd FileType ruby map ]m 40 | autocmd FileType ruby map [m 41 | autocmd FileType rspec map } 42 | autocmd FileType rspec map { 43 | autocmd FileType javascript map } 44 | autocmd FileType javascript map { 45 | 46 | " Command-/ to toggle comments 47 | map :TComment 48 | imap :TCommenti 49 | 50 | " Use numbers to pick the tab you want (like iTerm) 51 | map :tabn 1 52 | map :tabn 2 53 | map :tabn 3 54 | map :tabn 4 55 | map :tabn 5 56 | map :tabn 6 57 | map :tabn 7 58 | map :tabn 8 59 | map :tabn 9 60 | 61 | " Resize windows with arrow keys 62 | nnoremap + 63 | nnoremap - 64 | nnoremap < 65 | nnoremap > 66 | 67 | " ============================ 68 | " Tabularize - alignment 69 | " ============================ 70 | " Hit Cmd-Shift-A then type a character you want to align by 71 | nmap :Tabularize / 72 | vmap :Tabularize / 73 | 74 | " Source current file Cmd-% (good for vim development) 75 | map :so % 76 | -------------------------------------------------------------------------------- /vim/settings/yadr-keymap.vim: -------------------------------------------------------------------------------- 1 | " ======================================== 2 | " General vim sanity improvements 3 | " ======================================== 4 | " 5 | " 6 | " alias yw to yank the entire word 'yank inner word' 7 | " even if the cursor is halfway inside the word 8 | " FIXME: will not properly repeat when you use a dot (tie into repeat.vim) 9 | nnoremap ,yw yiww 10 | 11 | " ,ow = 'overwrite word', replace a word with what's in the yank buffer 12 | " FIXME: will not properly repeat when you use a dot (tie into repeat.vim) 13 | nnoremap ,ow "_diwhp 14 | 15 | "make Y consistent with C and D 16 | nnoremap Y y$ 17 | function! YRRunAfterMaps() 18 | nnoremap Y :YRYankCount 'y$' 19 | endfunction 20 | 21 | " Make 0 go to the first character rather than the beginning 22 | " of the line. When we're programming, we're almost always 23 | " interested in working with text rather than empty space. If 24 | " you want the traditional beginning of line, use ^ 25 | nnoremap 0 ^ 26 | nnoremap ^ 0 27 | 28 | " ,# Surround a word with #{ruby interpolation} 29 | map ,# ysiw# 30 | vmap ,# c#{"} 31 | 32 | " ," Surround a word with "quotes" 33 | map ," ysiw" 34 | vmap ," c""" 35 | 36 | " ,' Surround a word with 'single quotes' 37 | map ,' ysiw' 38 | vmap ,' c'"' 39 | 40 | " ,) or ,( Surround a word with (parens) 41 | " The difference is in whether a space is put in 42 | map ,( ysiw( 43 | map ,) ysiw) 44 | vmap ,( c( " ) 45 | vmap ,) c(") 46 | 47 | " ,[ Surround a word with [brackets] 48 | map ,] ysiw] 49 | map ,[ ysiw[ 50 | vmap ,[ c[ " ] 51 | vmap ,] c["] 52 | 53 | " ,{ Surround a word with {braces} 54 | map ,} ysiw} 55 | map ,{ ysiw{ 56 | vmap ,} c{ " } 57 | vmap ,{ c{"} 58 | 59 | map ,` ysiw` 60 | 61 | " gary bernhardt's hashrocket 62 | imap => 63 | 64 | "Go to last edit location with ,. 65 | nnoremap ,. '. 66 | 67 | "When typing a string, your quotes auto complete. Move past the quote 68 | "while still in insert mode by hitting Ctrl-a. Example: 69 | " 70 | " type 'foo 71 | " 72 | " the first quote will autoclose so you'll get 'foo' and hitting will 73 | " put the cursor right after the quote 74 | imap wa 75 | 76 | " ==== NERD tree 77 | " Open the project tree and expose current file in the nerdtree with Ctrl-\ 78 | " " calls NERDTreeFind iff NERDTree is active, current window contains a modifiable file, and we're not in vimdiff 79 | function! OpenNerdTree() 80 | if &modifiable && strlen(expand('%')) > 0 && !&diff 81 | NERDTreeFind 82 | else 83 | NERDTreeToggle 84 | endif 85 | endfunction 86 | nnoremap :call OpenNerdTree() 87 | 88 | " ,q to toggle quickfix window (where you have stuff like Ag) 89 | " ,oq to open it back up (rare) 90 | nmap ,qc :cclose 91 | nmap ,qo :copen 92 | 93 | "Move back and forth through previous and next buffers 94 | "with ,z and ,x 95 | nnoremap ,z :bp 96 | nnoremap ,x :bn 97 | 98 | " ============================== 99 | " Window/Tab/Split Manipulation 100 | " ============================== 101 | " Move between split windows by using the four directions H, L, K, J 102 | " NOTE: This has moved to vim/settings/vim-tmux-navigator.vim. 103 | " nnoremap h 104 | " nnoremap l 105 | " nnoremap k 106 | " nnoremap j 107 | 108 | " Make gf (go to file) create the file, if not existent 109 | nnoremap f :sp +e 110 | nnoremap gf :tabe 111 | 112 | " Zoom in 113 | map ,gz o 114 | 115 | " Create window splits easier. The default 116 | " way is Ctrl-w,v and Ctrl-w,s. I remap 117 | " this to vv and ss 118 | nnoremap vv v 119 | nnoremap ss s 120 | 121 | " create <%= foo %> erb tags using Ctrl-k in edit mode 122 | imap <%= %>3hi 123 | 124 | " create <%= foo %> erb tags using Ctrl-j in edit mode 125 | imap <% %>2hi 126 | 127 | " ============================ 128 | " Shortcuts for everyday tasks 129 | " ============================ 130 | 131 | " copy current filename into system clipboard - mnemonic: (c)urrent(f)ilename 132 | " this is helpful to paste someone the path you're looking at 133 | nnoremap ,cf :let @* = expand("%:~") 134 | nnoremap ,cr :let @* = expand("%") 135 | nnoremap ,cn :let @* = expand("%:t") 136 | 137 | "Clear current search highlight by double tapping // 138 | nmap // :nohlsearch 139 | 140 | "(v)im (c)ommand - execute current line as a vim command 141 | nmap ,vc yy:p 142 | 143 | "(v)im (r)eload 144 | nmap ,vr :so % 145 | 146 | " Type ,hl to toggle highlighting on/off, and show current value. 147 | noremap ,hl :set hlsearch! hlsearch? 148 | 149 | " These are very similar keys. Typing 'a will jump to the line in the current 150 | " file marked with ma. However, `a will jump to the line and column marked 151 | " with ma. It’s more useful in any case I can imagine, but it’s located way 152 | " off in the corner of the keyboard. The best way to handle this is just to 153 | " swap them: http://items.sjbach.com/319/configuring-vim-right 154 | nnoremap ' ` 155 | nnoremap ` ' 156 | 157 | " ============================ 158 | " SplitJoin plugin 159 | " ============================ 160 | nmap sj :SplitjoinSplit 161 | nmap sk :SplitjoinJoin 162 | 163 | " Get the current highlight group. Useful for then remapping the color 164 | map ,hi :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" . " FG:" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"fg#") 165 | 166 | " ,hp = html preview 167 | map ,hp :!open -a Safari % 168 | 169 | " Map Ctrl-x and Ctrl-z to navigate the quickfix error list (normally :cn and 170 | " :cp) 171 | nnoremap :cn 172 | nnoremap :cp 173 | -------------------------------------------------------------------------------- /vim/settings/yadr-sudo-write.vim: -------------------------------------------------------------------------------- 1 | " w!! to write a file as sudo 2 | " stolen from Steve Losh 3 | cmap w!! w !sudo tee % >/dev/null 4 | -------------------------------------------------------------------------------- /vim/settings/yadr-whitespace-killer.vim: -------------------------------------------------------------------------------- 1 | " via: http://rails-bestpractices.com/posts/60-remove-trailing-whitespace 2 | " Strip trailing whitespace 3 | function! StripTrailingWhitespaces() 4 | " Preparation: save last search, and cursor position. 5 | let _s=@/ 6 | let l = line(".") 7 | let c = col(".") 8 | " Do the business: 9 | %s/\s\+$//e 10 | " Clean up: restore previous search history, and cursor position 11 | let @/=_s 12 | call cursor(l, c) 13 | endfunction 14 | command! StripTrailingWhitespaces call StripTrailingWhitespaces() 15 | nmap ,w :StripTrailingWhitespaces 16 | -------------------------------------------------------------------------------- /vim/settings/yadr-window-killer.vim: -------------------------------------------------------------------------------- 1 | " Use Q to intelligently close a window 2 | " (if there are multiple windows into the same buffer) 3 | " or kill the buffer entirely if it's the last window looking into that buffer 4 | function! CloseWindowOrKillBuffer() 5 | let number_of_windows_to_this_buffer = len(filter(range(1, winnr('$')), "winbufnr(v:val) == bufnr('%')")) 6 | 7 | " We should never bdelete a nerd tree 8 | if matchstr(expand("%"), 'NERD') == 'NERD' 9 | wincmd c 10 | return 11 | endif 12 | 13 | if number_of_windows_to_this_buffer > 1 14 | wincmd c 15 | else 16 | bdelete 17 | endif 18 | endfunction 19 | 20 | nnoremap Q :call CloseWindowOrKillBuffer() 21 | -------------------------------------------------------------------------------- /vim/settings/yadr-wrapping.vim: -------------------------------------------------------------------------------- 1 | " http://vimcasts.org/episodes/soft-wrapping-text/ 2 | function! SetupWrapping() 3 | set wrap linebreak nolist 4 | set showbreak=… 5 | endfunction 6 | 7 | " TODO: this should happen automatically for certain file types (e.g. markdown) 8 | command! -nargs=* Wrap :call SetupWrapping() 9 | 10 | vmap gj 11 | vmap gk 12 | vmap g$ 13 | vmap g^ 14 | vmap g^ 15 | nmap gj 16 | nmap gk 17 | nmap g$ 18 | nmap g^ 19 | nmap g^ 20 | 21 | -------------------------------------------------------------------------------- /vim/settings/yankring.vim: -------------------------------------------------------------------------------- 1 | let g:yankring_history_file = '.yankring-history' 2 | nnoremap ,yr :YRShow 3 | nnoremap C-y :YRShow 4 | -------------------------------------------------------------------------------- /vim/vundles.vim: -------------------------------------------------------------------------------- 1 | " ======================================== 2 | " Vim plugin configuration 3 | " ======================================== 4 | " 5 | " This file contains the list of plugin installed using vundle plugin manager. 6 | " Once you've updated the list of plugin, you can run vundle update by issuing 7 | " the command :BundleInstall from within vim or directly invoking it from the 8 | " command line with the following syntax: 9 | " vim --noplugin -u vim/vundles.vim -N "+set hidden" "+syntax on" +BundleClean! +BundleInstall +qall 10 | " Filetype off is required by vundle 11 | filetype off 12 | 13 | set rtp+=~/.vim/bundle/vundle/ 14 | set rtp+=~/.vim/vundles/ "Submodules 15 | call vundle#rc() 16 | 17 | " let Vundle manage Vundle (required) 18 | Bundle "gmarik/vundle" 19 | 20 | " YADR's vundles are split up by category into smaller files 21 | " This reduces churn and makes it easier to fork. See 22 | " ~/.vim/vundles/ to edit them: 23 | runtime ruby.vundle 24 | runtime languages.vundle 25 | runtime git.vundle 26 | runtime appearance.vundle 27 | runtime textobjects.vundle 28 | runtime search.vundle 29 | runtime project.vundle 30 | runtime vim-improvements.vundle 31 | 32 | " The plugins listed in ~/.vim/.vundles.local will be added here to 33 | " allow the user to add vim plugins to yadr without the need for a fork. 34 | if filereadable(expand("~/.yadr/vim/.vundles.local")) 35 | source ~/.yadr/vim/.vundles.local 36 | endif 37 | 38 | "Filetype plugin indent on is required by vundle 39 | filetype plugin indent on 40 | -------------------------------------------------------------------------------- /vim/vundles/appearance.vundle: -------------------------------------------------------------------------------- 1 | Bundle "chrisbra/color_highlight.git" 2 | Bundle "skwp/vim-colors-solarized" 3 | Bundle "itchyny/lightline.vim" 4 | Bundle "jby/tmux.vim.git" 5 | Bundle "morhetz/gruvbox" 6 | Bundle "xsunsmile/showmarks.git" 7 | Bundle "chriskempson/base16-vim" 8 | 9 | " Required for Gblame in terminal vim 10 | Bundle "godlygeek/csapprox.git" 11 | -------------------------------------------------------------------------------- /vim/vundles/git.vundle: -------------------------------------------------------------------------------- 1 | Bundle "gregsexton/gitv" 2 | Bundle "mattn/gist-vim" 3 | Bundle "tpope/vim-fugitive" 4 | Bundle "tpope/vim-git" 5 | -------------------------------------------------------------------------------- /vim/vundles/languages.vundle: -------------------------------------------------------------------------------- 1 | Bundle 'sheerun/vim-polyglot' 2 | Bundle 'pangloss/vim-javascript' 3 | Bundle 'w0rp/ale' 4 | Bundle 'garbas/vim-snipmate.git' 5 | Bundle 'honza/vim-snippets' 6 | Bundle 'jtratner/vim-flavored-markdown.git' 7 | Bundle 'vim-syntastic/syntastic.git' 8 | Bundle 'nelstrom/vim-markdown-preview' 9 | Bundle 'skwp/vim-html-escape' 10 | Bundle 'MaxMEllon/vim-jsx-pretty' 11 | Bundle 'jparise/vim-graphql' 12 | Bundle 'mogelbrod/vim-jsonpath' 13 | -------------------------------------------------------------------------------- /vim/vundles/project.vundle: -------------------------------------------------------------------------------- 1 | Bundle "jistr/vim-nerdtree-tabs.git" 2 | Bundle "preservim/nerdtree.git" 3 | Bundle "ctrlpvim/ctrlp.vim" 4 | Bundle 'JazzCore/ctrlp-cmatcher' 5 | Bundle 'junegunn/fzf' 6 | Bundle "xolox/vim-misc" 7 | Bundle "xolox/vim-session" 8 | -------------------------------------------------------------------------------- /vim/vundles/ruby.vundle: -------------------------------------------------------------------------------- 1 | Bundle "ecomba/vim-ruby-refactoring" 2 | Bundle "tpope/vim-rails.git" 3 | Bundle "tpope/vim-rake.git" 4 | Bundle "tpope/vim-rvm.git" 5 | Bundle "vim-ruby/vim-ruby.git" 6 | Bundle "keith/rspec.vim" 7 | Bundle "skwp/vim-iterm-rspec" 8 | Bundle "skwp/vim-spec-finder" 9 | Bundle "ck3g/vim-change-hash-syntax" 10 | Bundle "tpope/vim-bundler" 11 | -------------------------------------------------------------------------------- /vim/vundles/search.vundle: -------------------------------------------------------------------------------- 1 | Bundle "justinmk/vim-sneak" 2 | Bundle "rking/ag.vim" 3 | Bundle "henrik/vim-indexed-search" 4 | Bundle "nelstrom/vim-visual-star-search" 5 | Bundle "skwp/greplace.vim" 6 | Bundle "Lokaltog/vim-easymotion" 7 | -------------------------------------------------------------------------------- /vim/vundles/textobjects.vundle: -------------------------------------------------------------------------------- 1 | " These bundles introduce new textobjects into vim, 2 | " For example the Ruby one introduces the 'r' text object 3 | " such that 'var' gives you Visual Around Ruby 4 | Bundle "austintaylor/vim-indentobject" 5 | Bundle "bootleq/vim-textobj-rubysymbol" 6 | Bundle "coderifous/textobj-word-column.vim" 7 | Bundle "kana/vim-textobj-datetime" 8 | Bundle "kana/vim-textobj-entire" 9 | Bundle "kana/vim-textobj-function" 10 | Bundle "kana/vim-textobj-user" 11 | Bundle "lucapette/vim-textobj-underscore" 12 | Bundle "nathanaelkane/vim-indent-guides" 13 | Bundle "nelstrom/vim-textobj-rubyblock" 14 | Bundle "thinca/vim-textobj-function-javascript" 15 | Bundle "wellle/targets.vim" 16 | -------------------------------------------------------------------------------- /vim/vundles/vim-improvements.vundle: -------------------------------------------------------------------------------- 1 | Bundle "AndrewRadev/splitjoin.vim" 2 | Bundle "Raimondi/delimitMate" 3 | Bundle "Shougo/neocomplete.git" 4 | Bundle "briandoll/change-inside-surroundings.vim.git" 5 | Bundle "godlygeek/tabular" 6 | Bundle "tomtom/tcomment_vim.git" 7 | Bundle "vim-scripts/camelcasemotion.git" 8 | Bundle "vim-scripts/matchit.zip.git" 9 | Bundle "kristijanhusak/vim-multiple-cursors" 10 | Bundle "Keithbsmiley/investigate.vim" 11 | Bundle "chrisbra/NrrwRgn" 12 | Bundle "christoomey/vim-tmux-navigator" 13 | Bundle "MarcWeber/vim-addon-mw-utils.git" 14 | Bundle "bogado/file-line.git" 15 | Bundle "mattn/webapi-vim.git" 16 | Bundle "sjl/gundo.vim" 17 | Bundle "skwp/YankRing.vim" 18 | Bundle "tomtom/tlib_vim.git" 19 | Bundle "tpope/vim-abolish" 20 | Bundle "tpope/vim-endwise.git" 21 | Bundle "tpope/vim-ragtag" 22 | Bundle "tpope/vim-repeat.git" 23 | Bundle "tpope/vim-surround.git" 24 | Bundle "tpope/vim-unimpaired" 25 | Bundle "vim-scripts/AnsiEsc.vim.git" 26 | Bundle "vim-scripts/AutoTag.git" 27 | Bundle "vim-scripts/lastpos.vim" 28 | Bundle "vim-scripts/sudo.vim" 29 | Bundle "goldfeld/ctrlr.vim" 30 | Bundle "editorconfig/editorconfig-vim" 31 | 32 | -------------------------------------------------------------------------------- /vimify/editrc: -------------------------------------------------------------------------------- 1 | bind -v 2 | bind "^R" em-inc-search-prev 3 | bind \\t rl_complete 4 | -------------------------------------------------------------------------------- /vimify/inputrc: -------------------------------------------------------------------------------- 1 | set editing-mode vi 2 | -------------------------------------------------------------------------------- /vimrc: -------------------------------------------------------------------------------- 1 | " Use Vim settings, rather then Vi settings (much better!). 2 | " This must be first, because it changes other options as a side effect. 3 | set nocompatible 4 | 5 | " TODO: this may not be in the correct place. It is intended to allow overriding . 6 | " source ~/.vimrc.before if it exists. 7 | if filereadable(expand("~/.vimrc.before")) 8 | source ~/.vimrc.before 9 | endif 10 | 11 | " ================ General Config ==================== 12 | 13 | set number "Line numbers are good 14 | set backspace=indent,eol,start "Allow backspace in insert mode 15 | set history=1000 "Store lots of :cmdline history 16 | set showcmd "Show incomplete cmds down the bottom 17 | set showmode "Show current mode down the bottom 18 | set gcr=a:blinkon0 "Disable cursor blink 19 | set visualbell "No sounds 20 | set autoread "Reload files changed outside vim 21 | 22 | " This makes vim act like all other editors, buffers can 23 | " exist in the background without being in a window. 24 | " http://items.sjbach.com/319/configuring-vim-right 25 | set hidden 26 | 27 | "turn on syntax highlighting 28 | syntax on 29 | 30 | " Change leader to a comma because the backslash is too far away 31 | " That means all \x commands turn into ,x 32 | " The mapleader has to be set before vundle starts loading all 33 | " the plugins. 34 | let mapleader="," 35 | 36 | " =============== Vundle Initialization =============== 37 | " This loads all the plugins specified in ~/.vim/vundles.vim 38 | " Use Vundle plugin to manage all other plugins 39 | if filereadable(expand("~/.vim/vundles.vim")) 40 | source ~/.vim/vundles.vim 41 | endif 42 | au BufNewFile,BufRead *.vundle set filetype=vim 43 | 44 | " ================ Turn Off Swap Files ============== 45 | 46 | set noswapfile 47 | set nobackup 48 | set nowb 49 | 50 | " ================ Persistent Undo ================== 51 | " Keep undo history across sessions, by storing in file. 52 | " Only works all the time. 53 | if has('persistent_undo') && isdirectory(expand('~').'/.vim/backups') 54 | silent !mkdir ~/.vim/backups > /dev/null 2>&1 55 | set undodir=~/.vim/backups 56 | set undofile 57 | endif 58 | 59 | " ================ Indentation ====================== 60 | 61 | set autoindent 62 | set smartindent 63 | set smarttab 64 | set shiftwidth=2 65 | set softtabstop=2 66 | set tabstop=2 67 | set expandtab 68 | 69 | " Auto indent pasted text 70 | nnoremap p p=`] 71 | nnoremap P P=`] 72 | 73 | filetype plugin on 74 | filetype indent on 75 | 76 | " Display tabs and trailing spaces visually 77 | set list listchars=tab:\ \ ,trail:· 78 | 79 | set nowrap "Don't wrap lines 80 | set linebreak "Wrap lines at convenient points 81 | 82 | " ================ Folds ============================ 83 | 84 | set foldmethod=indent "fold based on indent 85 | set foldnestmax=3 "deepest fold is 3 levels 86 | set nofoldenable "dont fold by default 87 | 88 | " ================ Completion ======================= 89 | 90 | set wildmode=list:longest 91 | set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches 92 | set wildignore=*.o,*.obj,*~ "stuff to ignore when tab completing 93 | set wildignore+=*vim/backups* 94 | set wildignore+=*sass-cache* 95 | set wildignore+=*DS_Store* 96 | set wildignore+=vendor/rails/** 97 | set wildignore+=vendor/cache/** 98 | set wildignore+=*.gem 99 | set wildignore+=log/** 100 | set wildignore+=tmp/** 101 | set wildignore+=*.png,*.jpg,*.gif 102 | 103 | " ================ Scrolling ======================== 104 | 105 | set scrolloff=8 "Start scrolling when we're 8 lines away from margins 106 | set sidescrolloff=15 107 | set sidescroll=1 108 | 109 | " ================ Search =========================== 110 | 111 | set incsearch " Find the next match as we type the search 112 | set hlsearch " Highlight searches by default 113 | set ignorecase " Ignore case when searching... 114 | set smartcase " ...unless we type a capital 115 | 116 | " ================ Security ========================== 117 | set modelines=0 118 | set nomodeline 119 | 120 | " ================ Custom Settings ======================== 121 | so ~/.yadr/vim/settings.vim 122 | -------------------------------------------------------------------------------- /zsh/0000_before.zsh: -------------------------------------------------------------------------------- 1 | # Load any user customizations prior to load 2 | # 3 | if [ -d $HOME/.zsh.before/ ]; then 4 | if [ "$(ls -A $HOME/.zsh.before/)" ]; then 5 | for config_file ($HOME/.zsh.before/*.zsh) source $config_file 6 | fi 7 | fi 8 | -------------------------------------------------------------------------------- /zsh/0_path.zsh: -------------------------------------------------------------------------------- 1 | # path, the 0 in the filename causes this to load first 2 | 3 | pathAppend() { 4 | # Only adds to the path if it's not already there 5 | if ! echo $PATH | egrep -q "(^|:)$1($|:)" ; then 6 | PATH=$PATH:$1 7 | fi 8 | } 9 | 10 | # Remove duplicate entries from PATH: 11 | PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++{if (NR > 1) printf ORS; printf $a[$1]}') 12 | 13 | pathAppend "$HOME/.yadr/bin" 14 | pathAppend "$HOME/.yadr/bin/yadr" 15 | -------------------------------------------------------------------------------- /zsh/aliases.zsh: -------------------------------------------------------------------------------- 1 | # Aliases in this file are bash and zsh compatible 2 | 3 | # Don't change. The following determines where YADR is installed. 4 | yadr=$HOME/.yadr 5 | 6 | # Get operating system 7 | platform='unknown' 8 | unamestr=$(uname) 9 | if [[ $unamestr == 'Linux' ]]; then 10 | platform='linux' 11 | elif [[ $unamestr == 'Darwin' ]]; then 12 | platform='darwin' 13 | fi 14 | 15 | # YADR support 16 | alias yav='yadr vim-add-plugin' 17 | alias ydv='yadr vim-delete-plugin' 18 | alias ylv='yadr vim-list-plugin' 19 | alias yup='yadr update-plugins' 20 | alias yip='yadr init-plugins' 21 | 22 | # PS 23 | alias psa="ps aux" 24 | alias psg="ps aux | grep " 25 | alias psr='ps aux | grep ruby' 26 | 27 | # Moving around 28 | alias cdb='cd -' 29 | alias cls='clear;ls' 30 | 31 | # Show human friendly numbers and colors 32 | alias df='df -h' 33 | alias du='du -h -d 2' 34 | 35 | if [[ $platform == 'linux' ]]; then 36 | alias ll='ls -alh --color=auto' 37 | alias ls='ls --color=auto' 38 | elif [[ $platform == 'darwin' ]]; then 39 | alias ll='ls -alGh' 40 | alias ls='ls -Gh' 41 | fi 42 | 43 | # show me files matching "ls grep" 44 | alias lsg='ll | grep' 45 | 46 | # Alias Editing 47 | TRAPHUP() { 48 | source $yadr/zsh/aliases.zsh 49 | } 50 | 51 | alias ae='vim $yadr/zsh/aliases.zsh' #alias edit 52 | alias ar='source $yadr/zsh/aliases.zsh' #alias reload 53 | alias gar="killall -HUP -u \"$USER\" zsh" #global alias reload 54 | 55 | # vim using 56 | mvim --version > /dev/null 2>&1 57 | MACVIM_INSTALLED=$? 58 | if [ $MACVIM_INSTALLED -eq 0 ]; then 59 | alias vim="mvim -v" 60 | fi 61 | 62 | # mimic vim functions 63 | alias :q='exit' 64 | 65 | # vimrc editing 66 | alias ve='vim ~/.vimrc' 67 | 68 | # zsh profile editing 69 | alias ze='vim ~/.zshrc' 70 | 71 | # Git Aliases 72 | alias gs='git status' 73 | alias gstsh='git stash' 74 | alias gst='git stash' 75 | alias gsp='git stash pop' 76 | alias gsa='git stash apply' 77 | alias gsh='git show' 78 | alias gshw='git show' 79 | alias gshow='git show' 80 | alias gi='vim .gitignore' 81 | alias gcm='git ci -m' 82 | alias gcim='git ci -m' 83 | alias gci='git ci' 84 | alias gco='git co' 85 | alias gcp='git cp' 86 | alias ga='git add -A' 87 | alias gap='git add -p' 88 | alias guns='git unstage' 89 | alias gunc='git uncommit' 90 | alias gm='git merge' 91 | alias gms='git merge --squash' 92 | alias gam='git amend --reset-author' 93 | alias grv='git remote -v' 94 | alias grr='git remote rm' 95 | alias grad='git remote add' 96 | alias gr='git rebase' 97 | alias gra='git rebase --abort' 98 | alias ggrc='git rebase --continue' 99 | alias gbi='git rebase --interactive' 100 | alias gl='git l' 101 | alias glg='git l' 102 | alias glog='git l' 103 | alias co='git co' 104 | alias gf='git fetch' 105 | alias gfp='git fetch --prune' 106 | alias gfa='git fetch --all' 107 | alias gfap='git fetch --all --prune' 108 | alias gfch='git fetch' 109 | alias gd='git diff' 110 | alias gb='git b' 111 | # Staged and cached are the same thing 112 | alias gdc='git diff --cached -w' 113 | alias gds='git diff --staged -w' 114 | alias gpub='grb publish' 115 | alias gtr='grb track' 116 | alias gpl='git pull' 117 | alias gplr='git pull --rebase' 118 | alias gps='git push' 119 | alias gpsh='git push -u origin `git rev-parse --abbrev-ref HEAD`' 120 | alias gnb='git nb' # new branch aka checkout -b 121 | alias grs='git reset' 122 | alias grsh='git reset --hard' 123 | alias gcln='git clean' 124 | alias gclndf='git clean -df' 125 | alias gclndfx='git clean -dfx' 126 | alias gsm='git submodule' 127 | alias gsmi='git submodule init' 128 | alias gsmu='git submodule update' 129 | alias gt='git t' 130 | alias gbg='git bisect good' 131 | alias gbb='git bisect bad' 132 | alias gdmb='git branch --merged | grep -v "\*" | xargs -n 1 git branch -d' 133 | 134 | # Common shell functions 135 | alias less='less -r' 136 | alias tf='tail -f' 137 | alias l='less' 138 | alias lh='ls -alt | head' # see the last modified files 139 | alias screen='TERM=screen screen' 140 | alias cl='clear' 141 | 142 | # Zippin 143 | alias gz='tar -zcvf' 144 | 145 | # Ruby 146 | alias c='rails c' # Rails 3 147 | alias co='script/console' # Rails 2 148 | alias cod='script/console --debugger' 149 | 150 | #If you want your thin to listen on a port for local VM development 151 | #export VM_IP=10.0.0.1 <-- your vm ip 152 | alias ts='thin start -a ${VM_IP:-127.0.0.1}' 153 | alias ms='mongrel_rails start' 154 | alias tfdl='tail -f log/development.log' 155 | alias tftl='tail -f log/test.log' 156 | 157 | alias ka9='killall -9' 158 | alias k9='kill -9' 159 | 160 | # Gem install 161 | alias sgi='sudo gem install --no-ri --no-rdoc' 162 | 163 | # TODOS 164 | # This uses NValt (NotationalVelocity alt fork) - http://brettterpstra.com/project/nvalt/ 165 | # to find the note called 'todo' 166 | alias todo='open nvalt://find/todo' 167 | 168 | # Forward port 80 to 3000 169 | alias portforward='sudo ipfw add 1000 forward 127.0.0.1,3000 ip from any to any 80 in' 170 | 171 | alias rdm='rake db:migrate' 172 | alias rdmr='rake db:migrate:redo' 173 | 174 | # Zeus 175 | alias zs='zeus server' 176 | alias zc='zeus console' 177 | alias zr='zeus rspec' 178 | alias zrc='zeus rails c' 179 | alias zrs='zeus rails s' 180 | alias zrdbm='zeus rake db:migrate' 181 | alias zrdbtp='zeus rake db:test:prepare' 182 | alias zzz='rm .zeus.sock; pkill zeus; zeus start' 183 | 184 | # Rspec 185 | alias rs='rspec spec' 186 | alias sr='spring rspec' 187 | alias src='spring rails c' 188 | alias srgm='spring rails g migration' 189 | alias srdm='spring rake db:migrate' 190 | alias srdt='spring rake db:migrate' 191 | alias srdmt='spring rake db:migrate db:test:prepare' 192 | 193 | 194 | # Sprintly - https://github.com/nextbigsoundinc/Sprintly-GitHub 195 | alias sp='sprintly' 196 | # spb = sprintly branch - create a branch automatically based on the bug you're working on 197 | alias spb="git checkout -b \`sp | tail -2 | grep '#' | sed 's/^ //' | sed 's/[^A-Za-z0-9 ]//g' | sed 's/ /-/g' | cut -d"-" -f1,2,3,4,5\`" 198 | 199 | alias hpr='hub pull-request' 200 | alias grb='git recent-branches' 201 | 202 | # Finder 203 | alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app' 204 | alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app' 205 | 206 | alias dbtp='spring rake db:test:prepare' 207 | alias dbm='spring rake db:migrate' 208 | alias dbmr='spring rake db:migrate:redo' 209 | alias dbmd='spring rake db:migrate:down' 210 | alias dbmu='spring rake db:migrate:up' 211 | 212 | # Homebrew 213 | alias brewu='brew update && brew upgrade && brew cleanup && brew doctor' 214 | -------------------------------------------------------------------------------- /zsh/colors.zsh: -------------------------------------------------------------------------------- 1 | export GREP_COLOR='1;33' 2 | -------------------------------------------------------------------------------- /zsh/custom_prompt_path.zsh: -------------------------------------------------------------------------------- 1 | #Load themes from yadr and from user's custom prompts (themes) in ~/.zsh.prompts 2 | autoload promptinit 3 | fpath=($HOME/.yadr/zsh/prezto-themes $HOME/.zsh.prompts $fpath) 4 | promptinit 5 | -------------------------------------------------------------------------------- /zsh/fasd.zsh: -------------------------------------------------------------------------------- 1 | # 2 | # only init if installed. 3 | fasd_cache="$HOME/.fasd-init-bash" 4 | if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then 5 | eval "$(fasd --init posix-alias zsh-hook zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install)" >| "$fasd_cache" 6 | fi 7 | source "$fasd_cache" 8 | unset fasd_cache 9 | 10 | 11 | # jump to recently used items 12 | alias a='fasd -a' # any 13 | alias s='fasd -si' # show / search / select 14 | alias d='fasd -d' # directory 15 | alias f='fasd -f' # file 16 | alias z='fasd_cd -d' # cd, same functionality as j in autojump 17 | alias zz='fasd_cd -d -i' # interactive directory jump 18 | -------------------------------------------------------------------------------- /zsh/git.zsh: -------------------------------------------------------------------------------- 1 | # Makes git auto completion faster favouring for local completions 2 | __git_files () { 3 | _wanted files expl 'local files' _files 4 | } 5 | -------------------------------------------------------------------------------- /zsh/key-bindings.zsh: -------------------------------------------------------------------------------- 1 | # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html 2 | # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins 3 | # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets 4 | 5 | bindkey -v # Use vi key bindings 6 | bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line. 7 | 8 | # emacs style 9 | bindkey '^a' beginning-of-line 10 | bindkey '^e' end-of-line 11 | 12 | # Make numpad enter work 13 | bindkey -s "^[Op" "0" 14 | bindkey -s "^[Ol" "." 15 | bindkey -s "^[OM" "^M" 16 | 17 | -------------------------------------------------------------------------------- /zsh/last-command.zsh: -------------------------------------------------------------------------------- 1 | # Use Ctrl-x,Ctrl-l to get the output of the last command 2 | zmodload -i zsh/parameter 3 | insert-last-command-output() { 4 | LBUFFER+="$(eval $history[$((HISTCMD-1))])" 5 | } 6 | zle -N insert-last-command-output 7 | bindkey "^X^L" insert-last-command-output 8 | -------------------------------------------------------------------------------- /zsh/noglob.zsh: -------------------------------------------------------------------------------- 1 | # Don't try to glob with zsh so you can do 2 | # stuff like ga *foo* and correctly have 3 | # git add the right stuff 4 | alias git='noglob git' 5 | -------------------------------------------------------------------------------- /zsh/prezto-override/zpreztorc: -------------------------------------------------------------------------------- 1 | # 2 | # Sets Prezto options. 3 | # 4 | # Authors: 5 | # Sorin Ionescu 6 | # 7 | 8 | # 9 | # General 10 | # 11 | 12 | # Set case-sensitivity for completion, history lookup, etc. 13 | zstyle ':prezto:*:*' case-sensitive 'no' 14 | 15 | # Color output (auto set to 'no' on dumb terminals). 16 | zstyle ':prezto:*:*' color 'yes' 17 | 18 | # Set the Zsh modules to load (man zshmodules). 19 | # zstyle ':prezto:load' zmodule 'attr' 'stat' 20 | 21 | # Set the Zsh functions to load (man zshcontrib). 22 | # zstyle ':prezto:load' zfunction 'zargs' 'zmv' 23 | 24 | # Set the Prezto modules to load (browse modules). 25 | # The order matters. 26 | zstyle ':prezto:load' pmodule \ 27 | 'environment' \ 28 | 'terminal' \ 29 | 'editor' \ 30 | 'history' \ 31 | 'directory' \ 32 | 'spectrum' \ 33 | 'utility' \ 34 | 'completion' \ 35 | 'archive' \ 36 | 'fasd' \ 37 | 'git' \ 38 | 'osx' \ 39 | 'ruby' \ 40 | 'syntax-highlighting' \ 41 | 'history-substring-search' \ 42 | 'ssh' \ 43 | 'prompt' 44 | 45 | # 46 | # Editor 47 | # 48 | 49 | # Set the key mapping style to 'emacs' or 'vi'. 50 | zstyle ':prezto:module:editor' key-bindings 'emacs' 51 | 52 | # Auto convert .... to ../.. 53 | # zstyle ':prezto:module:editor' dot-expansion 'yes' 54 | 55 | # 56 | # Git 57 | # 58 | 59 | # Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'. 60 | # zstyle ':prezto:module:git:status:ignore' submodules 'all' 61 | 62 | # 63 | # GNU Utility 64 | # 65 | 66 | # Set the command prefix on non-GNU systems. 67 | # zstyle ':prezto:module:gnu-utility' prefix 'g' 68 | 69 | # 70 | # Pacman 71 | # 72 | 73 | # Set the Pacman frontend. 74 | # zstyle ':prezto:module:pacman' frontend 'yaourt' 75 | 76 | # 77 | # Prompt 78 | # 79 | 80 | # Set the prompt theme to load. 81 | # Setting it to 'random' loads a random theme. 82 | # Auto set to 'off' on dumb terminals. 83 | zstyle ':prezto:module:prompt' theme 'sorin' 84 | 85 | # 86 | # Screen 87 | # 88 | 89 | # Auto start a session when Zsh is launched. 90 | # zstyle ':prezto:module:screen' auto-start 'yes' 91 | 92 | # 93 | # GPG-Agent 94 | # 95 | 96 | # Enable SSH-Agent protocol emulation. 97 | # zstyle ':prezto:module:gpg-agent' ssh-support 'yes' 98 | 99 | # 100 | # SSH-Agent 101 | # 102 | 103 | # Enable ssh-agent forwarding. 104 | zstyle ':prezto:module:ssh-agent' forwarding 'yes' 105 | 106 | # Set ssh-agent identities to load. 107 | # zstyle ':prezto:module:ssh-agent' identities 'id_rsa' 'id_rsa2' 'id_github' 108 | 109 | # 110 | # Syntax Highlighting 111 | # 112 | 113 | # Set syntax highlighters. 114 | # By default main, brackets, and cursor are enabled. 115 | # zstyle ':prezto:module:syntax-highlighting' highlighters \ 116 | # 'main' \ 117 | # 'brackets' \ 118 | # 'pattern' \ 119 | # 'cursor' \ 120 | # 'root' 121 | 122 | # 123 | # Terminal 124 | # 125 | 126 | # Auto set the tab and window titles. 127 | zstyle ':prezto:module:terminal' auto-title 'yes' 128 | 129 | # 130 | # Tmux 131 | # 132 | 133 | # Auto start a session when Zsh is launched. 134 | # zstyle ':prezto:module:tmux' auto-start 'yes' 135 | 136 | -------------------------------------------------------------------------------- /zsh/prezto-override/zshrc: -------------------------------------------------------------------------------- 1 | source $HOME/.zprezto/runcoms/zshrc 2 | 3 | for config_file ($HOME/.yadr/zsh/*.zsh) source $config_file 4 | -------------------------------------------------------------------------------- /zsh/prezto-themes/prompt_agnoster_setup: -------------------------------------------------------------------------------- 1 | # vim:ft=zsh ts=2 sw=2 sts=2 2 | # 3 | # agnoster's Theme - https://gist.github.com/3712874 4 | # A Powerline-inspired theme for ZSH 5 | # 6 | # # README 7 | # 8 | # In order for this theme to render correctly, you will need a 9 | # [Powerline-patched font](https://gist.github.com/1595572). 10 | # 11 | # In addition, I recommend the 12 | # [Solarized theme](https://github.com/altercation/solarized/) and, if you're 13 | # using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - 14 | # it has significantly better color fidelity. 15 | # 16 | # # Goals 17 | # 18 | # The aim of this theme is to only show you *relevant* information. Like most 19 | # prompts, it will only show git information when in a git working directory. 20 | # However, it goes a step further: everything from the current user and 21 | # hostname to whether the last call exited with an error to whether background 22 | # jobs are running in this shell will all be displayed automatically when 23 | # appropriate. 24 | 25 | ### Segment drawing 26 | # A few utility functions to make it easy and re-usable to draw segmented prompts 27 | 28 | CURRENT_BG='NONE' 29 | SEGMENT_SEPARATOR='⮀' 30 | 31 | # Customizations 32 | 33 | # Checks if working tree is dirty 34 | # From robbyrussell/oh-my-zsh 35 | parse_git_dirty() { 36 | local SUBMODULE_SYNTAX='' 37 | local GIT_STATUS='' 38 | local CLEAN_MESSAGE='nothing to commit (working directory clean)' 39 | if [[ "$(command git config --get oh-my-zsh.hide-status)" != "1" ]]; then 40 | if [[ $POST_1_7_2_GIT -gt 0 ]]; then 41 | SUBMODULE_SYNTAX="--ignore-submodules=dirty" 42 | fi 43 | if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then 44 | GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1) 45 | else 46 | GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1) 47 | fi 48 | if [[ -n $GIT_STATUS ]]; then 49 | echo "$ZSH_THEME_GIT_PROMPT_DIRTY" 50 | else 51 | echo "$ZSH_THEME_GIT_PROMPT_CLEAN" 52 | fi 53 | else 54 | echo "$ZSH_THEME_GIT_PROMPT_CLEAN" 55 | fi 56 | } 57 | 58 | # Takes two arguments, background and foreground. Both can be omitted, 59 | # rendering default background/foreground. 60 | prompt_segment() { 61 | local bg fg 62 | [[ -n $1 ]] && bg="%K{$1}" || bg="%k" 63 | [[ -n $2 ]] && fg="%F{$2}" || fg="%f" 64 | if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then 65 | echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " 66 | else 67 | echo -n "%{$bg%}%{$fg%} " 68 | fi 69 | CURRENT_BG=$1 70 | [[ -n $3 ]] && echo -n $3 71 | } 72 | 73 | # End the prompt, closing any open segments 74 | prompt_end() { 75 | if [[ -n $CURRENT_BG ]]; then 76 | echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" 77 | else 78 | echo -n "%{%k%}" 79 | fi 80 | echo -n "%{%f%}" 81 | CURRENT_BG='' 82 | } 83 | 84 | ### Prompt components 85 | # Each component will draw itself, and hide itself if no information needs to be shown 86 | 87 | # Context: user@hostname (who am I and where am I) 88 | prompt_context() { 89 | local user=`whoami` 90 | 91 | if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then 92 | prompt_segment black default "%(!.%{%F{yellow}%}.)$user@%m" 93 | fi 94 | } 95 | 96 | # Git: branch/detached head, dirty status 97 | prompt_git() { 98 | local ref dirty 99 | if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then 100 | ZSH_THEME_GIT_PROMPT_DIRTY='±' 101 | dirty=$(parse_git_dirty) 102 | ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" 103 | if [[ -n $dirty ]]; then 104 | prompt_segment yellow black 105 | else 106 | prompt_segment green black 107 | fi 108 | echo -n "${ref/refs\/heads\//⭠ }$dirty" 109 | fi 110 | } 111 | 112 | # Dir: current working directory 113 | prompt_dir() { 114 | prompt_segment blue black '%~' 115 | } 116 | 117 | # Status: 118 | # - was there an error 119 | # - am I root 120 | # - are there background jobs? 121 | prompt_status() { 122 | local symbols 123 | symbols=() 124 | [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" 125 | [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" 126 | [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" 127 | 128 | [[ -n "$symbols" ]] && prompt_segment black default "$symbols" 129 | } 130 | 131 | ## Main prompt 132 | build_prompt() { 133 | RETVAL=$? 134 | prompt_status 135 | prompt_context 136 | prompt_dir 137 | prompt_git 138 | prompt_end 139 | } 140 | 141 | PROMPT='%{%f%b%k%}$(build_prompt) ' 142 | -------------------------------------------------------------------------------- /zsh/prezto-themes/prompt_kylewest_setup: -------------------------------------------------------------------------------- 1 | # 2 | # A theme based on sorin theme 3 | # * ruby info shown on the right 4 | # * git info on the left 5 | # * editor mode as $> or <# 6 | # * single line prompt 7 | # 8 | # Authors: 9 | # Sorin Ionescu 10 | # Kyle West 11 | 12 | function prompt_kylewest_precmd { 13 | setopt LOCAL_OPTIONS 14 | unsetopt XTRACE KSH_ARRAYS 15 | 16 | # Get Git repository information. 17 | if (( $+functions[git-info] )); then 18 | git-info on 19 | git-info 20 | fi 21 | 22 | # Get ruby information 23 | if (( $+functions[ruby-info] )); then 24 | ruby-info 25 | fi 26 | } 27 | 28 | function prompt_kylewest_setup { 29 | setopt LOCAL_OPTIONS 30 | unsetopt XTRACE KSH_ARRAYS 31 | prompt_opts=(cr percent subst) 32 | 33 | # Load required functions. 34 | autoload -Uz add-zsh-hook 35 | 36 | # Add hook for calling git-info before each command. 37 | add-zsh-hook precmd prompt_kylewest_precmd 38 | 39 | # editor 40 | zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b' 41 | zstyle ':prezto:module:editor:info:keymap:primary' format "%B%F{green}$>%f%b" 42 | zstyle ':prezto:module:editor:info:keymap:alternate' format "%B%F{magenta}<#%f%b" 43 | 44 | # ruby info (rvm, rbenv) 45 | zstyle ':prezto:module:ruby:info:version' format '[ %v ]' 46 | 47 | # vcs 48 | zstyle ':prezto:module:git:info:branch' format '%F{yellow}%b%f' 49 | zstyle ':prezto:module:git:info:dirty' format '%B%F{red}!%f%b' 50 | zstyle ':prezto:module:git:info:keys' format 'prompt' '- %b%D ' 51 | 52 | # prompts 53 | PROMPT='%F{cyan}%c%f ${git_info[prompt]}${editor_info[keymap]} ' 54 | RPROMPT='%F{blue}${ruby_info[version]}' 55 | } 56 | 57 | prompt_kylewest_setup "$@" 58 | -------------------------------------------------------------------------------- /zsh/prezto-themes/prompt_skwp_setup: -------------------------------------------------------------------------------- 1 | # 2 | # A theme based on steeef theme 3 | # * RVM/Rbenv info shown on the right 4 | # * Git branch info on the left 5 | # * Single line prompt 6 | # 7 | # Authors: 8 | # Steve Losh 9 | # Bart Trojanowski 10 | # Brian Carper 11 | # steeef 12 | # Sorin Ionescu 13 | # Yan Pritzker 14 | 15 | function prompt_skwp_precmd { 16 | setopt LOCAL_OPTIONS 17 | unsetopt XTRACE KSH_ARRAYS 18 | 19 | # Get Git repository information. 20 | if (( $+functions[git-info] )); then 21 | git-info on 22 | git-info 23 | fi 24 | 25 | # Get ruby information 26 | if (( $+functions[ruby-info] )); then 27 | ruby-info 28 | fi 29 | } 30 | 31 | function prompt_skwp_setup { 32 | setopt LOCAL_OPTIONS 33 | unsetopt XTRACE KSH_ARRAYS 34 | prompt_opts=(cr percent sp subst) 35 | 36 | autoload -Uz add-zsh-hook 37 | 38 | add-zsh-hook precmd prompt_skwp_precmd 39 | 40 | # Use extended color pallete if available. 41 | if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then 42 | __PROMPT_SKWP_COLORS=( 43 | "%F{81}" # turquoise 44 | "%F{166}" # orange 45 | "%F{135}" # purple 46 | "%F{161}" # hotpink 47 | "%F{118}" # limegreen 48 | ) 49 | else 50 | __PROMPT_SKWP_COLORS=( 51 | "%F{cyan}" 52 | "%F{yellow}" 53 | "%F{magenta}" 54 | "%F{red}" 55 | "%F{green}" 56 | ) 57 | fi 58 | 59 | # git 60 | zstyle ':prezto:module:git:info:branch' format "${__PROMPT_SKWP_COLORS[1]}%b%f" 61 | zstyle ':prezto:module:git:info:added' format "${__PROMPT_SKWP_COLORS[5]}●%f" 62 | zstyle ':prezto:module:git:info:deleted' format "${__PROMPT_SKWP_COLORS[2]}●%f" 63 | zstyle ':prezto:module:git:info:modified' format "${__PROMPT_SKWP_COLORS[4]}●%f" 64 | zstyle ':prezto:module:git:info:untracked' format "${__PROMPT_SKWP_COLORS[3]}●%f" 65 | zstyle ':prezto:module:git:info:keys' format 'prompt' '(%b%d%a%m%u)' 66 | 67 | # ruby info (rvm, rbenv) 68 | zstyle ':prezto:module:ruby:info:version' format '[%v]' 69 | 70 | PROMPT="${__PROMPT_SKWP_COLORS[3]}%n%f@${__PROMPT_SKWP_COLORS[2]}%m%f ${__PROMPT_SKWP_COLORS[5]}%~%f "'$git_info[prompt]'"$ " 71 | RPROMPT='%F{blue}${ruby_info[version]}' 72 | } 73 | 74 | prompt_skwp_setup "$@" 75 | -------------------------------------------------------------------------------- /zsh/prezto-themes/prompt_steeef_simplified_setup: -------------------------------------------------------------------------------- 1 | # 2 | # A theme based on Steve Losh's Extravagant Prompt with vcs_info integration. 3 | # 4 | # Authors: 5 | # Steve Losh 6 | # Bart Trojanowski 7 | # Brian Carper 8 | # steeef_simplified 9 | # Sorin Ionescu 10 | # 11 | # Screenshots: 12 | # http://i.imgur.com/HyRvv.png 13 | # 14 | 15 | function prompt_steeef_simplified_precmd { 16 | # Check for untracked files or updated submodules since vcs_info does not. 17 | if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then 18 | branch_format="(${_prompt_steeef_simplified_colors[1]}%b%f%u%c${_prompt_steeef_simplified_colors[4]}●%f)" 19 | else 20 | branch_format="(${_prompt_steeef_simplified_colors[1]}%b%f%u%c)" 21 | fi 22 | 23 | zstyle ':vcs_info:*:prompt:*' formats "${branch_format}" 24 | 25 | vcs_info 'prompt' 26 | 27 | if (( $+functions[python-info] )); then 28 | python-info 29 | fi 30 | 31 | # Get ruby information 32 | if (( $+functions[ruby-info] )); then 33 | ruby-info 34 | fi 35 | } 36 | 37 | function prompt_steeef_simplified_setup { 38 | setopt LOCAL_OPTIONS 39 | unsetopt XTRACE KSH_ARRAYS 40 | prompt_opts=(cr percent subst) 41 | 42 | # Load required functions. 43 | autoload -Uz add-zsh-hook 44 | autoload -Uz vcs_info 45 | 46 | # Add hook for calling vcs_info before each command. 47 | add-zsh-hook precmd prompt_steeef_simplified_precmd 48 | 49 | # Use extended color pallete if available. 50 | if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then 51 | _prompt_steeef_simplified_colors=( 52 | "%F{81}" # Turquoise 53 | "%F{166}" # Orange 54 | "%F{135}" # Purple 55 | "%F{161}" # Hotpink 56 | "%F{118}" # Limegreen 57 | ) 58 | else 59 | _prompt_steeef_simplified_colors=( 60 | "%F{cyan}" 61 | "%F{yellow}" 62 | "%F{magenta}" 63 | "%F{red}" 64 | "%F{green}" 65 | ) 66 | fi 67 | 68 | # Formats: 69 | # %b - branchname 70 | # %u - unstagedstr (see below) 71 | # %c - stagedstr (see below) 72 | # %a - action (e.g. rebase-i) 73 | # %R - repository path 74 | # %S - path in the repository 75 | local branch_format="(${_prompt_steeef_simplified_colors[1]}%b%f%u%c)" 76 | local action_format="(${_prompt_steeef_simplified_colors[5]}%a%f)" 77 | local unstaged_format="${_prompt_steeef_simplified_colors[2]}●%f" 78 | local staged_format="${_prompt_steeef_simplified_colors[5]}●%f" 79 | 80 | # Set vcs_info parameters. 81 | zstyle ':vcs_info:*' enable bzr git hg svn 82 | zstyle ':vcs_info:*:prompt:*' check-for-changes true 83 | zstyle ':vcs_info:*:prompt:*' unstagedstr "${unstaged_format}" 84 | zstyle ':vcs_info:*:prompt:*' stagedstr "${staged_format}" 85 | zstyle ':vcs_info:*:prompt:*' actionformats "${branch_format}${action_format}" 86 | zstyle ':vcs_info:*:prompt:*' formats "${branch_format}" 87 | zstyle ':vcs_info:*:prompt:*' nvcsformats "" 88 | 89 | # Set python-info parameters. 90 | zstyle ':prezto:module:python:info:virtualenv' format '(%v)' 91 | 92 | # Define prompts. 93 | PROMPT="${_prompt_steeef_simplified_colors[3]}%n%f@${_prompt_steeef_simplified_colors[2]}%m%f ${_prompt_steeef_simplified_colors[5]}%~%f "'${vcs_info_msg_0_}'"$ " 94 | RPROMPT='%F{blue}${ruby_info[version]}' 95 | } 96 | 97 | prompt_steeef_simplified_setup "$@" 98 | 99 | -------------------------------------------------------------------------------- /zsh/rm.zsh: -------------------------------------------------------------------------------- 1 | # Override rm -i alias which makes rm prompt for every action 2 | alias rm='nocorrect rm' 3 | -------------------------------------------------------------------------------- /zsh/secrets.zsh: -------------------------------------------------------------------------------- 1 | if [ -e ~/.secrets ]; then 2 | source ~/.secrets 3 | fi 4 | -------------------------------------------------------------------------------- /zsh/theme.zsh: -------------------------------------------------------------------------------- 1 | prompt skwp 2 | -------------------------------------------------------------------------------- /zsh/vi-mode.zsh: -------------------------------------------------------------------------------- 1 | set -o vi 2 | export EDITOR=vim 3 | export VISUAL=vim 4 | -------------------------------------------------------------------------------- /zsh/zmv.zsh: -------------------------------------------------------------------------------- 1 | # Use zmv, which is amazing 2 | autoload -U zmv 3 | alias zmv="noglob zmv -W" 4 | 5 | -------------------------------------------------------------------------------- /zsh/zsh-aliases.zsh: -------------------------------------------------------------------------------- 1 | # Global aliases 2 | alias -g ...='../..' 3 | alias -g ....='../../..' 4 | alias -g .....='../../../..' 5 | alias -g C='| wc -l' 6 | alias -g H='| head' 7 | alias -g L="| less" 8 | alias -g N="| /dev/null" 9 | alias -g S='| sort' 10 | alias -g G='| grep' # now you can do: ls foo G something 11 | 12 | # Functions 13 | # 14 | # (f)ind by (n)ame 15 | # usage: fn foo 16 | # to find all files containing 'foo' in the name 17 | function fn() { ls **/*$1* } 18 | 19 | -------------------------------------------------------------------------------- /zsh/zzzz_after.zsh: -------------------------------------------------------------------------------- 1 | # Load any custom after code 2 | if [ -d $HOME/.zsh.after/ ]; then 3 | if [ "$(ls -A $HOME/.zsh.after/)" ]; then 4 | for config_file ($HOME/.zsh.after/*.zsh) source $config_file 5 | fi 6 | fi 7 | --------------------------------------------------------------------------------