Last active
October 19, 2021 19:53
-
-
Save gitawego/60a66674e9f325d53656d3f581d772c9 to your computer and use it in GitHub Desktop.
docker helper alias
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dockerCleanUp(){ | |
| # remove exited containers: | |
| docker ps --filter status=dead --filter status=exited --filter status=created -aq | xargs -r docker rm -v | |
| # remove unused images: | |
| docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi | |
| # remove unused volumes: | |
| docker volume ls -qf dangling=true | xargs -r docker volume rm | |
| } | |
| dockerShell(){ | |
| docker exec -i -t $1 /bin/bash | |
| } | |
| gitCleanBranches(){ | |
| git fetch -p | |
| if [ ! -z "`git branch -vv | awk '/: gone]/{print $1}'`" ]; | |
| then | |
| git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d | |
| else | |
| echo "no branch to be cleaned" | |
| fi | |
| } | |
| resetCommit(){ | |
| if [ -z $1 ]; | |
| then | |
| echo "reset total histories required" | |
| else | |
| git reset --soft HEAD~$1 | |
| fi | |
| } | |
| function use_nvidia(){ | |
| __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia $@ | |
| } | |
| alias docker-cleanup=dockerCleanUp | |
| alias docker-shell=dockerShell | |
| alias git-clean-branches="git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d" | |
| alias git-clean-branches=gitCleanBranches | |
| alias git-reset-commit=resetCommit | |
| alias node-update="nvm install node --reinstall-packages-from=node && nvm alias default node" | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you are using dotfile, put content to ~/.extra.
otherwise, put in ~/.bashrc
usage