Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
source /usr/local/lib/python3.7/site-packages/powerline/bindings/zsh/powerline.zsh
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
export PATH="/usr/local/opt/python/bin:$PATH"
# alias ls='ls -F --color --show-control-chars'
# alias ls='ls -F --show-control-chars'
alias ll='ls -l'
# Windows aliases
alias cls="clear && printf '\e[3J'"
# alias dir='ls -F --color=always'
alias dir='ls -l'
alias del='rm'
alias deltree='rm -Rf'
alias edit='nano'
alias find='grep --color=auto -in'
alias rd='rmdir'
alias ren='mv'
alias md='mkdir'
# git commands
alias ga='git add'
alias gb='git branch'
alias gc='git commit'
alias gd='git diff'
alias gf='git fetch'
alias gm='git merge'
alias gr='git rebase'
alias gs='git status'
alias gt='git tag'
alias dt='git difftool'
alias mt='git mergetool'
alias co='git checkout'
alias sw='git switch'
alias pb='git switch @{-1}'
alias push='git push'
# Function aliases
alias sq=squash
alias cb=$(git branch --show-current)
# Functions
function pull() {
if [[ $@ ]]; then
# Pass the args through to `git pull`
return $(git pull $@) 2>/dev/null
fi
# Get verbose branch info (includes tracking)
branch=$(git branch -vv | grep $(git branch --show-current))
# Extract tracking info
branch=${branch#*\[}
branch=${branch%%\]*}
branch=${branch%%:*}
remote=${branch%%/*}
branch=${branch#*/}
if [[ -z $remote && -z $branch ]]; then
# There is no tracking information for the current branch.
return $(git pull) 2>/dev/null
fi
# Fetch only the current branch from the tracked remote
git fetch $remote $branch
original_commit=$(git rev-parse HEAD)
git merge FETCH_HEAD
if [[ -a package-lock.json ]]; then
git diff --name-only $original_commit HEAD | grep package-lock.json && npm ci
else
git diff --name-only $original_commit HEAD | grep package.json && npm install
fi
}
function squash() {
git rebase -i HEAD~$1
}
function blam() {
push origin $(git branch --show-current) $@
}
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.