Hello catch22,
What you want to do can be done using a thing called
Functions.
Code: Select all
apt-get () {
if printf '%s\n' "$*" | grep -q '^dist-upgrade$'; then
cat <<- 'END'
Are you sure you wouldn't rather use the GUI update manager? It's much safer!
y) Yes
n) No
END
while read -p '#' yn; do
case $yn in
y )
break
;;
n )
command sudo apt-get dist-upgrade
break
;;
esac
done
else
command sudo apt-get $*
fi
}
Don't worry, the code above is not as hard as it looks.
What the code above does is create a function called 'apt-get', check if only 'dist-upgrade' is given as parameter, if so, use a heredoc with cat to show some text and execute a while loop that asks you for input using read.
The while loop will repeat unless 'y' or 'n' are given.
If anything different then just 'dist-upgrade is given, it will just execute 'sudo apt-get' normally without asking anything.
If you want to run this in every terminal for your user, add this code to .bashrc in your home directory.
Files starting with a dot are hidden, so you should show hidden files for your file manager to see it.
UPDATE: Every 3 beginning whitespace's where meant to be a tab, if you run it as is, it will give a error on parsing the heredoc.
To fix, change every 3 whitespaces to tabs or remove all beginning whitespaces.