Skip to content

Instantly share code, notes, and snippets.

@bruncanepa
Created January 25, 2024 00:04
Show Gist options
  • Save bruncanepa/082b4975243589c66dc4f66820cc0d01 to your computer and use it in GitHub Desktop.
Save bruncanepa/082b4975243589c66dc4f66820cc0d01 to your computer and use it in GitHub Desktop.
My MacOS ~/.bash_profile
# REFERENCE:
# $@ => sets all passed arguments
# $1 => sets first passed argument
# $2 => sets second passed argument
# MacOS
function killport(){sudo kill -9 $(lsof -ti:$@);} # kills port passed as first argument
alias dontsleep="caffeinate -d -i -s" # stops Mac from going to sleep until the command is stopped
# Git
alias gf="git fetch $@"
alias gpl="git pull $@"
alias gplr="gpl --rebase"
alias gps="git push $@"
alias gpsu="git push -u origin $(git branch --show-current)" # pushes current non-tracked branch
alias gchd="git checkout develop $@"
alias gchs="git checkout staging $@"
alias gchm="git checkout master $@"
alias gch="git checkout $@"
alias gch-="git checkout -" # checkout to most recent branch
alias gm="git merge $@"
alias gmod="git merge origin/develop $@"
alias gmos="git merge origin/staging $@"
alias gmom="git merge origin/master $@"
alias gpick="git cherry-pick $@"
alias gl="git log"
alias gls="git log --oneline" # same than git log, but with short commit hashes
function gdiff() { git log --oneline origin/$1...origin/$2; }
alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'" # same than git log, but with graphics
alias grsoft="git reset --soft HEAD^" # removes last commit, and all changes from it are staged
function gpstag() { git push origin refs/tags/$@; } # pushes a new tag
function gpstagdel() { git push --delete origin refs/tags/$@; } # deletes a remote tag
alias gam="git commit --amend" # modify most recent commit
alias gstl="git stash list" # list stashes
alias gsts="git stash save $@" # save a new stash. arguments will be passed. can use `gsts dev-work` as name for it.
alias gsta="git stash apply $@" # if non arguments passed, applies last stash.
alias gstp="git stash pop $@"
function gplallfolders() { for i in */.git; do ( echo $i; cd $i/..; gchm -f; git pull; ); done } # pulls from all subfolders inside a folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment