Skip to content

Instantly share code, notes, and snippets.

@nitrix
Created May 1, 2019 19:27
Show Gist options
  • Save nitrix/ff6cacbe5790605f4e61dbe9dda5e9e2 to your computer and use it in GitHub Desktop.
Save nitrix/ff6cacbe5790605f4e61dbe9dda5e9e2 to your computer and use it in GitHub Desktop.
Bash profile useful aliases at work
# Docker Compose
# Runs a docker command of your choice from anywhere.
#
# Usage: dc <command>
dc() {
docker-compose --project-directory ~/Documents/Repos/workspace -f ~/Documents/Repos/workspace/docker-compose.yml $@
}
# Docker Compose Restart.
# Restart a container by name.
#
# Usage: dcr <name>
dcr() {
dc kill "$1"
dc up -d "$1"
}
# Docker Compose Logs.
#
# Inspect the logs in real-time of a container by name.
# Defaults to all containers if no name is specified.
#
# Usage: dcl
# Usage: dcl <name>
dcl() {
dc logs -f "$1"
}
# Docker Compose Enter.
# Enter a container by name and gains a basic shell.
# Usage: dce <name>
dce() {
dc exec "$1" sh
}
# Reload.
# Reloads your bash profile configuration file.
#
# Usage: r
r() {
source ~/.bash_profile
}
# Docker Cleanup.
# Deletes all containers and images.
#
# Usage: dcleanup
dcleanup() {
docker rm $(docker ps -q -f 'status=exited')
docker rmi $(docker images -q -f "dangling=true")
}
# Git Rebase.
#
# Rebases the specified branch onto the current branch,
# squashing the commits into a single one,
# using the first message as the final commit message.
#
# If no branches are specified, the master branch is used.
#
# Usage: gr
# Usage: gr <trunk>
gr() {
TRUNK=${1:-master}
MSG=$(git log --oneline --abbrev-commit $TRUNK..HEAD --pretty=format:"%s" --reverse | head -1)
git fetch origin "$TRUNK"
git reset $(git merge-base origin/$TRUNK $(git rev-parse --abbrev-ref HEAD))
git add -A
git commit -m "${MSG}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment