Skip to content

Instantly share code, notes, and snippets.

@justanotherdot
Last active April 7, 2019 23:40
Show Gist options
  • Save justanotherdot/bc2a97910d2e6763e9a6661db0f6552b to your computer and use it in GitHub Desktop.
Save justanotherdot/bc2a97910d2e6763e9a6661db0f6552b to your computer and use it in GitHub Desktop.
# Little aliases and tidbits.
# Assumes shell is `zsh`.
if [ $(uname | tr [A-Z] [a-z]) = "darwin" ]; then
time="gtime" # GNU time installed via homebrew
fi
# Show revision history and full commit on right hand side.
commits() {
limit_arg=$1
limit=${limit_arg:=50000}
git l -$limit | fzf --reverse +s --preview 'echo {} | cut -f1 -d" " | xargs -I{} git show {}'
}
# Quick ping of a DNS.
up() {
box=$1
dns_to_test=${box=www.google.com}
ping -c 3 "$dns_to_test"
}
# Tell what branch each repository under `$HOME/work` is on.
# TODO: Make the default $HOME/work, but allow specifying an exact directory.
branchstat() {
find $HOME/work -name ".git" -type d | grep -v vendor | xargs -i sh -c 'echo "`dirname {} | xargs -I % basename %`: `git --git-dir='{}' rev-parse --abbrev-ref HEAD`"'
}
docker_clean() {
docker system prune --all --force --volumes
}
## Haskell specific stuff to be replaced by `g'
## see https://github.com/justanotherdot/g
# List available GHC versions
# ghc-list-available() {
# echo "Available versions:"
# for ver in $HOME/haskell/ghc-*; do
# echo " ${ver##$HOME/haskell/ghc-}"
# done
# }
# Switch to a specific GHC version
# ghc-switch() {
# if [ -z "$1" ]; then
# echo "USAGE: ghc-switch VERSION"
# ghc-list-available
# return 1
# fi
# VER_PATH="$HOME/haskell/ghc-$1"
# if [ -d "$VER_PATH" ]; then
# export path=($VER_PATH/bin ${(@)path:#*ghc*})
# export GHC_VERSION=$1
# ghc --version
# else
# echo "GHC $1 isn't available"
# ghc-list-available
# return 1
# fi
# }
# Cycle GHC versions
# g() {
# case $GHC_VERSION in
# 7.10.2)
# ghc-switch 7.10.2
# ;;
# 8.0.1)
# ghc-switch 8.0.1
# ;;
# 8.0.2)
# ghc-switch 8.0.2
# ;;
# 8.2.2)
# ghc-switch 8.2.2
# ;;
# *)
# ghc-switch 8.0.1
# ;;
# esac
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment