Shortcut to run current command with sudo in bash
For me, I mostly forget to add “sudo” to the command until the time I am actually supposed to run it. Also sometimes, on some systems, bash completion does not work as expected with “sudo”. With these in mind, I wanted something such that when I have completed the command, I could insert sudo in the begining of the command without much ado. So, finally this is what I came up with in my “~/.inputrc” file. Note: If you don’t have this file, then simply create this file.
"C-k":"C-a sudo n"
Related articles
Related Articles:
- 2012/05/07 Array of all possible colors in bash script
- 2012/04/30 colors in bash scripts
- 2011/09/27 some interesting alias
- 2011/09/16 better bash debugging
- 2011/08/09 bash completion
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.