Skip to content

Instantly share code, notes, and snippets.

@revans
Created April 3, 2013 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save revans/5304506 to your computer and use it in GitHub Desktop.
Save revans/5304506 to your computer and use it in GitHub Desktop.
#######################################################################
# Setup Paths
function prepend_to_path -d "Prepend the given dir to the PATH if it exists and is not already
included within the PATH"
if test -d $argv[1]
if not contains $argv[1] $PATH
set -gx PATH "$argv[1]" $PATH
end
end
end
prepend_to_path "./bin"
prepend_to_path "./bundle/bin"
prepend_to_path "/usr/local/bin"
prepend_to_path "/usr/local/sbin"
prepend_to_path "$HOME/bin"
prepend_to_path "$HOME/.rbenv/bin"
prepend_to_path "$HOME/.brew"
prepend_to_path "/usr/local/share/npm/lib/node_modules"
prepend_to_path "/usr/local/share/bin"
prepend_to_path "/Applications/Postgres.app/Contents/MacOS/bin"
set BROWSER open
set -g -x fish_greeting ''
set -g -x EDITOR vim
set -g -x GIT_EDITOR vim
set -g -x RUBYOPT rubygems
set -g -x NODE_PATH "/usr/local/share/npm/lib/node_modules"
#######################################################################
# Alias functions
# config files
function fishconf; vim $HOME/.config/fish/config.fish; end
function vimrc; vim $HOME/.vimrc; end
function gitconfig; vim $HOME/.gitconfig; end
function gemrc; vim $HOME/.gemrc; end
function pryrc; vim $HOME/.pryrc; end
function gitignore; vim $HOME/.gitignore; end
function ackrc; vim $HOME/.ackrc; end
# applications
function mou; open -a mou; end
# utilities/shell
function l; ls -alhG; end
function c; clear; end
# git
function gs; git status; end
function gb; git branch; end
# rails
function rg; rails g; end
function rd; rails d; end
function rs; rails s; end
function rc; rails c; end
function b; bundle exec; end
function h; heroku; end
#######################################################################
# Alias Functions for easy cd-ing
function clients; cd $HOME/Work; end
function play; cd $HOME/Playground; end
function os; cd $HOME/OpenSource; end
function dotfiles; cd $HOME/dotfiles; end
#######################################################################
# Rbenv Setup
set -x PATH $HOME/.rbenv/shims $PATH
rbenv rehash >/dev/null ^&1
function rbenv_shell
set -l vers $argv[1]
switch "$vers"
case '--complete'
echo '--unset'
echo 'system'
exec rbenv-versions --bare
return
case '--unset'
set -e RBENV_VERSION
return 1
case ''
if [ -z "$RBENV_VERSION" ]
echo "rbenv: no shell-specific version configured" >&2
return 1
else
echo "$RBENV_VERSION"
return
end
case '*'
rbenv prefix "$vers" > /dev/null
set -g -x RBENV_VERSION "$vers"
end
end
function rbenv
set -l command $argv[1]
[ (count $argv) -gt 1 ]; and set -l args $argv[2..-1]
switch $command
case shell
rbenv_shell $args
case '*'
command rbenv $command $args
end
end
#######################################################################
# Python Server
function serve_this
python -m SimpleHTTPServer 8081
open "http://localhost:8081/"
end
#######################################################################
# Utilities
function psg -d "Grep for a running process, returning its PID and full string"
ps auxww | grep -i --color=always $argv | grep -v grep | collapse | cuts -f 2,11
end
function update_clone -d "Utility function to update a git repo"
cd $1
git pull
cd -
end
#######################################################################
# Update my clone copy of Rails
function update_rails -d "Update my clone of rails"
update_clone $HOME/OpenSource/rails
end
#######################################################################
# Update my clone copy of Ruby
#######################################################################
# Update my clone copy of Sinatra
#######################################################################
# Update my clone copy of Rack
#######################################################################
# Prompt Setup
set normal (set_color normal)
set magenta (set_color magenta)
set yellow (set_color yellow)
set green (set_color green)
set gray (set_color -o black)
function git_prompt
if git root >/dev/null 2>&1
set_color normal
printf ' on '
set_color magenta
printf '%s ' (git current-branch ^/dev/null)
set_color normal
end
end
function rbenv_prompt
if rbenv root >/dev/null 2>&1
set_color -o black
printf '('
set_color green
printf '%s' (rbenv version-name ^/dev/null)
set_color -o black
printf ')'
set_color normal
printf ' '
end
end
function fish_prompt
set last_status $status
rbenv_prompt
set_color magenta
printf '%s' (whoami)
set_color normal
printf ' in '
set_color $fish_color_cwd
printf '%s' (prompt_pwd)
set_color normal
git_prompt
echo
set_color normal
printf ': '
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment