Skip to content

Instantly share code, notes, and snippets.

@nalipaz
Last active January 19, 2017 00:11
Show Gist options
  • Save nalipaz/a8730ea349855f5ba871db90492f58c7 to your computer and use it in GitHub Desktop.
Save nalipaz/a8730ea349855f5ba871db90492f58c7 to your computer and use it in GitHub Desktop.
Make direnv do function aliases
export_alias() {
local name=$1
local alias_dir=$PWD/.direnv/aliases
mkdir -p "$alias_dir"
PATH_add "$alias_dir"
local target="$alias_dir/$name"
if declare -f "$name" >/dev/null; then
echo "#!/usr/bin/env bash" > "$target"
declare -f "$name" >> "$target" 2>/dev/null
echo "$@" >> "$target"
chmod +x "$target"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment