Michael Bonner

Set up some aliases

Bash aliases are amazing, just set them up.

What are bash aliases?

Bash aliases are shortcuts. They reduce the key strokes, and increase efficiency. You just type a short, easy to remember shortcut, and bash will execute the full command. Why type out git status when you could type gs? Whey type out git checkout origin master when you could just type gcm?

How to set them up

First, identify which version of shell you're using and where 's configuration file is. Usually, on a mac, it's in a file at ~/.bash_profile. I use zsh, so mine is at ~/.zshrc. An easy way to test is to add a sample alias, and try executing it after refreshing the shell or sourcing your config file. e.g. source ~/.zshrc. I keep my aliases in a file at ~/.aliases and then add

source ~/.aliases
source ~/.aliases to my ~/.zshrc.

Once you identify which file to edit, all you need to do is add something like the following:

alias gs='git status'

In the above example, `gs` is the text you will type, and the text in the quotes is the command that will be executed.

My aliases

Here are the aliases that I use

# general
alias ll='ls -la'
alias zshrc='vim ~/.zshrc'
alias hosts='sudo vim /etc/hosts'

# directories
alias dev='cd ~/Development'
alias projects='cd ~/Development/projects'

# git
alias mylog='git log --author="Michael Bonner" --pretty=format:"%aD : %s"'
alias gs='git status'
alias gb='git branch'
alias gpull='git pull'
alias gpo='git pull origin'
alias gp='git pull'
alias gpush='git push'
alias gf='git fetch'
alias gl="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all"
alias gl2="git log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"
alias gcm='git checkout main'
alias gcma='git checkout master'
alias gcd='git checkout development'
alias gcs='git checkout staging'
alias gpma='git pull origin master'
alias gpd='git pull origin development'
alias gps='git pull origin staging'
alias ga='git add .'
alias gc='git commit -m '
alias gac='git commit -am '
alias ggs='find . -type d -name '.git' -maxdepth 3 | while read dir ; do sh -c "cd $dir/../ && echo -e "
GIT STATUS IN ${dir//.git/{" && git status -s" ; done'
alias ggpull='find . -type d -name '.git' -maxdepth 3 | while read dir ; do sh -c "cd $dir/../ && echo -e "
GIT PULL IN ${dir//.git/{" && git pull" ; done'
alias gc--.='git checkout -- .'
alias gch='git checkout'
alias gclean='git reset --hard;git clean -df;'
alias ghash='git rev-parse HEAD | pbcopy'
alias gt='git trim'
alias ggt='find . -type d -name '.git' -maxdepth 3 | while read dir ; do sh -c "cd $dir/../ && echo -e "
GIT TRIM IN ${dir//.git/{" && git trim" ; done'

# laravel
alias sup='sail up'
alias sdo='sail down'
alias pa='sail artisan'
alias mfs='sail artisan queue:clear; sail artisan migrate:fresh --seed'
alias cda='composer dump-autoload'
alias sail='./vendor/bin/sail'
alias sa='sail artisan'
alias sc='sail composer'
alias smfs='sail artisan queue:clear; sail artisan migrate:fresh --seed'

# npm
alias nr='npm run'
alias nrs='npm run start'
alias nrss='npm run start-secure'
alias nrd='npm run dev'
alias nrt='npm run test'
alias nrw='npm run watch'
alias nrp='npm run prod'
alias nrb='npm run build'
alias nrl='npm run lint'
alias nrc='npm run codegen'
alias nrg='npm run generate'
alias npmout='find . -type d -name .git -maxdepth 3 | while read dir ; do sh -c "cd $dir/../ && echo -e "
NPM STATUS IN ${dir//.git/}" && npm out" ; done'
alias npmup='find . -type d -name '.git' -maxdepth 2 | while read dir ; do sh -c "cd $dir/ && echo -e "
NPM UPDATE IN ${dir//.git/}" && npm up" ; done'
alias y='yarn'
alias mjml='./node_modules/.bin/mjml'
alias nd='netlify dev'
alias npm='~/.npm-global/bin/npm'

# bun
alias br='bun run'
alias brs='bun run start'
alias brss='bun run start-secure'
alias brd='bun run dev'
alias brt='bun run test'
alias brw='bun run watch'
alias brp='bun run prod'
alias brb='bun run build'
alias brl='bun run lint'
alias brc='bun run codegen'
alias brg='bun run generate'

# docker
alias dcu='docker-compose up'
alias dcd='docker-compose down'

# deployments
alias vl='vercel ls'

# audio source
alias da='SwitchAudioSource -t input -s "Shure MV7" && SwitchAudioSource -t output -s "Mike’s AirPods Max" && open -jg -a /Applications/ShurePlus MOTIV.app'
alias ba='SwitchAudioSource -t input -s "MacBook Pro Microphone" && SwitchAudioSource -t output -s "Mike’s AirPods Max"'

# misc
alias c='open . -a /Applications/Visual Studio Code.app'
alias st='open . -a /Applications/Sourcetree.app'
alias vim='lvim'

Published:

Updated: