Mac ::: Create on-the-fly hostname lists for ssh tab completion
March 27th, 2008 at 18:33
Raw copy/quote from macosxhints.com:
If you don’t want to manage server lists for tab completion with ssh, put the following line in your .bash_profile file in your home directory:
complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh
This will allow you to tab complete any hostname you've previously ssh'd to.
[robg adds: This worked as described for me. The complete command is a built-in bash function that lets you specify lists of options to be used with tab completion on a given command. The version above parses your known_hosts to create the list of options. You can read more about the complete built-in function in the bash man pages -- man bash, then search for the section titled Programmable Completion.]
Tags: cli, hostname, macosxhints, ssh://, tab
Raw copy/quote from macosxhints.com:
If you don't want to manage server lists for tab completion with ssh, put the following line in your .bash_profile file in your home directory:
complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh
This will allow you to tab complete any hostname you've previously ssh'd to.
[robg adds: This worked as described for me. The complete command is a built-in bash function that lets you specify lists of options to be used with tab completion on a given command. The version above parses your known_hosts to create the list of options. You can read more about the complete built-in function in the bash man pages -- man bash, then search for the section titled Programmable Completion.]
Posted by fidel,
in mac, Terminal
November 9th, 2010 at 17:35
…
I found your web site on google and verify a couple of of your early posts. Keep up the excellent operate. I just additional up your RSS feed to my MSN News Reader. Searching forward to reading through additional from you later on!…