Debian’s apt-get and related tools are pretty fantastic. The
command_not_found_handle tells you the package to install if the command you’re trying to run is not found.
> pacman The program 'pacman' is currently not installed. You can install it by typing: sudo apt-get install pacman > # okay, fine, let me type or copy/paste that > sudo apt-get install pacman
I don’t want that message to have an interactive prompt at the end (“Go ahead and install it? (y/n):”) but I do want a quick way of doing what it says. The computer just told me exactly what needs to be typed, so why do I need to type it myself?
This alias reruns your last command, grabs the last line from the error message, and runs it.
alias doit='$($(history -p \!\!) 2>&1 | tail -n1)'
> pacman The program 'pacman' is currently not installed. You can install it by typing: sudo apt-get install pacman > # I've been expecting you > doit Reading package lists... Done [...]