Skip to content

Instantly share code, notes, and snippets.

@stephen-w-pracy
Created January 17, 2025 17:31
Show Gist options
  • Save stephen-w-pracy/e16ff456b6e47450d79dfc9bcaecf60c to your computer and use it in GitHub Desktop.
Save stephen-w-pracy/e16ff456b6e47450d79dfc9bcaecf60c to your computer and use it in GitHub Desktop.
boma, the shell book mark function
# I added this to my .zshrc
boma() {
case "$1" in
set)
if [ -n "$2" ]; then
export "BOMA_$2=$PWD"
echo "Bookmark '$2' set to $PWD"
else
echo "Please provide a name for the bookmark."
fi
;;
go)
if [ -n "$2" ]; then
local bookmark_var="BOMA_$2"
if [ -n "${(P)bookmark_var}" ]; then
cd "${(P)bookmark_var}" || echo "Failed to navigate to $2"
else
echo "Bookmark '$2' not found."
fi
else
echo "Please provide a name for the bookmark."
fi
;;
list)
env | grep '^BOMA_' | sed 's/^BOMA_//g' | while IFS='=' read -r name value; do
echo "$name -> $value"
done
;;
*)
echo "Usage: boma {set|go|list} bookmark_name"
;;
esac
}
# Convenient shortcuts
bose() {
boma set "$@"
}
bogo() {
boma go "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment