Skip to content

Instantly share code, notes, and snippets.

@technige
Created July 12, 2023 12:27
Show Gist options
  • Save technige/aa0801f769fd4e7a7f97d0a093c08531 to your computer and use it in GitHub Desktop.
Save technige/aa0801f769fd4e7a7f97d0a093c08531 to your computer and use it in GitHub Desktop.
Alt switcher for bash
#!/usr/bin/env bash
MENU=$1
OPTION=$2
MENU_PATH=${HOME}/.alt/${MENU}
cd ${MENU_PATH}
if [ ! -z "$OPTION" ]
then
rm -f .current
ln -s ${OPTION} .current
fi
CURRENT_OPTION=$(readlink .current)
for OPTION in $(ls ${MENU_PATH})
do
if [ "${OPTION}" == "${CURRENT_OPTION}" ]
then
echo -e "\033[36;1m${OPTION}\033[0m"
else
echo "${OPTION}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment