Skip to content

Instantly share code, notes, and snippets.

@henrytseng
Last active November 27, 2019 21:01
Show Gist options
  • Save henrytseng/61ad0a52e25e833c4def1660012e497d to your computer and use it in GitHub Desktop.
Save henrytseng/61ad0a52e25e833c4def1660012e497d to your computer and use it in GitHub Desktop.
# Aliases
#alias ls='ls -aF -G' # List files with symbols (/ * @) and colors
alias viprofile="vi ~/.bash_profile && source ~/.bash_profile"
alias vialias="vi ~/.bash_aliases && source ~/.bash_aliases"
alias less='less -r'
alias l='ls'
alias ll='ls -alF -G' # List files including hidden files, with symbols
alias diff='grc diff'
# K8s
alias k=kubectl
# Git
alias gbc='git fetch; git checkout origin/master -q; git checkout -b'
alias gbl='git branch -a'
alias gcm='git commit -s -m'
alias gdf='git diff'
alias gds='git diff --cached'
alias gl='git log --pretty=oneline --abbrev-commit'
alias glg='git log --pretty=oneline --abbrev-commit --graph'
alias glc='git shortlog -s -n --all --no-merges'
alias gsk='git stash -k -u'
alias gsl='git stash list'
alias gsp='git stash pop'
alias gss='git stash save'
alias gst='git status -s'
alias gstl='git status'
# Git diff
gd() {
git_branch="$( git branch 2> /dev/null | cut -f2 -d\* -s )"
git diff master..$git_branch
}
# Git add
ga() {
if [ $# -eq 0 ]; then
git add .
else
git ls-files -om | grep "${@}" | xargs git add
fi
git status -s
}
# Git reset
gr() {
if [ $# -eq 0 ]; then
git reset
else
git ls-files -m | grep "${@}" | xargs git reset
fi
}
# Git branch
gb() {
if [ $# -eq 0 ]; then
git branch
else
git switch $@
fi
}
# Git update upstream
guu() {
git_branch="$( git branch 2> /dev/null | cut -f2 -d\* -s )"
git pull upstream $git_branch
git push
}
# Search history
lh() {
history | grep -i "$1" | grep -v hg | grep -v history | grep -v '[0-9] lh' | tail -n ${2-5}
}
lf() {
find -P . -type f -name "*$1*"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment