Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ZSH Initializer
mkcd() {
mkdir -p "$dir" && cd "$dir"
cpwd() {
pwd | pbcopy
notify_done() {
afplay /System/Library/Sounds/Ping.aiff;
osascript -e 'display notification "All set" with title "Done"'
alias gcne='git commit --amend --no-edit'
# Git delete all merged branches
alias gdmb='git branch --merged main | grep -v main | xargs -I % sh -c "git branch -d %; git push -d origin %;"'
alias gap='git add -p'
alias ap='gap'
unalias gcm
gcm() {
local has_main=$(git branch --list main)
if [[ -z ${has_main} ]]; then
git checkout master
git checkout main
# Git Sync with Master: from master branch, pull, and delete all merged branches locally and remotely
alias gsm='gcm;gl;gdmb;git remote prune origin;'
alias sm='gsm'
alias st='git status'
p() {
if [[ $(git checkout) ]]; then
git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)
alias gpu='git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)'
alias gpuo='gpu;go'
alias gpff='git push --force'
alias gpf='git push --force-with-lease'
alias pf='gpf'
alias gpsm='git push staging master'
alias go='git open'
alias o='git open'
# Git stage all deleted
alias gsd='git rm $(git ls-files --deleted)'
# Git fetch upstream and merge to master
gfu() {
git fetch upstream
git merge upstream/master
alias gt='git checkout --track'
alias gphm='git push heroku master'
alias glp='git log -p'
alias gln='git log --name-only'
alias gc='git clone'
gcamp() {
git add .
gcam "$str"
alias a.='ga .'
alias a='ga'
alias ©='gcamp'
() {
gcamp "$str"
alias grm='git rebase master'
alias grc='git rebase --continue'
alias gra='git rebase --abort'
alias grao='git remote add origin'
alias uc='git commit -m "Update Changelog"'
alias ucp='uc;gp'
alias gucp='guc;gp'
# Remove all local branches except master
alias remove_all_local_branches_except_master='git branch | grep -v "master\|main" | xargs git branch -D '
b() {
if [ $# -eq 0 ]
git branch
gco -b $*
# git commit -m
c() {
if [ $# -eq 0 ]
git commit
git commit -m "$str"
# Grep for string in list of branches and git checkout a find
ggc() {
gco $(gb | grep $1)
gto() {
git checkout --track origin/"$branch"
# Copy current branch name to clipboard
ccb() {
git branch | grep \* | cut -d ' ' -f2 | pbcopy
alias pc='gh pr create'
alias opr='hub pr show'
alias pro='hub pr show'
alias h='heroku'
alias ho='heroku open'
alias ns='npm start'
alias ni='npm i'
alias nis='npm i --save'
alias nt='npm test'
alias nta='npm run test-all'
# Yarn
alias y='yarn'
alias yi='yarn install'
alias ys='yarn start'
alias yd='yarn dev'
alias ya='yi;ys'
alias yo='yarn outdated'
alias u='yvm use'
alias ytw='yarn test --watch'
alias tw='yarn test --watch'
alias ytd='yarn test:debug:watch'
alias cc='yarn check:code'
alias ytu='yarn test -u'
alias yad='yarn add --dev'
alias yl='yarn lint'
alias yv='yarn validate'
alias e2er='y test:e2e:run'
# Jest
alias j='jest'
# Rspec and notify done
nrspec() {
rspec "$path" && notify_done;
# alias rs='rails server -b'
alias fs='foreman start'
# Run Rubocop on non-deleted, .rb files that are different in your branch from master
alias rcf='git diff-tree -r --no-commit-id --name-only head origin/master | xargs ls -1 2>/dev/null | grep '\.rb$' | xargs rubocop'
# Run Rubocop on non-deleted, .rb files that are different in your branch from master
alias scf='git diff-tree -r --no-commit-id --name-only head origin/master | xargs ls -1 2>/dev/null | grep '\.rb$' | xargs rspec'
alias rspec='bundle exec rspec'
# Ksdiff recipes
alias ksde='ksdiff ~/code/open-source/elixir/source ~/code/open-source/elixir/clone'
# Vim
alias v='vim'
alias vv='vim .'
alias virc='vim ~/.vimrc'
alias vpi='v +PlugInstall'
alias vpu='v +PlugUpdate'
alias vpc='v +PlugClean'
# Ip
alias ip="dig +short"
alias localip="ipconfig getifaddr en0"
# oh-my-zsh config
z() {
vim ~/.oh-my-zsh/custom/plugins/gusaiani/gusaiani.plugin.zsh
li() {
if [ -f firebase.json ]; then
yarn lint:js;yarn lint:deps
yarn lint
t() {
if [ -f mix.exs ]; then
mix test "$@"
elif [ -f Gemfile.lock ]; then
rspec "$@"
elif [ -d __pycache__ ]; then
pytest "$@"
yarn test "$@"
s() {
if [ -f ]; then runserver
elif [ -f mix.exs ]; then
iex -S mix phx.server
elif [ -f elm-package.json ]; then
elm-live --port=3000 --output=elm.js src/Main.elm --pushstate --open --debug
elif [ -f Gemfile.lock ]; then
foreman start
elif [ -f default.hbs ]; then
yarn watch
elif [ -d .next ]; then
yarn dev
elif [ -f firestore.indexes.json ]; then
firebase serve --only functions
elif [ -f Cargo.toml ]; then
cargo run
yarn start
td() {
if [ $OUT -eq 0 ]; then
say "Tests passed"
say "Failure in tests"
# Cypress
alias co='npx cypress open'
alias cr='npx cypress run'
alias cdee='cd ~/code/estudo/elixir'
alias cdos='cd ~/code/open-source'
alias es='cd ~/code/open-source/elixir/source'
alias ec='cd ~/code/open-source/elixir/clone'
alias e='cd ~/code/open-source/elixir/'
alias cdce='cd ~/code/estudo/elixir/cracking-interview-elixir'
alias cdcj='cd ~/code/estudo/js/js-cracking-coding-interview'
alias hk='cd ~/code/estudo/js/learn-hooks/chapter11'
alias q='cd ~/code/estudo/quantum'
alias re='cd ~/code/open-source/react'
alias res='cd ~/code/open-source/react/source'
alias rec='cd ~/code/open-source/react/clone'
alias hr='cd ~/code/estudo/js/hacker-rank'
alias hre='cd ~/code/estudo/elixir/hacker_rank'
alias hrr='cd ~/code/estudo/ruby/hacker_rank'
alias hrp='cd ~/code/estudo/python/hacker_rank'
alias lc='cd ~/code/estudo/js/leetcode'
alias egg='cd ~/code/estudo/elixir/pragstudio/getaways/backend'
alias di='cd ~/Documents/Gustavo\ Saiani/.j;vim "+ normal G $"'
alias ac='cd ~/Documents/acoes-bovespa && vim +1 empresas.txt'
alias san='cd ~/code/security-analysis-graham-dodd && vim "+ normal G $"'
alias gsw='cd ~/code/'
alias gsbl='cd ~/code/'
alias kb='cd ~/code/estudo/kotlin/prag-prog-programming-kotlin/intro'
alias pa='cd ~/code/estudo/typescript/redux-paint'
alias ce='cd ~/code/circuit/circuit-elixir'
alias cli='cd ~/code/circuit/react-graphl-client'
alias mkt='cd ~/code/circuit/marketing-website'
alias sr='~/code/speedyroute'
alias ca='~/code/circuit/admin-panel'
alias api='~/code/circuit/circuit-api'
cw() {
cd ~/code/circuit/teams-web
wr() {
cd ~/code/circuit/recipient
mi() {
cd ~/code/circuit/migrations
cb() {
cd ~/code/circuit/teams-backend
alias bs='bin/setup -v'
alias bu='bundle update'
alias bi='bundle install'
alias mted='MIX_ENV=test mix ecto.drop'
alias hism='heroku run "POOL_SIZE=2 iex -S mix"'
ti() {
cd ~/code/travels-in-italy
vim -c 'windo execute "norm! G" | winc h' -O
lp() {
cd ~/code/little-prince
vim -c 'windo execute "norm! G" | winc h' -O
pp() {
cd ~/code/pragmatic-programmer-russian
vim -c 'windo execute "norm! G" | winc h' -O
# Gist
# uzg - Update Zsh Gist
alias uzg='gist -u 70736c970c2b2d4020006eb7dd31bc40 /Users/gustavosaiani/.oh-my-zsh/custom/plugins/gusaiani/gusaiani.plugin.zsh'
alias uvg='gist -u 82efd3fab81e416c6830782a408b5514 ~/.vimrc'
alias uzrg='gist -u 96b2f5ae47dcc003e60b52b5be9dcbe5 ~/.zshrc'
alias gistup='uzg;uvg;uzrg'
# Update Keyboard Maestro Repository
uk() {
cd ~/.keyboard-maestro-macros
gcamp "…More"
tabcolor() {
echo -e -n "\033]6;1;bg;red;brightness;$1\a"
echo -e -n "\033]6;1;bg;green;brightness;$2\a"
echo -e -n "\033]6;1;bg;blue;brightness;$3\a"
alias p3='python3'
blacktab() {
tabcolor 0 0 0
# Formatted, syntax-highlighted cat
alias cat='bat'
# Nicer looking ls
alias l='k -A -h'
alias n='node'
alias ag='ag --path-to-ignore ~/.agignore'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.