Skip to content

Instantly share code, notes, and snippets.

@wflanagan
Last active November 14, 2017 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wflanagan/96de1fe44a8c63ade604127da1421867 to your computer and use it in GitHub Desktop.
Save wflanagan/96de1fe44a8c63ade604127da1421867 to your computer and use it in GitHub Desktop.
custom_aliases.sh file for use in our dev environment
# Add to your path to the application for editing
# This file is automatically generated.
# v0.1.1 14November2017 837amEST
# This file was generated at <%= Time.now.utc %>
<% if defined?(home) && home.to_s.length > 0 %>
export DEVELOPER_HOME="<%= home %>"
<% end -%>
<% if defined?(app_path) && app_path.to_s.length > 0 %>
export APP_PATH="<%= app_path %>"
alias toapp="cd $APP_PATH"
<% end -%>
<% if defined?(audienti_path) && audienti_path.to_s.length > 0 %>
export AUDIENTI_PATH="<%= audienti_path %>"
alias audi="cd $AUDIENTI_PATH"
<% end -%>
<% if defined?(inspire_path) && inspire_path.to_s.length > 0 %>
export INSPIRE_PATH="<%= inspire_path %>"
alias insp="cd $INSPIRE_PATH"
<% end -%>
# SETUP
export DEVELOPER_NAME="<%= name %>"
export DEVELOPER_EMAIL="<%= email %>"
export DEVELOPER_TOKEN="<%= token %>"
export GIT_AUTHOR_NAME="<%= name %>"
export GIT_AUTHOR_EMAIL="<%= email %>"
export GIT_COMMITTER_NAME="<%= name %>"
export GIT_COMMITTER_EMAIL="<%= email %>"
export EMAIL="<%= email %>"
export NAME="<%= name %>"
export DOCKER_EMAIL="<%= email %>"
export DOCKER_USER="<%= docker_user %>"
export DOCKER_PASS="<%= docker_pass %>"
git config --global color.ui true
git config --global user.name $DEVELOPER_NAME
git config --global user.email $DEVELOPER_EMAIL
alias dc='docker-compose'
alias be='bundle exec'
alias bi="bundle install --with development test"
alias ber='bundle exec rspec'
# Aliases
alias gcl='git clone'
alias ga='git add'
alias grm='git rm'
alias gap='git add -p'
alias gall='git add -A'
alias gf='git fetch --all --prune'
alias gft='git fetch --all --prune --tags'
alias gfv='git fetch --all --prune --verbose'
alias gftv='git fetch --all --prune --tags --verbose'
alias gus='git reset HEAD'
alias gpristine='git reset --hard && git clean -dfx'
alias gclean='git clean -fd'
alias gm="git merge"
alias gmv='git mv'
alias g='git'
alias get='git'
alias gst='git status'
alias gs='git status'
alias gss='git status -s'
alias gsu='git submodule update --init --recursive'
alias gl='git pull'
alias glum='git pull upstream master'
alias gpr='git pull --rebase'
alias gpp='git pull && git push'
alias gup='git fetch && git rebase'
alias gp='git push'
alias gpo='git push origin'
alias gpu='git push --set-upstream'
alias gpom='git push origin master'
alias gr='git remote'
alias grv='git remote -v'
alias gra='git remote add'
alias gd='git diff'
alias gdv='git diff -w "$@" | vim -R -'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gcm='git commit -v -m'
alias gci='git commit --interactive'
alias gb='git branch'
alias gba='git branch -a'
alias gbt='git branch --track'
alias gbm='git branch -m'
alias gcount='git shortlog -sn'
alias gcp='git cherry-pick'
alias gco='git checkout'
alias gcom='git checkout master'
alias gcb='git checkout -b'
alias gcob='git checkout -b'
alias gct='git checkout --track'
alias gexport='git archive --format zip --output'
alias gdel='git branch -D'
alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master'
alias gll='git log --graph --pretty=oneline --abbrev-commit'
alias ggs="gg --stat"
alias gsl="git shortlog -sn"
alias gwc="git whatchanged"
alias gt="git tag"
alias gta="git tag -a"
alias gtd="git tag -d"
alias gtl="git tag -l"
alias gsyncbranches="git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done"
# From http://blogs.atlassian.com/2014/10/advanced-git-aliases/
# Show commits since last pull
alias gnew="git log HEAD@{1}..HEAD@{0}"
# Add uncommitted and unstaged changes to the last commit
alias gcaa="git commit -a --amend -C HEAD"
alias ggui="git gui"
alias gcam="git commit -am"
alias gcsam="git commit -S -am"
alias gstd="git stash drop"
alias gstl="git stash list"
# Foreman commands to start the dev procfile.
alias fsd="foreman start -f Procfile.dev"
case $OSTYPE in
darwin*)
alias gtls="git tag -l | gsort -V"
;;
*)
alias gtls='git tag -l | sort -V'
;;
esac
# reset environment
function devenv { export APP_ENV="$1" && export OMA_ENV="$1" && export RAILS_ENV="$1" && export RACK_ENV="$1" && export INSPIRE_ENV="$1"; }
# docker-compose run without port mapping
alias dcdr="devenv development && dc run -e OMA_ENV='development' -e RAILS_ENV='development' -e RACK_ENV='development' -e INSPIRE_ENV='development'"
alias dcpr="devenv production && dc run --no-deps -e OMA_ENV='production' -e RAILS_ENV='production' -e RACK_ENV='production' -e INSPIRE_ENV='production'"
alias dcplr="devenv production_local && dc run --no-deps -e OMA_ENV='production_local' -e RAILS_ENV='production_local' -e RACK_ENV='production_local' -e INSPIRE_ENV='production_local'"
alias dcsr="devenv staging && dc run --no-deps -e OMA_ENV='staging' -e RAILS_ENV='staging' -e RACK_ENV='staging' -e INSPIRE_ENV='staging'"
alias dctr="devenv test && dc run -e OMA_ENV='test' -e RAILS_ENV='test' -e RACK_ENV='test' -e INSPIRE_ENV='test'"
# If you are troubleshooting the bootup of a docker container, add verbose to the docker compose. This will show the booting docker logging.
alias dcdv="devenv development && dc --verbose run -e OMA_ENV='development' -e RAILS_ENV='development' -e RACK_ENV='development' -e INSPIRE_ENV='development'"
# docker-compose run with port mapping
alias dcdp="devenv development && dc run -e OMA_ENV='development' -e RAILS_ENV='development' -e RACK_ENV='development' -e INSPIRE_ENV='development' --service-ports"
alias dcpp="devenv production && dc run --no-deps -e OMA_ENV='production' -e RAILS_ENV='production' -e RACK_ENV='production' -e INSPIRE_ENV='production' --service-ports"
alias dcplp="devenv production_local && dc run --no-deps -e OMA_ENV='production_local' -e RAILS_ENV='production_local' -e RACK_ENV='production_local' -e INSPIRE_ENV='production_local' --service-ports"
alias dcsp="devenv staging && dc run --no-deps -e OMA_ENV='staging' -e RAILS_ENV='staging' -e RACK_ENV='staging' -e INSPIRE_ENV='staging' --service-ports"
alias dctp="devenv test && dc run -e OMA_ENV='test' -e RAILS_ENV='test' -e RACK_ENV='test' -e INSPIRE_ENV='test' --service-ports"
# up detached in development mode
alias dcdup="devenv development && dc up -d"
# docker-compose run bash prompt with service ports mapped
function dcdb { dc run -e OMA_ENV='development' -e RAILS_ENV='development' -e RACK_ENV='development' -e INSPIRE_ENV='development' --service-ports $1 bash; }
function dcpb { dc run --no-deps -e OMA_ENV='production' -e RAILS_ENV='production' -e RACK_ENV='production' -e INSPIRE_ENV='production' --service-ports $1 bash; }
function dcsb { dc run --no-deps -e OMA_ENV='staging' -e RAILS_ENV='staging' -e RACK_ENV='staging' -e INSPIRE_ENV='staging' --service-ports $1 bash; }
function dcplb { dc run --no-deps -e OMA_ENV='production_local' -e RAILS_ENV='production_local' -e RACK_ENV='production_local' -e INSPIRE_ENV='production_local' --service-ports $1 bash; }
function dctb { dc run -e OMA_ENV='test' -e RAILS_ENV='test' -e RACK_ENV='test' -e INSPIRE_ENV='test' --service-ports $1 bash; }
# wraps the cli.rb function to make it nicer to use.
function cli { ruby $AUDIENTI_PATH/cli.rb "$@"; }
# will delete most of your stuff, but isnt as nuclear as the nuclear option
function dcleanup {
docker rm -v $(docker ps --filter status=exited -q 2>/dev/null) 2>/dev/null
docker rmi $(docker images --filter dangling=true -q 2>/dev/null) 2>/dev/null
}
# ssh access to a running container, uses the same login as the box (manually configured)
function dssh { docker run -d -p 2222:22 -v /var/run/docker.sock:/var/run/docker.sock -e CONTAINER=$1 -e AUTH_MECHANISM=simpleAuth -e AUTH_USER=$SHARED_USERNAME -e AUTH_PASSWORD=$SHARED_PASSWORD jeroenpeeters/docker-ssh; }
# stops all your continers
function dockerstop {
docker rm $(docker stop $(docker ps -a -q --filter ancestor=$1 --format="{{.ID}}"))
}
# matches a name of a container and removes all matching
function dremovebyname {
docker ps -a | awk '{ print $1,$2 }' | grep $1 | awk '{print $1 }' | xargs -I {} docker rm -f {}
}
# Gives the process ID that is running listening on port number supplied.
function whatsonport {
lsof -n -i :$1 | grep LISTEN
}
# this literally blows away your entire system to start over. Be careful
# as this will delete every image and container there is.. but, you can
# rebuild, you have to reimport data
function dnuke {
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
docker ps -a | sed '1 d' | awk '{print $1}' | xargs -L1 docker rm
docker images -a | sed '1 d' | awk '{print $3}' | xargs -L1 docker rmi -f
docker volume rm $(docker volume ls -qf dangling=true)
echo "Nuked!"
}
function oauth_clone {
git clone https://$DEVELOPER_TOKEN:x-oauth-basic@github.com/$1.git $2;
}
function drunningcontainer {
docker ps | grep $1 | awk 'NR=1{ print $1 }'
}
function dattach {
docker exec -ti $(docker ps | grep $1 | awk 'NR=1{ print $1 }') /bin/bash
}
function reset_back_to_development {
devenv development
}
trap reset_back_to_development EXIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment