Skip to content

Instantly share code, notes, and snippets.

@ecto
Last active September 15, 2016 17:51
Show Gist options
  • Save ecto/77307697c8fd112d7b2ce8e554f57b3c to your computer and use it in GitHub Desktop.
Save ecto/77307697c8fd112d7b2ce8e554f57b3c to your computer and use it in GitHub Desktop.
~ :q 10:50 AM
Your shell has no parents. Are you sure you want to exit? (y/n)n
alias :q="exit"
alias exit="maybe_exit"
function maybe_exit {
PARENT="$(ps -o comm= $PPID)"
ROOT="login"
if [ $PARENT != $ROOT ]; then
exit 0;
else
read "choice?Your shell has no parents. Are you sure you want to exit? (y/n)"
case "$choice" in
y|Y ) builtin exit 0;;
n|N ) ;;
* ) maybe_exit;;
esac
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment