Monday, March 9, 2009

Tip: Enable sudo completion in tcsh/csh shell

Having installed and setup sudo I realized that the C shell (e.g. tcsh/csh) didn't autocomplete commands issued after typing sudo.

Place the following in your .cshrc file:
set complete = enhance
complete sudo 'n/-l/u/' 'p/1/c/'
And finally source the changes:
% source .cshrc
For more information visit tcsh(1) in the REFERENCE section under complete.

1 comment:

joce said...

Fine, but this does not complete the commands that are in the root's $PATH and usually not in the user's, such as /sbin. And these are among the most relevant—things you can't do as a regular user.

Unfortunately it seems that complete does not allow a complementary list to be added to the default command list... Any idea to trick it?