Our great sponsors
-
find-the-command
Discontinued Interactive command-not-found hook for bash and zsh, that uses pacman as a backend (BTW, this shit should be completely re-written as it's very ugly)
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
ohmyzsh
🙃 A delightful community-driven (with 2,300+ contributors) framework for managing your zsh configuration. Includes 300+ optional plugins (rails, git, macOS, hub, docker, homebrew, node, php, python, etc), 140+ themes to spice up your morning, and an auto-update tool so that makes it easy to keep up with the latest updates from the community.
Another comment mentioned the fuck tool https://github.com/nvbn/thefuck/blob/master/thefuck/rules/sudo.py it seems that they use a simple error message check list to guess which command failed due to permissions.
I don't think something like that is impossible. See how find-the-command hooks into bash errors to display other info or run a sudo command automatically if configured. https://github.com/agura-lex/find-the-command/blob/master/usr/share/doc/find-the-command/ftc.bash
In zsh, more specifically in oh-my-zsh they have an addon for sudo where if you double press "esc" it basically does "sudo !!" and you can also use it to add "sudo" to the command you are typing so it makes it less of an annoyance.