_ _ _
| | | | | |
| |___| |_____ __| | ____
|_____ (____ |/ _ |/ ___)
_____| / ___ ( (_| | |
(_______\_____|\____|_|
# Yet Another Dotfile Repo v0.8
# Alpha Release Please Report Bugs
git clone https://github.com/skwp/dotfiles ~/.yadr
cd ~/.yadr && rake install
# Your dotfiles are safe! YADR will not
# overwrite anything. Please read on for
# install directions!
This is a collection of best of breed tools from across the web, from scouring other people's dotfile repos, blogs, and projects.
YADR is an opinionated dotfile repo that will make your heart sing
- OSX is the best OS. MacVim is the best editor. Zsh is the best shell. Pry is the best irb. Solarized is the best color scheme.
- Apple-style philosophy: make everything Just Work and Look Good. Don't worry about too many options.
- All common commands should be two and three character mnemonic aliases - less keystrokes, RSI reduction
- Avoid stressful hand motions, e.g. remap Esc to caps lock key, remap underscore to Alt-k in vim, make window management in vim easy.
- Easy to use plugin architecture, no config files to edit.
- Pick one tool and use it everywhere: vim-ize everything
- NEW Beautiful, easy to read and small vimrc
- NEW No key overrides or custom hackery in vimrc, everything in well factored snippets in .vim/plugin/settings
Janus is an amazing first effort to deliver a ready-to-use vim setup and is a huge inspiration to us all.
However as any first effort, it paves the way to improvements:
- Much larger list of vim plugins, specifically geared to Ruby/Rails/Git development.
- Optimized support for MacVim only means less things will break because we don't worry about linux or gvim.
- Optimized support for Solarized color scheme only, everything guaranteed to Look Good. Your eyes will thank you.
- All plugins tested with Solarized and custom color maps provided where needed to ensure your eyes will not bleed.
- No configuration file to maintain. YADR uses tiny ruby scripts to wrap git submodule maintenance.
- Much cleaner vimrc that does not introduce any new key maps. (Janus: 160 lines vimrc, 260 lines gvimrc; YADR: 90 lines vimrc with great comments)
- All keymaps and customization in small, easy to maintain files under .vim/plugin/settings
- More than just vim plugins - great shell aliases, osx, and irb/pry tweaks to make you more productive.
For the love of all that is holy, stop abusing your hands! Remap caps-lock to escape: http://pqrs.org/macosx/keyremap4macbook/extra.html
YADR is opinionated. To get the most out of using it, you should install all the software it depends on.
Homebrew is the missing package manager for OSX. To install:
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
With homebrew installed, install some packages:
brew install ack ctags git hub imagemagick macvim
Vim will complain every time you save a file if you do not have ctags installed correctly. We
assume you have installed ctags via homebrew. If you have homebrew setup correctly running
which ctags
should output /usr/local/bin/ctags
. If you get something else do this:
Make sure /usr/local/bin
is before /usr/bin
in your PATH.
If that doesn't work, move the OSX supplies ctags like so:
sudo mv /usr/bin/ctags /usr/bin/ctags_original
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
Please note: if you want the skwp theme referenced in these dotfiles, you should grab the skwp fork of oh-my-zsh, which just has the additional theme. While we are waiting for @robbyrussell to merge the theme upstream (unknown if it will happen).
cd ~/.oh-my-zsh
git remote add skwp https://github.com/skwp/oh-my-zsh.git
git pull skwp master
Pry 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
Installation is automated via rake
and the yadr
command. To get
started please run:
git clone https://github.com/skwp/dotfiles ~/.yadr
cd ~/.yadr && rake install
Note: YADR will not destroy any of your files unless you tell it to.
Upgrading is easy.
cd ~/.yadr
git pull origin master
rake install
After a lifetime of bash, I am now using ZSH as my default shell because of its awesome globbing and autocomplete features (the spelling fixer autocomplete is worth the money alone).
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, you soul will sing if you install zsh. I promise.
Lots of things I do every day are done with two or three character mnemonic aliases. Please feel free to edit them:
ae # alias edit
ar # alias reload
- Vim mode
- Bash style ctrl-R for reverse history finder
- Fuzzy matching - if you mistype a directory name, tab completion will fix it
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
- as irb:
pry
- as rails console:
script/console --irb=pry
clear
command to clear screensql
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
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:
# Set your git user info
export GIT_AUTHOR_NAME='Your Name'
export GIT_AUTHOR_EMAIL='[email protected]'
export GIT_COMMITTER_NAME='Your Name'
export GIT_COMMITTER_EMAIL='[email protected]'
# Optionally, set your GitHub credentials
export GITHUB_USER='your_user_name'
export GITHUB_TOKEN='your_github_token'
git l
- a much more usable git loggit b
- a list of branches with summary of last commitgit r
- a list of remotes with infogit t
- a list of tags with infogit nb
- a (n)ew (b)ranch - like checkout -bgit 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) andgit uncommit
(revert to the time prior to the last commit - dangerous if already pushed) aliases
A .gemrc is included. Never again type gem install whatever --no-ri --no-rdoc
. --no-ri --no-rdoc
is done by default.
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.
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)
,z
- go to previous buffer (:bp),x
- go to next buffer (:bn)Ctrl-j
andCtrl-k
to move up and down roughly by functionsCtrl-o
- Old cursor position - this is a standard mapping but very useful, so included hereCtrl-i
- opposite of Ctrl-O (again, this is standard)
,mm
- set the next available mark (set a mark withmX
whereX
is a letter, navigate to mark using'X
). Uppercase marks to mark files, lowercase marks to use within a file.,ma
- clear all marks,mh
- clear current mark,Bt
- toggle local anonymous bookmark at current location,Bn
,Bp
- next and previous anonymous bookmark,Bc
- clear anonymous bookmarks
,lj
- show buffers (LustyJuggler buffer search), just type to fuzzy match a buffer name
,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 pluginCmd-Shift-R
to use vim-rspec to run a spec file.Cmd-Shift-L
to run from a line (individual it block)
- in plugin/settings/surround.vim (this folder contains all my customizations)
- the
#
key now surrounds with#{}
, soysaw#
(surround around word)#{foo}
=
surrounds with<%= erb tag %>
;-
for<% this %>
. So,yss=
oryss-
to wrap code
,f
- instantly Find definition of class (must have exuberant ctags installed),F
- same as ,f but in a vertical splitK
- GitGrep the current word under the cursor and show results in quickfix window,K
- GitGrep the current word up to next exclamation point (useful for ruby foo! methods)Cmd-*
- highlight all occurrences of current word (similar to regular*
except doesn't move),hl
- toggle search highlight on and off,gg
- GitGrep command line with a quote pretyped (close the quote yourself),gd
- GitGrep def (greps for 'def [function name]') when cursor is over the function name,gcp
- GitGrep Current Partial to find references to the current view partial//
- clear the search,q/
- quickfix window with last search (stolen from Steve Losh),qa/
- quickfix Ack last search (Steve Losh),qg/
- quickfix GitGrep last search,T
- Tag list (list of methods in a class)
,t
- CtrlP fuzzy file selector,b
- CtrlP buffer selectorCmd-Shift-P
- Clear CtrlP cache,jm
jump (via CtrlP) to app/models,jc
app/controllers,jv
app/views,jh
app/helpers,jl
lib,jp
public,js
spec,jf
fast_spec,jt
test,jd
db,jC
config,jV
vendor,jF
factories
Cmd-k
andCmd-d
to type underscores and dashes (use Shift), since they are so common in code but so far away from home row;
in addition to:
- avoid Shift for common tasks, just hit semicolon to get to ex mode,.
to go to last edit location instead of'.
because the apostrophe is hard on the pinkyCmd-'
andCmd-"
to change content inside quotes- Cmd-Space to autocomplete. Tab for snipmate snippets.
Ctrl-H
andCtrl-L
- left an right on tabs- Use
Cmd-1
thruCmd-9
to switch to a specific tab number (like iTerm) - and tabs have been set up to show numbers
H
L
I
M
- to move left, right, up, down between windowsQ
- Intelligent Window Killer. Close windowwincmd c
if there are multiple windows to same buffer, or kill the bufferbwipeout
if this is the last window into it.
vv
- vertical split (Ctrl-w,v
)ss
- horizontal split (Ctrl-w,s
),qo
- open quickfix window (this is where output from GitGrep goes),qc
- close quickfix,gz
- zoom a window to max size and again to unzoom it (ZoomWin plugin, usuallyC-w,o
)
Cmd-Shift-N
- NERDTree toggleCtrl-\
- Show current file tree
,ig
- toggle visual indentation guides,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,w
- strip trailing whitespacessj
- split a line such as a hash {:foo => {:bar => :baz}} into a multiline hash (j = down)sk
- unsplit a link (k = up),he
- Html Escape,hu
- Html UnescapeCmd-Shift-A
- align things (type a character/expression to align by, works in visual mode or by itself)
Cmd-/
- toggle comments (usually gcc from tComment)gcp
(comment a paragraph)
Wrapping
- :Wrap - wrap long lines (e.g. when editing markdown files).
- Cmd-[j, k, $, 0, ^] - navigate display lines.
- NERDTree - everyone's favorite tree browser
- NERDTree-tabs - makes NERDTree play nice with MacVim tabs so that it's on every tab
- ShowMarks - creates a visual gutter to the left of the number column showing you your marks
- 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
- LustyJuggler/Explorer - hit B, type buf name to match a buffer, or type S and use the home row keys to select a buffer
- TagBar - hit ,T to see a list of methods in a class (uses ctags)
- CtrlP - Ctrl-p or ,t to find a file
- VimBookmarks - toggle an anonymous bookmark ,bb and go thru them ,bn ,bp and clear them ,bc
- TabMan - hit ,mt to see all tabs and buffers in a tree. Easy to navigate and close.
- fugitive - "a git wrapper so awesome, it should be illegal...". Try Gstatus and hit
-
to toggle files. Gitd
to see a diff. Learn more: http://vimcasts.org/blog/2011/05/the-fugitive-series/ - extradite - use :Extradite to get a really great git log browser. Only works when you have a file open.
- GitGrep - much better than the grep provided with fugitive; use :GitGrep or hit K to grep current word
- 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)
- tComment - gcc to comment a line, gcp to comment blocks, nuff said
- sparkup - div.foo#bar - hit
ctrl-e
, expands into<div class="foo" id="bar"/>
, and that's just the beginning - rails.vim - syntax highlighting, gf (goto file) enhancements, and lots more. should be required for any rails dev
- 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
- jasmine.vim - support for jasmine javascript unit testing, including snippets for it, before, etc..
- vim-coffeescript - support for coffeescript, highlighting
- vim-stylus - support for stylus css language
The things in this section provide new "objects" to work with your standard verbs such as yank/delete/change/=(codeformat), etc
- 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 - 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
- argtextobj - manipulation of function arguments as an "a" object, so vaa/via, caa/cia, daa/dia, etc..
- textobj-datetime - gives you
da
(date),df
(date full) and so on text objects. useable with all standard verbs - vim-textobj-entire - gives you
e
for entire document. so vae (visual around entire document), and etc - vim-textobj-rubysymbol - gives you
:
textobj. so va: to select a ruby symbol. da: to delete a symbol..etc - vim-textobj-function - gives you
f
textobj. so vaf to select a function - next-textobject - from Steve Losh, ability to use
n
such as vinb (visual inside (n)ext set of parens)
- 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
- tabularize - align code effortlessly by using :Tabularize /[character] to align by a character, or try the keymaps
- 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
- surround - super easy quote and tag manipulation - ysiw" - sourround inner word with quotes. ci"' - change inner double quotes to single quotes, etc
- greplace - use :Gsearch to find across many files, replace inside the changes, then :Greplace to do a replace across all matches
- 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)
- vim-rspec - really clean and colorful rspec output (Cmd-Shift-R) with ability to navigate directly to error; will replace vim-ruby-conque when I do a couple enhancements/bug fixes
- vim-markdown-preview - :Mm to view your README.md as html
- html-escape - ,he and ,hu to escape and unescape html
- ruby-debug-ide - not quite working for me, but maybe it will for you. supposedly a graphical debugger you can step through
- Gundo - visualize your undos - pretty amazing plugin. Hit ,u with my keymappings to trigger it, very user friendly
- 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"
- vim-indent-guides - visual indent guides, off by default
- IndexedSearch - when you do searches will show you "Match 2 of 4" in the status line
- delimitMate - automatically closes quotes
- syntastic - automatic syntax checking when you save the file
- 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) - 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
- sass-status - decorates your status bar with full nesting of where you are in the sass file
You may use ~/.vimrc.before
for settings like the leader setting. You may ~/.vimrc.after
for any additional overrides/settings.
YADR comes with a dead simple plugin manager that just uses git submodules, without any fancy config files.
yav -u https://github.com/airblade/vim-rooter
You can update all the plugins easily:
yuv
Delete a plugin (Coming Soon)
ydv -p airblade-vim-rooter
The aliases (yav=yadr vim-add-plugin) and (yuv=yadr vim-update-all-plugins) live in the aliases file. You can then commit the change. It's good to have your own fork of this project to do that.
The osx file is a bash script that sets up sensible defaults for devs and power users under osx. Read through it before running it. To use:
./osx
These hacks are Lion-centric. May not work for other OS'es. My favorite mods include:
- 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)
- 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.
- brew install autojump - will track your commonly used directories and let you jump there. With the zsh plugin you can just type
j [dirspec]
, a few letters of the dir you want to go to.
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, and other places for the cream of the crop of vim awesomeness.
- http://ethanschoonover.com/solarized - a scientifically calibrated color scheme
- 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.
- Automatic installation setup
- Initial Version: @skwp
- Cleanup, auto installer: @kylewest
Follow my blog: http://yanpritzker.com