Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ZSH Initializer
mkcd() {
dir="$*"
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 master | grep -v master | xargs -I % sh -c "git branch -d %; git push -d origin %;"'
alias gap='git add -p'
alias ap='gap'
# 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
gp
else
gpu
fi
}
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'
# 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 .
str="$*"
gcam "$str"
gp
}
alias a.='ga .'
alias a='ga'
alias ©='gcamp'
() {
str="'$*'"
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" | xargs git branch -D '
alias b='gco -b'
# git commit -m
c() {
if [ $# -eq 0 ]
then
git commit
else
str="$*"
git commit -m "$str"
fi
}
# Grep for string in list of branches and git checkout a find
ggc() {
gco $(gb | grep $1)
}
gto() {
branch="$*"
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 h='heroku'
alias ho='heroku open'
# NPM
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'
# Jest
alias j='jest'
# Rspec and notify done
nrspec() {
path="$*"
rspec "$path" && notify_done;
}
# alias rs='rails server -b 0.0.0.0'
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'
# Ip
alias ip="dig +short myip.opendns.com @resolver1.opendns.com."
alias localip="ipconfig getifaddr en0"
# oh-my-zsh config
z() {
vim ~/.oh-my-zsh/custom/plugins/gusaiani/gusaiani.plugin.zsh
}
t() {
if [ -f mix.exs ]; then
mix test
elif [ -f Gemfile.lock ]; then
rspec
elif [ -d __pycache__ ]; then
pytest
else
yarn test
fi
}
s() {
blacktab
if [ -f manage.py ]; then
manage.py runserver
elif [ -f mix.exs ]; then
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
else
yarn start
fi
}
td() {
t;
OUT=$?
if [ $OUT -eq 0 ]; then
say "Tests passed"
else
say "Failure in tests"
fi
}
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 tdr='cd ~/code/estudo/js/kent-dodds/react-testing-library-course'
alias hk='cd ~/code/estudo/js/learn-hooks/chapter11'
alias ds='cd ~/code/estudo/js/data-structures-egghead'
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 ab='cd ~/code/estudo/elixir/absinthe-book'
alias rg='cd ~/code/estudo/js/road-to-graphql'
alias di='cd ~/Documents/Gustavo\ Saiani/.j;vim "+ normal G $" README.md'
alias ac='cd ~/Documents/acoes-bovespa && vim +1 empresas.txt'
alias san='cd ~/code/security-analysis-graham-dodd && vim "+ normal G $" chapter-33.md'
alias gsw='cd ~/code/gustavosaiani.com'
alias gsbl='cd ~/code/blog.gustavosaiani.com/wp-content/themes/gusaiani'
alias bs='bin/setup -v'
alias bu='bundle update'
alias bi='bundle install'
alias mted='MIX_ENV=test mix ecto.drop'
alias sr='~/code/speedyroute'
alias wr='~/code/circuit/teams-web-recipient'
cb() {
cd ~/code/circuit/teams-backend
nvm use v10.19.0
}
ti() {
cd ~/code/travels-in-italy
vim -c 'windo execute "norm! G" | winc h' -O travels-in-italy-de.md travels-in-italy-pt.md
}
lp() {
cd ~/code/little-prince
vim -c 'windo execute "norm! G" | winc h' -O petit-prince-ru.md petit-prince-fr.md
}
alias calc='~/code/calculator'
# 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
}
alias sk='BYPASS_LENS=true EAGER_LOAD=true bundle exec sidekiq'
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.