Skip to content

Instantly share code, notes, and snippets.

@ellisio
Created December 15, 2016 22:00
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 ellisio/9bb527570b67b2564bbeb59823fcc4ec to your computer and use it in GitHub Desktop.
Save ellisio/9bb527570b67b2564bbeb59823fcc4ec to your computer and use it in GitHub Desktop.
# Create a new directory and enter it
function mkd() {
mkdir -p "$@" && cd "$@"
}
# Determine size of a file or total size of a directory
function fs() {
if du -b /dev/null > /dev/null 2>&1; then
local arg=-sbh
else
local arg=-sh
fi
if [[ -n "$@" ]]; then
du $arg -- "$@"
else
du $arg .[^.]* *
fi
}
# Use Git’s colored diff when available
hash git &>/dev/null
if [ $? -eq 0 ]; then
function diff() {
git diff --no-index --color-words "$@"
}
fi
# Syntax-highlight JSON strings or files
# Usage: `json '{"foo":42}'` or `echo '{"foo":42}' | json`
hash pygmentize &>/dev/null
if [ $? -eq 1 ]; then
sudo easy_install Pygments
fi
function json() {
if [ -t 0 ]; then # argument
python -mjson.tool <<< "$*" | pygmentize -l javascript
else # pipe
python -mjson.tool | pygmentize -l javascript
fi
}
# All the dig info
function digga() {
dig +nocmd "$1" any +multiline +noall +answer
}
# Docker Commands
function dc() {
docker-compose $@
}
function doc() {
docker $@
}
function doc-cleanup() {
docker rm -f $(docker ps -a | grep Exited | grep -v "(0)" | awk '{print $1}')
docker rmi $(docker images -f "dangling=true" -q)
docker images -q | xargs docker rmi
}
function doc-clear() {
docker rm -f $(docker ps -a -q)
docker rmi -f $(docker images -q)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment