Skip to content

Instantly share code, notes, and snippets.

@manila
manila / prompt.sh
Created August 5, 2023 16:24
Source into bash profile for a better prompt for piper | fig | git workspaces
print_relative_dir() {
re="^$HOME(/?.*)"
[[ "$PWD" =~ $re ]] && echo "~${BASH_REMATCH[1]}" || echo "$PWD"
}
is_workspace() {
# Path on macOS will begin with /Volumes
re="^(/Volumes)?(/google/src/cloud)/(${USER})/([^/]+)(/.*)?"
dir="$PWD"
[[ "$dir" =~ $re ]] && return 0 || return 1