-
-
Save jsantell/7671825 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fish 2.0 config | |
# Utility functions | |
function sser --description "Starts a SimpleHTTPServer in the current directory" | |
if [ (count $argv) = 0 ] | |
sser 8080 | |
return | |
end | |
python -m SimpleHTTPServer $argv[1] | |
end | |
function jsrun --description "Compiles ES6 code into ES3 and runs it" | |
set out out.js | |
traceur $argv[1] --out $out --block-binding true | |
node $out | |
end | |
function : --description "Checks if a statement executes cleanly, and prints the result if so" | |
@ (eval $argv ^/dev/null) | |
end | |
# Enviroment setup | |
clear | |
set -x ADT_BUNDLE /Applications/adt-bundle-mac | |
set -x EMSCRIPTEN_BUNDLE /Users/victorporof/Work/Mozilla/emscripten | |
set -x PATH /usr/local/bin /usr/bin /bin /usr/local/sbin /usr/sbin /sbin /usr/local/share/npm/bin $ADT_BUNDLE/sdk/tools $ADT_BUNDLE/sdk/platform-tools $EMSCRIPTEN_BUNDLE | |
set -e fish_greeting | |
alias @ "printf '%s'" | |
alias @@ "xargs printf '%s'" | |
alias @% "xargs printf" | |
set _black (set_color black) | |
set _black_bkg (set_color --background black) | |
set _green (set_color green) | |
set _brown (set_color brown) | |
set _yellow (set_color yellow) | |
set _blue (set_color blue) | |
set _magenta (set_color magenta) | |
set _purple (set_color purple) | |
set _red (set_color red) | |
set _cyan (set_color cyan) | |
set _white (set_color white) | |
set _normal (set_color normal) | |
set _normal_bkg (set_color --background normal) | |
set _bold (set_color --bold) | |
set _underline (set_color --underline) | |
set DESKTOP $HOME/Desktop | |
set DROPBOX $HOME/Dropbox | |
set DOWNLOADS $HOME/Downloads | |
# Firefox dev | |
set MOZCONFIG $HOME/.mozconfig-firefox | |
set CCACHE_DIR $HOME/.ccache | |
set MOZDEV ~/Work/Mozilla | |
set FXTEAM ~/Work/Mozilla/fx-team | |
set M_INBOUND ~/Work/Mozilla/mozilla-inbound | |
set M_CENTRAL ~/Work/Mozilla/mozilla-central | |
set M_AURORA ~/Work/Mozilla/mozilla-aurora | |
set M_BETA ~/Work/Mozilla/mozilla-beta | |
set HG_MI ssh://hg.mozilla.org/integration/mozilla-inbound | |
set HG_FX ssh://hg.mozilla.org/integration/fx-team | |
set HG_MC ssh://hg.mozilla.org/mozilla-central | |
set HG_MA ssh://hg.mozilla.org/releases/mozilla-aurora | |
set HG_MB ssh://hg.mozilla.org/releases/mozilla-beta | |
set HG_TRY ssh://hg.mozilla.org/try | |
alias mozdev "cd $MOZDEV" | |
alias fxteam "cd $FXTEAM" | |
alias m-inbound "cd $M_INBOUND" | |
alias m-central "cd $M_CENTRAL" | |
alias m-aurora "cd $M_AURORA" | |
alias m-beta "cd $M_BETA" | |
function fxbuild --description "Build firefox from source" | |
if [ (count $argv) = 1 ] | |
cd $argv[1] | |
end | |
set -gx MOZCONFIG $MOZCONFIG | |
set -gx CCACHE_DIR $CCACHE_DIR | |
if [ (uname) = "Darwin" ] | |
say -v V "Build started." | |
end | |
./mach build | |
if [ (uname) = "Darwin" ] | |
say -v V "Build finished." | |
end | |
end | |
function fxclobber --description "Clobber firefox build" | |
./mach clobber | |
end | |
function fxmake --description "Make firefox from a certain directory (incremental build)" | |
for i in $argv | |
./mach build $i | |
end | |
end | |
function fxtest --description "Run firefox mochitests from a designated folder" | |
./mach mochitest-browser $argv[1] | |
end | |
function fxtestxpc --description "Run firefox xpcshell tests from a designated folder" | |
./mach xpcshell-test $argv[1] | |
end | |
function fxrun --description "Open firefox from the obj/dist directory using a specified profile" | |
if [ (count $argv) = 0 ] | |
fxrun development | |
return | |
end | |
./mach run -P $argv[1] | |
end | |
function fxtry --description "Pushes to try" | |
if [ (count $argv) = 0 ] | |
return | |
end | |
set build "-b " | |
set platf "-p " | |
set tests "-u " | |
set talos "-t " | |
if contains "debug" $argv | |
set build $build"d" | |
else if contains "opt" $argv | |
set build $build"o" | |
else | |
set build $build"do" | |
end | |
if contains "all" $argv | |
set platf "$platf all" | |
set tests "$tests all" | |
else | |
set platf $platf"linux,linux64,linux64-asan,macosx64,win32,win64" | |
if contains "none" $argv | |
set tests $tests"none,"; | |
end | |
if contains "bc" $argv | |
set tests $tests"mochitest-bc,"; | |
end | |
if contains "oth" $argv | |
set tests $tests"mochitest-o,"; | |
end | |
if contains "X" $argv | |
set tests $tests"xpcshell,"; | |
end | |
set tests (@ $tests | sed '$s/.$//') | |
end | |
if contains "talos" $argv | |
set talos $talos"all" | |
else | |
set talos $talos"none" | |
end | |
qnew _ -m "try: $build $platf $tests $talos" | |
qser | |
if [ (uname) = "Darwin" ] | |
say "Pushing to try." | |
end | |
hgpf $HG_TRY | |
if [ (uname) = "Darwin" ] | |
say "Done" | |
end | |
qpo | |
qrm _ | |
end | |
# Mercurial | |
alias hgs "hg status" | |
alias hgu "hg update" | |
alias hgl "hg pull --update" | |
alias hgp "hg push" | |
alias hgpf "hg push --force" | |
alias hgc "hg commit" | |
alias hgcam "hg qimport --rev tip; hg qrefresh --edit; hg qfinish tip" | |
alias hgco "hg checkout" | |
alias hgb "hg branch" | |
alias hgba "hg branches" | |
alias hgg "hg log --rev (hg parent --template \"{node}\") --stat" | |
alias hggt "hg log --rev tip --stat" | |
alias hgqg "hg log --rev qtip:qbase --stat" | |
alias hggg "hg log --graph --limit 5" | |
alias hga "hg add" | |
alias hgar "hg addremove" | |
alias hgm "hg merge" | |
alias hgd "hg diff" | |
alias hgdr "hg diff --change" | |
alias hgpu "hg purge" | |
alias hgra "hg revert --all" | |
alias hgrap "hg revert --all; and hg qpop --all; hg purge" | |
alias qnew "hg qnew --force" | |
alias qimp "hg qimport" | |
alias qfol "hg qfold" | |
alias qfin "hg qfinish --applied" | |
alias qrm "hg qremove" | |
alias qrn "hg qrename" | |
alias qref "hg diff; hg qref" | |
alias qrefm "hg qref --message" | |
alias qrefe "hg qref --edit" | |
alias qrefu "hg qref --user" | |
alias qpu "hg qpush" | |
alias qpm "hg qpush --move" | |
alias qpo "hg phase --force --draft qbase:tip; hg qpop" | |
alias qpa "hg phase --force --draft qbase:tip; hg qpop --all" | |
alias qgo "hg qgoto" | |
alias qcref "hg qcrefresh" | |
alias qdiff "hg qdiff" | |
alias qser "hg qseries --summary --verbose" | |
alias qa "hg qa --summary --verbose" | |
alias qu "hg qu --summary --verbose" | |
function qexp --description "Export the current qtip as a patch on the desktop" | |
hgg | |
set qtip (hg qa | tail -1) | |
if [ $qtip ] | |
set file $DESKTOP/$qtip | |
hg export qtip > $file | |
ls -lah $file | awk '{ print $5 }' | |
end | |
end | |
function hgqpl --description "Pop all the queue, pull, update and restore queue" | |
if [ (: hgs) ] | |
hgs | |
return | |
end | |
set qtip (hg qa | tail -1) | |
if [ $qtip ] | |
qpa | |
end | |
hgl | |
hggg | |
if [ $qtip ] | |
qpu $qtip | |
end | |
end | |
function hgback --description "Perform a mercurial backout without a merge" | |
if [ (count $argv) = 0 ] | |
set tip (hg tip --template "{rev}") | |
hgback $tip | |
return | |
end | |
if [ (count $argv) = 1 ] | |
set cset $argv[1] | |
set parent (hg parent --rev $cset --template "{rev}") | |
hgback $cset $parent | |
return | |
end | |
set newest $argv[1] | |
set oldest $argv[2] | |
set file "backout$newest.patch" | |
hgd --rev $newest:$oldest > $file | |
qimp --force --push $file | |
set node (hg log --rev $newest --template "{node|short}") | |
qrefm "Backed out changeset $node" | |
hgg | |
rm $file | |
end | |
# Git | |
alias gst "git status" | |
alias gl "git pull" | |
alias gup "git fetch; git rebase" | |
alias gp "git push" | |
alias gpf "git push --force" | |
alias gc "git commit" | |
alias gca "git commit --all" | |
alias gcam "git commit --amend" | |
alias gco "git checkout" | |
alias gcm "git checkout master" | |
alias gcp "git cherry-pick" | |
alias gb "git branch" | |
alias gba "git branch --all" | |
alias glg "git log --stat --max-count=1" | |
alias glgg "git log --graph --max-count=5" | |
alias ga "git add" | |
alias gm "git merge" | |
alias gd "git diff" | |
alias grh "git reset HEAD" | |
alias grhh "git reset HEAD --hard" | |
# Shell prompt | |
set -g RESPONSIVE_PROMPT_COLUMNS 110 | |
function __prompt_set_self_addr_wdir | |
if not set -q __self | |
set -g __self (whoami) | |
set -g __addr (ifconfig | grep "inet " | grep -v "127.0.0.1" | head -n 1 | tr -d "addr:" | awk '{print $2}') | |
set -g __self_len (@ $__self | wc -m) | |
set -g __addr_len (@ $__addr | wc -m) | |
end | |
if [ $COLUMNS -gt $RESPONSIVE_PROMPT_COLUMNS ] | |
set -g __self_addr_wdir $_blue $__self $_normal " at " $_blue $__addr $_normal " in " $_bold $_green (prompt_pwd) $_normal | |
else | |
set -g __self_addr_wdir $_bold $_green (prompt_pwd) $_normal | |
end | |
end | |
function __prompt_set_hg_git | |
if not set -q __has_hg | |
set -g __has_hg (which hg) | |
end | |
if not set -q __has_git | |
set -g __has_git (which git) | |
end | |
if [ $__has_hg ] | |
set -g __is_hg_wdir (: hg root) | |
if [ $__is_hg_wdir ] | |
set hg_info (hg parent --template "{branch},{node},{tags}") | |
set hg_qseries (hg qseries --verbose) | |
set hg_branch (@ $hg_info | cut -d "," -f 1) | |
set hg_tip_cset (@ $hg_info | cut -d "," -f 2 | cut -c 1-12) | |
set hg_tip_tags (@ $hg_info | cut -d "," -f 3) | |
set hg_tip_tag1 (@ $hg_tip_tags | cut -d " " -f 1 | @% "%s ") | |
set hg_tip_tag2 (@ $hg_tip_tags | cut -d " " -s -f 2- | @% "%s ") | |
set hg_qa (@ $hg_qseries | grep -o " A " | wc -l | tr -d " ") | |
set hg_mq (@ $hg_qseries | grep -o " [AU] " | wc -l | tr -d " ") | |
set hg_branch_len (@ $hg_branch | wc -m) | |
set hg_tip_cset_len (@ $hg_tip_cset | wc -m) | |
set hg_tip_tag1_len (@ $hg_tip_tag1 | wc -m) | |
set hg_tip_tag2_len (@ $hg_tip_tag2 | wc -m) | |
set hg_qa_len (@ $hg_qa | wc -m) | |
set hg_mq_len (@ $hg_mq | wc -m) | |
if [ $COLUMNS -gt $RESPONSIVE_PROMPT_COLUMNS ] | |
set -g __hg_repo_info $_normal "[ " $_red $_black_bkg "hg" $_normal $_normal_bkg " on " $_brown $hg_branch $_green " " $hg_tip_cset " " $_bold $_blue $hg_tip_tag1 $_normal $_normal $hg_tip_tag2 $_cyan $hg_qa/$hg_mq $_normal " ]" | |
else | |
set -g __hg_repo_info $_normal "[ " $_red $_black_bkg "hg" $_normal $_normal_bkg " " $_cyan $hg_qa/$hg_mq $_normal " ]" | |
end | |
end | |
end | |
if [ $__has_git ] | |
set -g __is_git_wdir (: git rev-parse --show-toplevel) | |
if [ $__is_git_wdir ] | |
set git_branch (git symbolic-ref HEAD | cut -d "/" -f 3) | |
set git_head (git rev-parse --short HEAD) | |
set git_status (git status --porcelain) | |
if [ (@ $git_status | grep -c "?? ") -gt 0 ] | |
set git_status_str "?" | |
end | |
if [ (@ $git_status | grep -c " [AD] ") -gt 0 ] | |
set git_status_str "$git_status_str!" | |
end | |
set git_status_str_len (@ $git_status_str | wc -m) | |
set git_branch_len (@ $git_branch | wc -m) | |
set git_head_len (@ $git_head | wc -m) | |
if [ $COLUMNS -gt $RESPONSIVE_PROMPT_COLUMNS ] | |
set -g __git_repo_info $_normal "[ " $_red $_black_bkg "git" $_magenta $_normal_bkg $git_status_str $_normal $_normal " on " $_brown $git_branch $_green " " $git_head $_normal " ]" | |
else | |
set -g __git_repo_info $_normal "[ " $_red $_black_bkg "git" $_magenta $_normal_bkg $git_status_str " " $_white $git_branch $_normal " ]" | |
end | |
end | |
end | |
end | |
function fish_prompt | |
@ $_blue "👻 " $_normal | |
end | |
function fish_right_prompt | |
__prompt_set_self_addr_wdir | |
__prompt_set_hg_git | |
set -g __prompt_value "$__self_addr_wdir $__hg_repo_info $__git_repo_info" | |
if not set -q __prev_prompt_value | |
set -g __prev_prompt_value "" | |
end | |
if [ $__prompt_value != $__prev_prompt_value ] | |
@ $__self_addr_wdir | |
if [ $__is_hg_wdir ] | |
@ " " $__hg_repo_info | |
end | |
if [ $__is_git_wdir ] | |
@ " " $__git_repo_info | |
end | |
end | |
set -g __prev_prompt_value $__prompt_value | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment