Skip to content

Instantly share code, notes, and snippets.

@3D-I
Forked from jednano/.zshrc
Created January 2, 2022 01:12
Show Gist options
  • Save 3D-I/42b57e81ec7998395405a249d350387b to your computer and use it in GitHub Desktop.
Save 3D-I/42b57e81ec7998395405a249d350387b to your computer and use it in GitHub Desktop.
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"
export GPG_TTY=$(tty)
# export START="$HOME/a"
# if [[ $PWD == $HOME ]]; then
# cd $START
# fi
# 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 cb=$(git branch --show-current)
alias co='git checkout'
alias sw='git switch'
# previous branch
alias pb='git switch @{-1}'
alias push='git push'
# Function aliases
alias sq=squash
function squash() {
git rebase -i HEAD~$1
}
# 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