Skip to content

Instantly share code, notes, and snippets.

View echu's full-sized avatar

Eric Chu echu

View GitHub Profile
# useful bits to remove temp files in shell scripts
FILE=$(mktemp)
function remove_temp_output {
rm $FILE
}
trap remove_temp_output EXIT
@echu
echu / git2pypi.sh
Last active March 4, 2023 19:53
Turning `git describe` into acceptable PyPi version strings.
# Assumes releases are tagged with "vMAJOR.MINOR.PATCH" (semver)
# The first sed removes the leading "v" (this step is not entirely necessary)
# The second sed uses the "number of commits since tag" to create a dev version and uses the sha as the "local version"
#
# If the second sed fails, it will just print the returns of the first sed
#
# Sample output:
# 0.3.0.dev1+g7a45b05
# 0.3.0.dev3+g8418ac6.dirty
# 2.7.1rc2.dev17.dirty
# to bootstrap, run `brew install git bash-completion`
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
if hash brew 2>/dev/null; then
export HOMEBREW_CASK_OPTS="--appdir=~/Applications"
fi