Last active
January 30, 2026 18:21
-
-
Save abea/213731d17b8c948174aaeac5231ca20e to your computer and use it in GitHub Desktop.
Terminal aliases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ################################################### | |
| # ALIASES | |
| ################################################### | |
| # Default | |
| ######### | |
| alias ohmyzsh="code ~/.oh-my-zsh" | |
| alias profile="code ~/.zshrc" | |
| # Basic navigation aliases | |
| ########################## | |
| alias sites="cd ~/Sites" | |
| alias home='cd ~' | |
| alias projects='f() { cd ~/Projects/$1};f' | |
| # Git stuff | |
| ########### | |
| alias gs="git status" | |
| alias co="git checkout" | |
| alias gc="git commit" | |
| alias gpo="git push origin" | |
| alias gph="git push origin HEAD" | |
| alias pull="git pull" | |
| alias grpo="git remote prune origin" | |
| alias prune="git prune && git remote prune origin" | |
| alias gb="git branch" | |
| alias gl='git log -p -- . ":(exclude)package-lock.json"' | |
| alias stash='git stash --include-untracked' | |
| # Deletes normally merged branches | |
| alias gitcleanup='f() { git branch --merged $1 | grep -v "\* $1" | xargs -n 1 git branch -d };f' | |
| # Checks for branches squash-merged into a given branch. Ex: `gq main` to view | |
| # squashed branches, `gqD main` to delete squashed branches | |
| alias gq='f() { git checkout -q $1 && git for-each-ref refs/heads/ "--format=%(refname:short)" | while read branch; do mergeBase=$(git merge-base $1 $branch) && [[ $(git cherry $1 $(git commit-tree $(git rev-parse $branch^{tree}) -p $mergeBase -m _)) == "-"* ]] && echo $branch; done };f' | |
| # Deletes branches squash-merged into a given branch. Ex: `gqD main` to view | |
| # squashed branches, `gqD main` to delete squashed branches | |
| alias gqD='f() { git checkout -q $1 && git for-each-ref refs/heads/ "--format=%(refname:short)" | while read branch; do mergeBase=$(git merge-base $1 $branch) && [[ $(git cherry $1 $(git commit-tree $(git rev-parse $branch^{tree}) -p $mergeBase -m _)) == "-"* ]] && git branch -D $branch; done };f' | |
| # Other project utilities | |
| ######################### | |
| # Refresh a project's node modules in one go. | |
| alias npm-refresh="rm package-lock.json && rm -rf node_modules && npm install" | |
| # Lists top level global npm packages | |
| alias npm-globals="npm list -g --depth=0" | |
| # Machine utilities | |
| ################### | |
| # Refresh terminal without opening a new tab | |
| alias refresh="source ~/.zshrc" | |
| # Fixes the camera when not responsive (most of the time) | |
| alias fixcam="sudo killall AppleCameraAssistant;sudo killall VDCAssistant" | |
| # Turn wifi network on or off | |
| # techrepublic.com/article/pro-tip-manage-wi-fi-with-terminal-commands-on-os-x/ | |
| alias nonet="networksetup -setairportpower en0 off" | |
| alias gonet="networksetup -setairportpower en0 on" | |
| # Archive | |
| # Not actively using anymore, but notably useful in the past. Mainly from OSS maintenance with ApostropheCMS. | |
| ######### | |
| # Check out a branch from an OSS contributor PR. | |
| alias copr='f() { git fetch origin pull/$1/head:pr/$1 && git checkout pr/$1 };f' | |
| # Easily clone Apostrophe repos, e.g., `cloneapos seo` | |
| alias cloneapos='f() { cd ~/Projects && git clone [email protected]:apostrophecms/apostrophe-$1.git && cd apostrophe-$1};f' | |
| # Quick alias function to cd into an Apostrophe directory. Was very useful when maintaining OSS libraries with a naming pattern. | |
| goToApos() { | |
| if [ -z $1 ]; | |
| then | |
| cd ~/Projects/apostrophe | |
| else | |
| cd ~/Projects/apostrophe-$1 | |
| fi | |
| } | |
| alias cdapos=goToApos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment