Skip to content

Instantly share code, notes, and snippets.

@akbiggs
Created May 14, 2014 01:11
Show Gist options
  • Save akbiggs/b4eb857ca79e45efe330 to your computer and use it in GitHub Desktop.
Save akbiggs/b4eb857ca79e45efe330 to your computer and use it in GitHub Desktop.
# NAVIGATION
function gop
cd ~/code/personal
if test (count $argv) != 0
cd $argv
end
end
# PROMPT
function prompt
set my_prompt ""
if test (count $argv) != 0
set my_prompt $argv[1]
else
set my_prompt "Are you sure? [y/n]"
end
echo $my_prompt
read response
switch $response
case y yes
return 0
case n no
return 1
case '*'
return 1
end
end
# GIT
alias g git
function gs
if not g status $argv
ls
end
end
function gd
g diff $argv
end
function gds
gd --staged $argv
end
function gdnew
gd HEAD^1..HEAD $argv
end
function gdelete-merged
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
end
function gb
g branch $argv
end
function gbmv
g branch -m $argv
end
function gbd
g branch -d $argv
end
function ga
g add $argv
end
function grm
g rm $argv
end
function grb
g rebase $argv
end
function gc
g commit $argv
end
function gpher
g push heroku master
end
function gp
if contains master $argv
if not prompt "YOLO?"
echo "Not pushing to master"
return 1
end
end
g push origin $argv
end
function gpu
g pull origin $argv
end
function gco
g checkout $argv
end
function gm
g merge $argv
end
function gl
g log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
end
function gst
g stash $argv
end
function gr
g reset $argv
end
function grc
g reset --soft HEAD^
end
function gcl
g clone $argv
end
function gf
g fetch $argv
end
function gfo
g fetch origin $argv
end
function gba
gco -
end
function gma
gm -
end
function gnb
g checkout -b $argv
end
function gboff
gco $argv[1]
gnb $argv[2]
end
function gcb
g rev-parse --abbrev-ref HEAD
end
function gpme
set current (gcb)
gp $current $argv
end
function gpume
set current (gcb)
gpu $current $argv
end
function gbs
g bisect $argv
end
function gbss
gbs start $argv
end
function gbsr
gbs reset $argv
end
function gbsg
gbs good $argv
end
function gbsb
gbs bad $argv
end
# GIST
function gist
/usr/bin/gist -c
end
function safegist
sanitize $argv | /usr/bin/gist -f (basename $argv[1]) -c
end
# WEBSITE
function site
ssh ssh.phx.nearlyfreespeech.net -l abiggs_akbiggs
end
# PREVIEW
function preview
open -a Preview $argv
end
# SCHEME
function sch
mit-scheme $argv
end
# HASKELL
function hs
runhaskell $argv
end
# PASTEBOARD (MAC ONLY)
function pbstrip
pbpaste | pbcopy
end
# GIT PROMPT
function fish_prompt --description 'Write out the prompt'
# Just calculate these once, to save a few cycles when displaying the prompt
if not set -q __fish_prompt_hostname
set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
end
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
end
if not set -q __git_cb
set __git_cb ":"(set_color brown)(git branch ^/dev/null | grep \* | sed 's/* //')(set_color normal)""
end
switch $USER
case root
if not set -q __fish_prompt_cwd
if set -q fish_color_cwd_root
set -g __fish_prompt_cwd (set_color $fish_color_cwd_root)
else
set -g __fish_prompt_cwd (set_color $fish_color_cwd)
end
end
printf '%s@%s:%s%s%s%s# ' $USER $__fish_prompt_hostname "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" $__git_cb
case '*'
if not set -q __fish_prompt_cwd
set -g __fish_prompt_cwd (set_color $fish_color_cwd)
end
printf '%s@%s:%s%s%s%s$ ' $USER $__fish_prompt_hostname "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" $__git_cb
end
end
# RAILS
function rs
rails s
end
function rc
rails c
end
# VIM
function pathogen
cd ~/.vim/bundle
gcl $argv
end
# SUDO !!
function sudo
if test "$argv" = !!
eval command sudo $history[1]
else
command sudo $argv
end
end
# HEROKU
function hr
heroku $argv
end
function hrl
hr logs
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment