Created
December 20, 2021 02:03
-
-
Save Natetronn/0c88a35bf381ba8f54bca4ac5d0eb451 to your computer and use it in GitHub Desktop.
Grub menuentry picker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# grub menuentry picker | |
function grub-entry () { | |
# Search for grub.cfg | |
GRUB_CFG=$(find /boot -name grub.cfg 2> /dev/null) | |
CUSTOM_CFG=$(find /boot -name custom.cfg 2> /dev/null) | |
LIVEISO_CFG=$(find /boot -name liveiso.cfg 2> /dev/null) | |
if [[ -z ${GRUB_CFG} ]]; then | |
echo "No grub.cfg found under /boot. Try as root." | |
exit 1 | |
elif [[ ! -r ${GRUB_CFG} ]]; then | |
echo "${GRUB_CFG} is not readable. Try as root." | |
exit 1 | |
fi | |
GRUB_MENUENTRY=$(awk -F\' '/^#/ {next} /menuentry / {print $2}' ${GRUB_CFG} ${CUSTOM_CFG} ${LIVEISO_CFG} | xargs -L1 | sort | fzf --reverse) | |
# Set boot target for next boot | |
#grub-reboot "${GRUB_MENUENTRY}" | |
sudo grub-set-default "${GRUB_MENUENTRY}" | |
echo "Do you wish to reboot now?" | |
select yn in "Yes" "No" | |
case $yn in | |
Yes ) reboot;; | |
No ) exit;; | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment