Skip to content

Instantly share code, notes, and snippets.

@jeffreywalter
Created February 28, 2013 14:15
Show Gist options
  • Save jeffreywalter/5057036 to your computer and use it in GitHub Desktop.
Save jeffreywalter/5057036 to your computer and use it in GitHub Desktop.
# Add the following to your ~/.bashrc or ~/.zshrc
hitch() {
command hitch "$@"
if [[ -s "$HOME/.hitch_export_authors" ]] ; then source "$HOME/.hitch_export_authors" ; fi
}
alias unhitch='hitch -u'
# Uncomment to persist pair info between terminal instances
# hitch
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
source /usr/local/etc/bash_completion.d/git-completion.bash
alias ts='date; time (rspec spec && flatware -w 2); date'
alias fw='date; time (flatware -w 2); date'
alias rw='rake jobs:work'
alias rc='rake jobs:clear; rw'
function gss() {
git stash show -p stash@{$1}
}
function reset_branch() {
BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`
git fetch --all
git reset --hard origin/$BRANCH
}
alias migrate='rake db:migrate; rake db:test:prepare; flatware fan rake db:test:prepare'
[github]
user = astronaut
[user]
email = dev@searchdiscovery.com
name = "Search Discovery Workstation"
bind - split-window
bind H resize-pane -L 5
bind J resize-pane -D 5
bind K resize-pane -U 5
bind L resize-pane -R 5
let g:no_turbux_mappings = 1
source ~/leader_t
set guifont=Monaco:h12
set backupdir=~/.vim/backup//
set directory=~/.vim/swp//
set antialias
colorscheme vividchalk
set background=dark
autocmd QuickFixCmdPost *grep* cwindow
autocmd User Rails Rnavcommand emitter app/emitters -suffix=_emitter.rb -default=model()
autocmd User Rails Rnavcommand renderer app/renderers -suffix=_renderer.rb -default=model()
autocmd User Rails Rnavcommand strategy app/strategies -suffix=_strategy.rb -default=model()
autocmd User Rails Rnavcommand notifier app/notifiers -suffix=_notifier.rb -default=model()
autocmd User Rails Rnavcommand validator app/validators -suffix=_validator.rb -default=model()
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
imap <right> <nop>
function! s:SendToTerminal(executable)
call system("osascript -e 'tell application \"Terminal\"' -e 'do script \"".a:executable."\" in window 1' -e 'end tell' -e 'tell application \"Terminal\" to activate'")
endfunction
function! s:first_readable_file(files) abort
let files = type(a:files) == type([]) ? copy(a:files) : split(a:files,"\n")
for file in files
if filereadable(rails#app().path(file))
return file
endif
endfor
return ''
endfunction
function! s:prefix_for_test(file)
if a:file =~# '_spec.rb$'
return "rspec "
elseif a:file =~# '_test.rb$'
return "ruby -Itest "
endif
return ''
endfunction
function! s:SendAlternateToTerminal(suffix) abort
let current_file = expand("%")
let executable = ""
if s:prefix_for_test(current_file) != ''
let executable = s:prefix_for_test(current_file) . current_file . a:suffix
elseif current_file =~# '.feature$'
let executable = "cucumber " . current_file . a:suffix
elseif exists('g:autoloaded_rails')
let related_file = s:first_readable_file(rails#buffer().related())
if related_file =~# '.rb$'
let executable = s:prefix_for_test(related_file) . related_file
endif
endif
if executable == ""
let executable = "!!"
endif
return s:SendToTerminal("
".executable)
endfunction
nnoremap <leader>t :w \| :call <SID>SendAlternateToTerminal("")<CR>
nnoremap <leader>T :w \| :call <SID>SendAlternateToTerminal(":".line('.'))<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment