Skip to content

Instantly share code, notes, and snippets.

@gardner
Last active October 24, 2019 22:51
Show Gist options
  • Save gardner/16c87002ddd6516b953b8c7b7b6beba4 to your computer and use it in GitHub Desktop.
Save gardner/16c87002ddd6516b953b8c7b7b6beba4 to your computer and use it in GitHub Desktop.
bash aliases
#!/bin/bash
export GREP_OPTIONS='--color'
## Save everything
export PROMPT_COMMAND='if [ "$(id -u)" -ne 0 ]; then echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history 1)" >> ~/.logs/bash-history-$(date "+%Y-%m-%d").log; fi'
# Print some useful milestones
python -c "from datetime import date; print '%s days until beta' % (date(2018,04,07) - date.today()).days; print '%s days until release' % (date(2018,10,7) - date.today()).days; print '%s days left of TSM ' % (90 - (date.today() - date(2017,9,10)).days)" &
export GIT_PS1_SHOWDIRTYSTATE=true
export PS1='\u@\h:\w$(__git_ps1)\$ '
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
alias smac="sudo ifconfig en0 ether 34:36:3b:d0:84:32"
alias realmac="sudo ifconfig en0 ether 34:36:3b:d0:84:33"
alias mtr="sudo /usr/local/sbin/mtr 8.8.8.8"
alias lsof="sudo lsof -iTCP -sTCP:LISTEN -P -n"
alias f='time find . \( -name .git -o -name node_modules -o -name \*.map \) -prune -o -type f -print0 | xargs -0 -n1 -P8 grep -H'
alias fl='time find ~/.logs -type f -print0 | xargs -0 -n1 -P8 grep -H'
alias airport='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport'
alias compose='docker-compose -f docker-compose.yml -f docker-compose-prod.yml'
# handy git pull alias
git_pull_with_stash() {
if [ -n "$(git status --untracked-files=no --porcelain)" ]; then
echo "Dirty"
git stash && git pull --rebase && git stash pop
else
# Working directory clean excluding untracked files
echo "Clean"
git pull --rebase
fi
}
alias gp=git_pull_with_stash
# "shell" into a docker instance
docker_ssh() {
container_id=$(docker ps | awk '{ print $1 " " $2}' | grep $1 | awk '{ print $1}')
docker container inspect $container_id | grep Image | tail -1 | awk '{ print $2 }'
echo $container_id
docker exec -i -t $container_id /bin/bash
}
alias ds=docker_ssh
# dump json from url
get_json() {
#do things with parameters like $1 such as
curl -s $1 | python -m json.tool
}
alias j=get_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment