Linux (e.g. Ubuntu) terminal, is there a method to get the last line? Say I am randomly typing a td
command, which has not been installed on my system, so I will get a message like below. I would like to have a "shortcut" to run sudo apt-get install textdraw
quickly.
Is there such a tool or how can I copy the last line to clipboard without using the mouse?
username@WorkStation:~$ td
The program 'td' is currently not installed. You can install it by typing:
sudo apt-get install textdraw
username@WorkStation:~$
Best Answer
If you don't mind a little obscenity (I don't), you might want to use the fuck, a tool that does exactly what you asked for.
Well, not exactly, but it solves the same problem. Instead of just getting the latest line, it tries to match the last command you typed.
The examples shown in the repository show several of the scenarios you mentioned.