As I got hit with a meme about command line stuff, I figured I'd share an update to my favorite bash completion:
SSH_COMPLETE=( $(cut -f1 -d' ' ~/.ssh/known_hosts |\
tr ',' '\n' |\
sort -u |\
grep -e '[:alpha:]') )
complete -o default -W "${SSH_COMPLETE[*]}" ssh
If you ssh directly to IP addresses very often, you might want to leave
off the last grep -e.
Not going to tag anyone, but if you have a favorite completion, please share! (I suggest not in a comment on this post as my comment system does not preserve any formatting).
writebacks...
zsh
Bash became the "standard" shell, but if you are into command-line wizardry, give the Z shell [http://zsh.sourceforge.net/] a try. Coincidentally, I'm preparing an internal/informal presentation about using the cmd-line to be more productive. Many developers ignore the power of the CLI.
fish
You should try fish, my favorite shell. It totally has that built-in :) http://blog.tracefunc.com/2008/04/11/fish-at-last
Username completion?
Interesting, but doesn't seem to work with username@host. Unfortunately it's not often that my workstation username matches my login name on the server (or else I have a number of different usernames on the server)... Trying to understand how the heck that thing works...
Brilliant! But it also shows all the cruft I have in my known_hosts file. Doing some cleanup :-)
username completion
Hi Andrew. you should do that in your config file man ssh_config or google.. it's quite easy. and Thanks Brian.. i love this auto-complete
comment...