Enable Autocomplete for root on Mac OS

Are you frustrated by the lack of autocomplete in root’s shell on Mac OS? I’ve tried a few different solutions, and the easiest / simplest I found is to create an /etc/inputrc file (chown root:wheel and chmod 644) with the following text.

"\C-i": complete

The /etc/inputrc file is used by readline — the input-related library used by bash and most other shells. GNU’s readline init file syntax page documents all the available settings.

Continue reading


Autocomplete SSH Hostnames

There are plenty of SSH autocomplete (or command-line completion) scripts available on the web, but I found most don’t go far enough — they usually just parse the ~/.ssh/known_hosts, ignoring the ~/.ssh/config and /etc/hosts files. Some of these scripts also generate a static autocomplete list at login, and can’t include new hostnames added during the session. The following script uses a function call to autocomplete hostnames dynamically, and fetches hostnames from the ~/.ssh/known_hosts, ~/.ssh/config and system-wide /etc/hosts file.

Continue reading