2011-12-07 13:57:45 +08:00
YADR: Yet Another Dotfile Repo
2011-11-18 05:45:33 +08:00
====
2011-12-07 13:57:45 +08:00
Warning: These dotfiles are opinionated!
2011-11-18 06:40:21 +08:00
2011-12-07 13:57:45 +08:00
This is a collection of best of breed tools from across the web,
from scouring other people's dotfile repos, blogs, and projects.
In some ways, this is an alternative to janus (https://github.com/carlhuda/janus), offering
many of the same plugins, with minor differnces. But it's also much more,
providing shell customizations (zsh), an irb replacement (pry) with customizations,
and osx settings that are developer friendly (such as fast key repeat),
and remapping your caps-lock to be Esc for vim.
The strongly held opinions expressed here:
2011-12-08 12:54:03 +08:00
---
* This configuration is for OSX, MacVim, zsh, and pry instead of irb.
* Apple-style philosophy: not a lot of choices, but everything Just Works and Looks Good.
2011-12-07 13:57:45 +08:00
* All common commands should be two and three character mnemonic aliases - less keystrokes, RSI reduction
* Most used vim commands should be under your fingertips (home row, prefer Shift to other command keys)
* Avoid stressful hand motions, e.g. remap Esc to caps lock key, remap underscore to Alt-k in vim
2011-12-08 12:54:03 +08:00
* Easy to use plugin architecture, no config files to edit.
* Pick one tool and use it everywhere: vim-ize everything
* Colors are _important_ - solarized (http://ethanschoonover.com/solarized) is a great looking scheme that is scientifically designed to be awesome.
Differences from janus:
---
* Much larger and (imho) better curated list of vim plugins
* Optimized for one color scheme (solarized) means everything Just Looks Good
2011-12-08 15:27:41 +08:00
* Easy plugin management system using **yadr** command which is a thin shell over git submodules - no editing of config files
2011-12-08 12:54:03 +08:00
* No need to replace your vimrc, instead uses overridable submodules (Coming Soon)
2011-12-08 15:27:41 +08:00
* More than just vim plugins - great shell aliases, osx, and irb/pry tweaks to make you more productive
2011-12-07 13:57:45 +08:00
Before you start
---
2011-12-08 15:27:41 +08:00
* Remap caps-lock to escape: http://pqrs.org/macosx/keyremap4macbook/extra.html
2011-12-07 13:57:45 +08:00
2011-12-08 15:27:41 +08:00
Installation
---
2011-12-07 13:57:45 +08:00
2011-12-08 15:27:41 +08:00
Coming Soon: gem-based installation
2011-11-18 06:40:21 +08:00
2011-12-08 15:27:41 +08:00
This project uses git submodules for its plugins, but this is handled
for you by the **yadr** command. Please run:
git clone https://github.com/skwp/dotfiles ~/.dotfiles
~/.dotfiles/bin/yadr/yadr init-plugins
2011-11-19 00:19:31 +08:00
2011-12-08 15:27:41 +08:00
NOTE: by default, YADR will not touch any of your files. You have to manually
activate each of its components, if you choose, by following the sections below.
Eventually these will be automated.
2011-11-19 00:19:31 +08:00
2011-12-08 15:27:41 +08:00
If you pull new changes, be sure to run this to init all the submodules:
2011-11-19 00:19:31 +08:00
2011-12-08 15:27:41 +08:00
yadr init-plugins
After you install yadr shell aliases, you can use the *yip* alias to do the same.
2011-12-09 02:05:53 +08:00
Please note that init-plugins will automatically compile the CommandT plugin for you.
2011-11-19 00:19:31 +08:00
2011-11-23 09:02:36 +08:00
Setup for ZSH
---
2011-12-08 15:27:41 +08:00
After a lifetime of bash, I am now using ZSH as my default shell because of its awesome globbing
2011-12-07 13:57:45 +08:00
and autocomplete features (the spelling fixer autocomplete is worth the money alone).
2011-12-08 15:27:41 +08:00
Migrating from bash to zsh is essentially pain free. The zshrc provided here
restores the only feature that I felt was 'broken' which is the Ctrl-R reverse history search.
While I am not going to support bash out of the box here, YADR _should_ work with bash if
you just source the _aliases_ file. However, I recommend taking 5 mins and upgrading to zsh
with this completely automated command courtesy of oh-my-zsh:
2011-11-23 09:02:36 +08:00
2011-12-08 15:27:41 +08:00
wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
2011-11-23 09:02:36 +08:00
Place this as the last line in your ~/.zshrc created by oh-my-zsh:
2011-12-07 18:48:00 +08:00
source ~/.dotfiles/zsh/zshrc
2011-11-23 09:02:36 +08:00
2011-12-07 13:57:45 +08:00
Lots of things I do every day are done with two or three character
mnemonic aliases. Please feel free to edit them:
2011-11-18 05:45:33 +08:00
ae # alias edit
ar # alias reload
2011-12-08 15:27:41 +08:00
Here are some of the customizations provided in ~/.dotfiles/zshrc:
2011-12-07 13:57:45 +08:00
* Vim mode
* Bash style ctrl-R for reverse history finder
2011-12-08 15:27:41 +08:00
* Fuzzy matching - if you mistype a directory name, tab completion will fix it
2011-12-07 13:57:45 +08:00
2011-12-06 16:40:44 +08:00
Setup for Pry
---
Pry (http://pry.github.com/) offers a much better out of the box IRB experience
with colors, tab completion, and lots of other tricks. You should:
gem install pry
gem install awesome_print
ln -s ~/.dotfiles/irb/pryrc ~/.pryrc
ln -s ~/.dotfiles/irb/aprc ~/.aprc
2011-12-07 13:57:45 +08:00
Use pry
* as irb: 'pry'
* as rails console: script/console --irb=pry
Pry customizations:
* 'clear' command to clear screen
* 'sql' command to execute something (within a rails console)
* all objects displayed in readable format (colorized, sorted hash keys) - via awesome_print
* a few color modifications to make it more useable
* type 'help' to see all the commands
2011-12-06 16:40:44 +08:00
2011-11-18 06:50:58 +08:00
Setup for Vim
---
2011-11-18 05:45:33 +08:00
To use the vim files:
ln -s ~/.dotfiles/vimrc ~/.vimrc
ln -s ~/.dotfiles/vim ~/.vim
2011-11-18 06:40:21 +08:00
2011-11-18 05:45:33 +08:00
The .vimrc is well commented and broken up by settings. I encourage you
to take a look and learn some of my handy aliases, or comment them out
if you don't like them, or make your own.
2011-12-13 13:04:42 +08:00
Vim Keymaps (in vim/plugin/settings)
---
2011-11-18 06:40:21 +08:00
2011-12-13 13:04:42 +08:00
The files in vim/plugin/settings are customizations stored on a per-plugin
basis. The main keymap is available in skwp-keymap.vim, but some of the vim
files contain key mappings as well (TODO: probably will move them out to skwp-keymap.vim)
Navigation
* ,z - jump back and forth between last two buffers
2011-12-16 14:20:51 +08:00
* Ctrl-\ - Show current file in nerd tree
2011-12-16 16:04:14 +08:00
* Ctrl-j and Ctrl-k to move up and down roughly by functions
2011-12-16 14:20:51 +08:00
* Ctrl-O - Old cursor position - this is a standard mapping but very useful, so included here
* Ctrl-I - opposite of Ctrl-O (again, this is standard)
2011-12-16 16:04:14 +08:00
* \mm - set the next available mark (set a mark with mX where X is a letter, navigate to mark using 'X). Uppercase marks to mark files, lowercase marks to use within a file.
2011-12-13 13:04:42 +08:00
LustyJuggler
* ,b - show buffers (LustyJuggler buffer search), just type to fuzzy match a buffer name
* ,s - Show buffers in LustyJuggler (use asdfjkl home row keys to then select buffer)
* ,lf - lusty file finder
* ,lr - lusty file finder from current folder
2011-12-16 15:24:22 +08:00
* ,lm ,lc ,ls - rails specific lusty juggler file finders (models, controllers, specs, etc) - just use the letter for what you want after ,l
2011-12-13 13:04:42 +08:00
2011-12-16 16:04:14 +08:00
Rails
2011-12-13 13:04:42 +08:00
2011-12-16 14:20:51 +08:00
* ,ru - Rails Unittest - synonym for :AV from rails.vim, opens up the corresponding test/spec to the file you're looking for, in a vertical split
* \ss to run specs, \ll to run a given spec on a line - using my vim-ruby-conque plugin (https://github.com/skwp/vim-ruby-conque)
2011-12-13 13:04:42 +08:00
2011-12-16 16:04:14 +08:00
Search/Code Navigation
2011-12-11 18:05:29 +08:00
2011-12-16 16:04:14 +08:00
* ,f - instantly Find definition of class (must have exuberant ctags installed)
* K - GitGrep the current word under the cursor
2011-12-13 10:21:42 +08:00
* Cmd-* - highlight all occurrences of current word (similar to regular * except doesn't move)
* ,hl - toggle search highlight on and off
2011-12-11 18:05:29 +08:00
* ,gg - GitGrep command line with a quote pretyped (close the quote yourself)
* ,gcp - GitGrep Current Partial to find references to the current view partial
2011-12-13 13:04:42 +08:00
* // - clear the search
* ,T - Tag list (list of methods in a class)
RSI-reduction
* Cmd-k and Cmd-d to type underscores and dashes (use ), since they are so common in code but so far away from home row
2011-12-16 14:20:51 +08:00
* ; instead of : - avoid Shift for common tasks, just hit semicolon to get to ex mode
2011-12-13 13:04:42 +08:00
2011-12-16 16:04:14 +08:00
Buffer/Window/Tab Manipulation
2011-12-13 13:04:42 +08:00
2011-12-16 16:04:14 +08:00
* ,m - NERDTree toggle
* Q - Quit a window, keep buffer alive (Ctrl-w,c)
* \Q - Quit window, kill buffer (:bw)
* vv - vertical split (Ctrl-w,v)
* ss - horizontal split (Ctrl-w,s)
2011-11-18 06:40:21 +08:00
* H,L,I,M - to move left, right, up, down between windows
2011-12-16 14:20:51 +08:00
* Cmd-H and Cmd-L - left an right on tabs
2011-12-16 16:04:14 +08:00
* ,, to zoom a window to max size and again to unzoom it (ZoomWin standard Ctrl-w,o)
2011-12-16 15:24:22 +08:00
* Use Cmd-1..Cmd-0 to switch to a specific tab number (like iTerm) - and tabs have been set up to show numbers
2011-12-16 14:20:51 +08:00
Utility
2011-12-13 13:04:42 +08:00
2011-12-16 14:20:51 +08:00
* ,cf - Copy Filename of current file into system (not vi) paste buffer
* ,cc - (Current command) copies the command under your cursor and executes it in vim. Great for testing single line changes to vimrc.
* ,yw - yank a word from anywhere within the word (so you don't have to go to the beginning of it)
* ,ow - overwrite a word with whatever is in your yank buffer - you can be anywhere on the word. saves having to visually select it
* gcc (comment a line) via tComment (standard)
* gcp (comment a paragraph) added
2011-12-13 13:04:42 +08:00
* ,t - Command-T fuzzy file selector (alternative to PeepOpen / LustyJuggler)
2011-11-18 06:50:58 +08:00
2011-12-07 15:06:13 +08:00
Included vim plugins
---
2011-12-07 17:02:20 +08:00
Navigation
* NERDTree - everyone's favorite tree browser
* NERDTree-tabs - makes NERDTree play nice with MacVim tabs so that it's on every tab
2011-12-07 17:12:42 +08:00
* ShowMarks - creates a visual gutter to the left of the number column showing you your marks (saved locations). use \mt to toggle it, \mm to place the next available mark, \mh to delete, \ma to clear all. Use standard vim mark navigation ('X) for mark named X.
2011-12-16 16:04:14 +08:00
* EasyMotion - hit \\w (forward) or \\b (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 and upper row, no pinkies
2011-12-07 17:40:44 +08:00
* LustyJuggler/Explorer - hit B, type buf name to match a buffer, or type S and use the home row keys to select a buffer
2011-12-13 12:42:54 +08:00
* TagList - hit ,T to see a list of methods in a class (uses ctags)
2011-12-09 02:05:53 +08:00
* CommandT - although I personally use PeepOpen, this is available as it's pretty standard
2011-12-07 17:02:20 +08:00
Git
2011-12-07 16:32:08 +08:00
* fugitive - "a git wrapper so awesome, it should be illegal..". Try Gstatus and hit '-' to toggle files. Git 'd' to see a diff. Learn more: http://vimcasts.org/blog/2011/05/the-fugitive-series/
2011-12-07 15:06:13 +08:00
* GitGrep - much better than the grep provided with fugitive; use :GitGrep or hit K to grep current word
2011-12-07 17:02:20 +08:00
Colors
* AnsiEsc - inteprets ansi color codes inside log files. great for looking at Rails logs
* solarized - a color scheme scientifically calibrated for awesomeness (including skwp mods for ShowMarks)
* csapprox - helps colors to be represented correctly on terminals (even though we expect to use MacVim)
2011-12-07 17:12:42 +08:00
Coding
2011-12-07 17:02:20 +08:00
* tComment - gcc to comment a line, gcp to comment blocks, nuff said
* sparkup - div.foo#bar - hit ctrl-e, expands into < code >< div class = 'foo' id # bar /></ code > , and that's just the beginning
2011-12-07 18:00:46 +08:00
* rails.vim - syntax highlighting, gf (goto file) enhancements, and lots more. should be required for any rails dev
2011-12-08 18:02:21 +08:00
* ruby.vim - lots of general enhancements for ruby dev
* necomplcache - intelligent and fast complete as you type, and added Command-Space to select a completion (same as Ctrl-N)
* snipMate - offers textmate-like snippet expansion + scrooloose-snippets . try hitting TAB after typing a snippet
2011-12-16 14:41:56 +08:00
* textobj-rubyblock - provides visual block selection specific to ruby. try var/vir to select a ruby block
* vim-indentobject - manipulation of blocks by their indentation (great for yaml) use vai/vii to select around an indent block
2011-12-07 17:02:20 +08:00
Utils
2011-12-08 18:02:21 +08:00
* surround - super easy quote and tag manipulation - ysiw" - sourround inner word with quotes. ci"' - change inner double quotes to single quotes, etc
2011-12-07 17:40:44 +08:00
* greplace - use :Gsearch to find across many files, replace inside the changes, then :Greplace to do a replace across all matches
2011-12-07 16:32:08 +08:00
* ConqueTerm - embedded fully colorful shell inside your vim
* vim-ruby-conque - helpers to run ruby,rspec,rake within ConqueTerm - use \rr (ruby), \ss (rspec), \ll (rspec line), \RR (rake)
2011-12-08 18:02:21 +08:00
* ruby_focused_unit_test - helpers to run tests/specs with \t
2011-12-07 16:49:13 +08:00
* vim-markdown-preview - :Mm to view your README.md as html
2011-12-08 18:02:21 +08:00
* html-escape - hit ctrl-h to escape html
2011-12-07 17:02:20 +08:00
* ruby-debug-ide - not quite working for me, but maybe it will for you. supposedly a graphical debugger you can step through
2011-12-13 12:55:35 +08:00
* Gundo - visualize your undos - pretty amazing plugin. Hit ,u with my keymappings to trigger it, very user friendly
2011-12-16 14:41:56 +08:00
* space-vim - hit space to repeat many navigation commands like finds, etc. very intuitive
2011-12-16 15:09:50 +08:00
* slime - use ctrl-c,ctrl-c to send text to a running irb/pry/console. To start the console, you must use screen with a named session: "screen -S [name] [cmd]", ex: "screen -S pry pry"
2011-12-07 17:02:20 +08:00
2011-12-07 17:12:42 +08:00
General enhancements that don't add new commands
* IndexedSearch - when you do searches will show you "Match 2 of 4" in the status line, nothing new to learn
* delimitMate - automatically closes quotes
* syntastic - automatic syntax checking when you save the file
2011-12-07 17:50:46 +08:00
* 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)
2011-12-08 18:02:21 +08:00
* endwise - automatically closes blocks (if/end)
* autotag - automatically creates tags for fast sourcecode browsing. use ctrl-[ over a symbol name to go to its definition
* matchit - helps with matching brackets, improves other plugins
2011-12-07 17:12:42 +08:00
2011-12-07 15:45:08 +08:00
Adding your own vim plugins
---
2011-12-08 12:54:03 +08:00
YADR comes with a dead simple plugin manager that just uses git submodules, without any fancy config files.
2011-12-07 15:45:08 +08:00
2011-12-08 12:54:03 +08:00
yav -u https://github.com/airblade/vim-rooter
2011-12-07 15:45:08 +08:00
2011-12-08 12:54:03 +08:00
You can update all the plugins easily:
2011-12-07 15:45:08 +08:00
2011-12-08 14:49:58 +08:00
yuv
Delete a plugin (Coming Soon)
ydv -p airblade-vim-rooter
2011-12-07 15:45:08 +08:00
2011-12-08 12:54:03 +08:00
The aliases (yav=yadr vim-add-plugin) and (yuv=yadr vim-update-all-plugins) live in the aliases file.
2011-12-07 15:45:08 +08:00
You can then commit the change. It's good to have your own fork of this project to do that.
2011-12-07 15:06:13 +08:00
2011-11-18 06:50:58 +08:00
Setup for Git
---
To use the gitconfig (some of the git bash aliases rely on my git aliases)
ln -s ~/.dotfiles/gitconfig ~/.gitconfig
2011-12-09 15:40:18 +08:00
Since the gitconfig doesn't contain the user info, I recommend using env variables.
Put the following in your ~/.secrets file which is automatically referenced by the provided zshrc:
export GIT_AUTHOR_NAME=yourname
export GIT_AUTHOR_EMAIL=you@domain.com
export GIT_COMITTER_NAME=yourname
export GIT_COMITTER_EMAIL=you@domain.com
2011-12-07 13:57:45 +08:00
Some of the customizations provided include:
* git l - a much more usable git log
* git b - a list of branches with summary of last commit
* git r - a list of remotes with info
* git t - a list of tags with info
* git nb - a (n)ew (b)ranch - like checkout -b
* git cp - cherry-pick -x (showing what was cherrypicked)
* git changelog - a nice format for creating changelogs
* Some sensible default configs, such as improving merge messages, push only pushes the current branch, removing status hints, and using mnemonic prefixes in diff: (i)ndex, (w)ork tree, (c)ommit and (o)bject
* Slightly imrpoved colors for diff
* git unstage (remove from index) and git uncommit (revert to the time prior to the last commit - dangerous if already pushed) aliases
2011-11-18 06:50:58 +08:00
OSX Hacks
---
The osx file is a bash script that sets up sensible defaults for devs and power users
2011-11-19 00:10:06 +08:00
under osx. Read through it before running it. To use:
./osx
2011-12-07 13:57:45 +08:00
These hacks are Lion-centric. May not work for other OS'es. My favorite mods include:
2011-11-19 00:10:06 +08:00
2011-12-07 13:57:45 +08:00
* Ultra fast key repeat rate (now you can scroll super quick using j/k)
* No disk image verification (downloaded files open quicker)
* Display the ~/Library folder in finder (hidden in Lion)
2011-11-18 06:40:21 +08:00
2011-12-07 13:57:45 +08:00
Other recommended OSX tools
2011-11-19 02:53:07 +08:00
---
2011-12-07 13:57:45 +08:00
* NValt - Notational Velocity alternative fork - http://brettterpstra.com/project/nvalt/ - syncs with SimpleNote
* Vimium for Chrome - vim style browsing. The 'f' to type the two char alias of any link is worth it.
* QuickCursor - gives you Apple-Shift-E to edit any OSX text field in vim.
2011-11-19 02:53:07 +08:00
2011-11-18 05:45:33 +08:00
Credits
2011-12-08 12:54:03 +08:00
---
2011-12-16 14:41:56 +08:00
2011-11-18 05:45:33 +08:00
I can't take credit for all of this. The vim files are a combination of
work by tpope, scrooloose, and many hours of scouring blogs, vimscripts,
2011-12-16 14:41:56 +08:00
and other places for the cream of the crop of vim awesomeness.
* https://github.com/astrails/dotvim
* https://github.com/carlhuda/janus
* https://github.com/tpope
* https://github.com/scrooloose
* https://github.com/kana
* https://github.com/robbyrussell
* https://github.com/nelstrom
And everything that's in the modules included in vim/bundle of course.
Please explore these people's work.
2011-11-18 05:45:33 +08:00
2011-12-06 16:40:44 +08:00
COMING SOON
2011-12-08 12:54:03 +08:00
---
2011-12-07 13:57:45 +08:00
* Full migration to tpope's pathogen format (~/.vim/bundle) for all plugins
* Better isolation of customizations in smaller chunks, maybe as plugins
2011-12-06 16:40:44 +08:00
* Automatic setup script to symlink all dotfiles, or just some selectively
2011-11-18 05:45:33 +08:00
2011-12-08 12:54:03 +08:00
2011-11-18 05:45:33 +08:00
For more tips and tricks
2011-12-08 12:54:03 +08:00
---
2011-11-18 06:40:21 +08:00
Follow my blog: http://yanpritzker.com