Reuse last line on terminal
When one issues a command that does not exist in the terminal, it results in:
The program 'programname' is not installed. You can install it by typing:
sudo apt-get install programname
Is there any shortcut by which one does not have to retype the 'sudo apt-get install programname' line?
Solution 1:
There is none by default, but it is not so hard to define one:
alias ii='sudo apt-get install'
You can then just call
ii !!
For more information, read man bash
on aliases and history.
Solution 2:
Since the suggested command was not typed before, it won't be in the bash history. So Up Arrow or .bash_history
will not help.
setting an alias for sudo apt-get install
will reduce some typing but you still need to type the name of the program, particularly if the programname is differnt from the package-name.
The simplest way to "type" the command without typing is to copy the line from the terminal and paste it.
- To copy the line, highlight
sudo apt-get install programname
using the mouse and press Ctrl+Shift+C. - To paste, make sure the cursor is at the
$
prompt and press Ctrl+Shift+V.
Hope this help.