Skip to content

Instantly share code, notes, and snippets.

@victorporof
Last active July 18, 2022 08:59
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save victorporof/3415836 to your computer and use it in GitHub Desktop.
Save victorporof/3415836 to your computer and use it in GitHub Desktop.
config.fish
# Enviroment setup
# Path vars
set -gx PATH /usr/local/bin /usr/bin /bin /usr/local/sbin /usr/sbin /sbin
set -gx PATH /opt/homebrew/bin $PATH
set -gx PATH $PATH $HOME/.local/bin
set -gx PATH $PATH $HOME/.cargo/bin
set -gx PATH $PATH $HOME/.yarn/bin
# Locale for SSH
set -gx LC_ALL "en_US.UTF-8"
# Other vars
set -gx EDITOR nano
# Git
# Git Helpers
function gbor --description "Checks if branch exists, otherwise returns other argument"
if git show-ref --quiet refs/heads/$argv[1]
echo $argv[1]
else
echo $argv[2]
end
end
# Git Patch Export
alias gexp "git format-patch HEAD^ --stdout > ~/Desktop/(git rev-parse --abbrev-ref HEAD)@(git rev-parse --short HEAD)-(date +%F-%H%M%S).diff"
# Git Patch Import
alias gimp "git am --signoff < "
alias gamc "git am --continue"
alias gama "git am --abort"
# Git Status/Diff/Patch
alias gs "git status"
alias gd "git diff --ws-error-highlight=all"
alias gds "git log --patch -1"
# Git Log
alias glg "git log --stat -1"
alias glgg "git log --graph"
alias glgp "git log --graph --oneline --branches"
alias glgps "git log --graph --oneline --branches --simplify-by-decoration"
# Git Pull
alias gf "git fetch"
alias gl "git pull --rebase"
function gfco --description "Fetch from remote and checkout"
git fetch $argv[1]
git checkout $argv[1]/$argv[2]
end
function glr --description "Pull from remote and rebase"
if [ (count $argv) = 0 ]
glr (gbor main master)
return
end
if [ (count $argv) = 1 ]
glr origin $argv[1]
return
end
set branch (git rev-parse --abbrev-ref HEAD)
and git checkout $argv[2]
and git pull --rebase $argv[1] $argv[2]
and git checkout $branch
and git rebase $argv[2]
end
# Git Push
alias gp "git push"
alias gpf "git push --force"
alias gpt "git push --tags"
# Git Index
alias ga "git add"
alias gr "git reset --"
# Git Cleanup
alias grh "git reset --soft HEAD~"
alias grap "git reset --hard; git clean --force; rm -fr \".git/rebase-merge\""
alias grapo "git reset --hard origin/(gbor main master); git clean --force; rm -fr \".git/rebase-merge\""
# Git Interactive Commit
alias gai "git add --patch"
alias gri "git reset --patch"
# Git Commit
alias gc "git commit --signoff --message"
alias gca "git commit --signoff --amend --no-edit"
alias gcam "git commit --signoff --amend --message"
alias gcami "git commit --signoff --amend"
# Git Stash
alias gst "git stash save"
alias gstu "git stash save --keep-index"
alias gsta "git stash save --include-untracked"
alias gsti "git stash save --patch"
alias gsl "git stash list"
alias gss "git stash show"
alias gsp "git stash pop"
alias gsa "git stash apply"
alias gsd "git stash drop"
alias gsda "git stash clear"
# Git Branches/Tags
alias gb "git branch"
alias gt "git tag --list"
alias gba "git branch --all; git tag --list"
alias gco "git checkout"
alias gcm "git checkout (gbor main master)"
alias gnew "git checkout -b"
alias gnewt "git checkout --track -b"
alias gbd "git branch --delete"
alias gbds "git push --delete"
alias gbrn "git branch --move (git rev-parse --abbrev-ref HEAD)"
alias gbmv "git branch --force"
alias gbt "git branch --set-upstream-to"
# Git Rebasing
alias grb "git rebase"
alias grc "git rebase --continue"
alias gra "git rebase --abort"
function grbi --description "Interactive rebase on branch from base"
if [ (count $argv) = 0 ]
grbi (gbor main master)
return
end
set branch (git rev-parse --abbrev-ref HEAD)
set compare $argv[1]
set base (git merge-base $branch $compare)
and git rebase --interactive $base
end
# Git Merging
alias gmff "git merge"
alias gm "git merge --no-ff"
# Git Cherrypicking
alias gcp "git cherry-pick"
# Git Squashing
alias gsqa "git reset (git commit-tree HEAD^{tree} -m \"Squash\")"
# Mercurial
# Mercurial Patch Export
alias hgexp "hg export --output ~/Desktop/(hg log --rev . --template \"{activebookmark}@{rev}\")-(date +%F-%H%M%S).diff --rev ."
# Mercurial Patch Import
alias hgimp "hg import"
# Mercurial Status/Diff/Patch
alias hgs "hg status"
alias hgd "hg diff"
alias hgds "hg log --patch --rev"
# Mercurial Log
alias hgg "hg log --stat --rev"
alias hggg "hg log --graph"
# Mercurial Pull
alias hgf "hg pull"
alias hgl "hg pull --update"
function hglr --description "Pull from remote and rebase"
if [ (count $argv) = 0 ]
hglr master
return
end
if [ (count $argv) = 1 ]
hglr central $argv[1]
return
end
set bookmark (hg log --rev . --template "{activebookmark}")
and hg update $argv[2]
and hg pull --rebase $argv[1]
and hg update $bookmark
and hg rebase --dest $argv[2]
end
# Mercurial Push
alias hgp "hg push"
alias hgpf "hg push --force"
# Mercurial "Index"
alias hga "hg add"
alias hgr "hg remove"
alias hgar "hg addremove"
# Mercurial Cleanup
alias hgrh "hg strip --config extensions.strip= --keep --rev ."
alias hgrap "hg revert --all --no-backup; hg purge --config extensions.purge=; hg update --clean -r ."
# Mercurial Interactive Commit
alias hgci "hg commit --interactive"
# Mercurial Commit
alias hgc "hg commit --message"
alias hgca "hg log --rev . --template \"{desc}\" | xargs -0 hg commit --amend --message"
alias hgcam "hg commit --amend --message"
alias hgcami "hg commit --amend"
# Mercurial "Stash"
alias hgst "hg shelve --config extensions.shelve= --addremove"
alias hgsta "hg shelve --config extensions.shelve= --addremove --unknown"
alias hgsti "hg shelve --config extensions.shelve= --addremove --interactive"
alias hgsl "hg shelve --config extensions.shelve= --list"
alias hgss "hg shelve --config extensions.shelve= --patch"
alias hgsp "hg unshelve --config extensions.shelve="
# alias hgsa "" TODO
alias hgsd "hg shelve --config extensions.shelve= --delete"
alias hgsda "hg shelve --config extensions.shelve= --cleanup"
# Mercurial Soft Branches
alias hgb "hg bookmarks"
alias hgco "hg update"
alias hgcm "hg update master"
alias hgnew "hg bookmark"
alias hgbd "hg bookmark --delete"
alias hgbs "hg strip --config extensions.strip= --no-backup"
alias hgbds "hg strip --config extensions.strip= --no-backup -B"
alias hgbrn "hg bookmark --rename ."
function hgbmv --description "Move hg bookmark to commit"
hg bookmark --force --rev $argv[2] $argv[1]
end
# Mercurial Rebasing
alias hgrb "hg rebase --dest"
alias hgrc "hg resolve --mark; hg histedit --continue"
alias hgra "hg histedit --abort"
function hgrbi --description "Interactive rebase on branch from base"
if [ (count $argv) = 0 ]
hgrbi master
return
end
set branch (hg log --rev . --template "{activebookmark}")
set compare $argv[1]
set base (hg debugancestor $branch $compare)
set first (hg log -r "::$branch and not ::$base" --template "{rev}" --limit 1)
and hg histedit $first
end
# Mercurial Cherrypicking
alias hgcp "hg graft"
# Node helpers
function npm-run-local --description "Run node command from `node_modules`"
set -x PATH (npm bin) $PATH
eval $argv
end
function yarn-run-local --description "Run node command from `node_modules` via yarn"
set -x PATH (yarn bin) $PATH
eval $argv
end
# Utility functions
function ipp --description "What is my IP?"
dig +short myip.opendns.com @resolver1.opendns.com
end
function ip --description "What is my local IP?"
ipconfig getifaddr en0
end
function ftp-serve --description "Start a ftp server"
sudo --shell launchctl load -w /System/Library/LaunchDaemons/ftp.plist
end
function ftp-stop --description "Stop a ftp server"
sudo --shell launchctl unload -w /System/Library/LaunchDaemons/ftp.plist
end
function http-serve --description "Starts a SimpleHTTPServer in the current directory"
if [ (count $argv) = 0 ]
http-serve 8080
return
end
python3 -m http.server $argv[1]
end
# Google
set -gx SKIP_GCE_AUTH_FOR_GIT 1
set -gx PATH $HOME/Work/depot_tools $PATH
# Google: DevTools
alias dtbuild "autoninja -C out/Default"
alias dtrun "./third_party/chrome/chrome-linux/chrome --custom-devtools-frontend=file://(realpath out/Default/gen/front_end/) about:blank"
alias dtirun "./devtools-frontend/third_party/chrome/chrome-linux/chrome --custom-devtools-frontend=file://(realpath out/Default/gen) about:blank"
# Google: Chrome
alias crbuild "autoninja -C out/Default chrome"
alias crtbuild "autoninja -C out/Default blink_tests"
alias crutbuild "autoninja -C out/Default unit_tests"
alias crrun "./out/Default/chrome about:blank"
alias crtest "./out/Default/unit_tests --gtest_filter="
alias crwtest "./third_party/blink/tools/run_web_tests.py -t Default"
alias crvwtest "crwtest -t Default virtual/"
alias crdttest "crwtest -t Default http/tests/devtools"
alias critest "crwtest -t Default inspector-protocol"
# Google: V8
alias gm "./tools/dev/gm.py"
alias v8build "gm x64.optdebug"
alias v8test "gm x64.optdebug inspector"
alias d8run "rlwrap ./out/x64.optdebug/d8 --allow-natives-syntax"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment