Skip to content

Instantly share code, notes, and snippets.

@aenniw
Last active October 9, 2019 07:33
Show Gist options
  • Save aenniw/7f1883a867e5d551b9c859eba176b6b3 to your computer and use it in GitHub Desktop.
Save aenniw/7f1883a867e5d551b9c859eba176b6b3 to your computer and use it in GitHub Desktop.
GIST_PROFILE_PATH=~/.bash_profile_gist
GIST_PROFILE_URI=https://gist.githubusercontent.com/aenniw/7f1883a867e5d551b9c859eba176b6b3/raw/.bash_profile_gist
function update-gist() {
curl -s ${GIST_PROFILE_URI} 2>/dev/null > ${GIST_PROFILE_PATH}
}
function resource-gist() {
test -f ${GIST_PROFILE_PATH} && \
source ${GIST_PROFILE_PATH}
}
resource-gist || ( update-gist && resource-gist )
PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\]@\[\033[0;36m\]\h \w\[\033[0;32m\]$(__git_ps1 2>/dev/null)\n\[\033[0;32m\]└─\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\] ▶\[\033[0m\] '
#maven
MAVEN_OPTS=" -XX:+TieredCompilation -XX:TieredStopAtLevel=1"
alias mvn-dep='mvn dependency:tree'
function mvn-fast() {
mvn -T 1C ${@:-install} -DskipTests -Dcheckstyle.skip=true
}
function mvn-module-fast() {
module=${1}
shift
mvn -T 1C ${@:-install} -pl ${module} -am -DskipTests -Dcheckstyle.skip=true
}
#docker
alias docker-rmi-all='docker rmi $(docker images | grep --invert-match "REPOSITORY" | awk '"'"'{ print $3}'"'"')'
alias docker-rm-all='docker container rm $(docker container ls -a | grep --invert-match "CONTAINER" | awk '"'"'{ print $1}'"'"')'
#vagrant
alias vu='vagrant up'
alias vd='vagrant destroy'
alias vdf='vagrant destroy -f'
alias vs='vagrant suspend'
alias vr='vagrant resume'
alias vsl='vagrant snapshot list'
alias vsr='vagrant snapshot restore'
alias vss='vagrant snapshot save'
alias vssh='vagrant ssh'
#git
alias gl='git log'
alias gll='git log --date-order --all --graph --format="%C(green)%h%Creset %C(yellow)%an%Creset %C(blue bold)%ar%Creset %C(red bold)%d%Creset%s"'
alias gf='git fetch'
alias gs='git status'
alias gtg='git tag'
alias git-wip='git add -A; git commit -m "--wip--"'
alias git-uwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
alias git-head='git rev-parse --abbrev-ref HEAD'
alias git-head-tag='git tag -l --points-at HEAD'
alias git-reset-soft='git reset --soft HEAD~1'
alias git-reset-hard='git reset --hard HEAD~1'
alias git-push-current='git push origin `git rev-parse --abbrev-ref HEAD`'
alias git-pull-current='git pull origin `git rev-parse --abbrev-ref HEAD`'
alias git-stash='git stash --include-untracked'
alias git-patch='git add -A && git diff --cached --binary'
alias git-pull-sub='git submodule foreach git pull origin master'
alias git-push-tags='git push --tags'
#platformio
alias pio-purge='find . -name .pio* -type d -exec rm -rf {} \;'
alias pio-clean='pio run --target clean'
alias pio-build='pio run'
alias pio-up='pio run --target upload'
alias pio-upfs='pio run --target uploadfs'
alias pio-utty='pio-up && pio-tty'
alias pio-all='pio-clean && pio-upfs && pio-btty'
function pio-tty() {
pio device monitor --baud ${1:-115200} --port ${2:-/dev/ttyUSB0} --filter colorize --eol LF --echo
}
#osx
alias osx-flush-forward='for f in /etc/pf-*.conf; do sudo pfctl -ef $f;done'
alias osx-finder='open -a Finder ./'
hash ldd 2>/dev/null || alias ldd='otool -L'
#unix
alias l='ls'
alias ll='ls -lG'
alias sed-last='sed '"'"'$ s/.$//'"'"''
alias log-timestamp='ts "[%Y-%m-%d %H:%M:%S]"'
alias rm-color='sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g"'
function delete() {
find ${1:-.} -name "${2:-*.none}" -type f -delete
}
function java-dist() {
if [[ $(java -version 2>&1) == *"OpenJDK"* ]]; then echo 'OpenJDK'; else echo 'ORACLE'; fi
}
function extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.xz) unxz $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
function resource() {
source ~/.bash_profile;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment