Powered By

Powered by Blogger

Selasa, 09 Maret 2010

How To Autocomplete Commands Preceded By 'sudo' [Quick Ubuntu Tip]

When writing a command in the terminal, you can autocomplete it by pressing the TAB key. Example: type "nau" in the terminal and press TAB -> "nautilus" should show up (if you have Nautilus installed, obviously).

However, the autocomplete doesn't work in Ubuntu if you are trying to run a command with "sudo". For example, typing "sudo nau" and then pressing the TAB key will not autocomplete the command to "sudo nautilus".

Here is how to get autocomplete to work in the Terminal while using "sudo". Simply open the ".bashrc" hidden file from your home folder. If you use GNOME, paste this in a terminal to open it:

sudo gedit ~/.bashrc

Then paste this at the bottom of the file:
if [ "$PS1" ]; then
complete -cf sudo

Then type this in a terminal to reload:

Now try the example in the beginning of the file "sudo nau" and press TAB. It should now work.

Tidak ada komentar:

Posting Komentar