Skip to content

Instantly share code, notes, and snippets.

@is-andrade
Last active May 13, 2022 17:27
Show Gist options
  • Save is-andrade/ed2c6d04df05d8d14dad4fe17f809ee7 to your computer and use it in GitHub Desktop.
Save is-andrade/ed2c6d04df05d8d14dad4fe17f809ee7 to your computer and use it in GitHub Desktop.
Terminal Aliases for software development
## All aliases/functions run on macOS, maybe some adaptation is needed for linux/windows.
###### GIT ######
alias we='git status' ## just a quick way to do git status
alias wee='git status --short' ## same, but shorter visualization
alias gcom='git checkout master && git pull' ## checkout and pull on master
alias gcod='git checkout develop && git pull' ## checkout and pull on develop
alias cgit='cd /Users/andrade/Dev/Git' ## cd direct to git folder
alias gamend='git commit --amend -m'
alias lastcommits='git log --pretty=oneline' ## show last commits formated
alias lastbranch='git checkout -'
alias lb='git checkout -' ## back to Last Branch
alias greset='git checkout -- .' ## reset all local changes
alias gunstage='git reset HEAD' ## unstage one file ex: gunstage src/example.js
alias gremote='git config --get remote.origin.url' ## get remote
alias branchs='git branch -r' ## list remote branchs
alias localbranchs="git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'" ## list local branchs formated
alias gdeletemergedbranchs='git branch --merged | egrep -v "(^\*|master|main|dev)" | xargs git branch -d' ## delete local branchs already merged in (main/master/dev)
###### NPM ######
alias n='npm run'
alias ni='nvm use && npm install' ## ensures using nvm before npm install
alias asd='ni && n start' ## just a quick way to do nvm+install+start
###### FUNCTIONS ######
## git clone + cd = clone the repo and enter the folder
function gccd() {
git clone "$1" && cd "$(basename "$1" .git)"
}
## sync folder using rsync example: syncFolders ~/Dev/repo1 ~/Dev/repo2
function syncFolders() {
rsync -av -H -zP --exclude=.git --exclude=node_modules --delete "$1" "$2"
}
## Feel free to suggest any new alias or upgrade an existing one. 🥸
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment