tab completion with scp
A person learns new things all the time. I was scp'ing a file to another machine, and happened to hit tab by habit while entering the pathname on the other machine, and lo and behold, it completed it. The path does not exist on the local machine. I found some reference to it in a post here but I had never heard of this. Does bash save the paths from machines? If so where (it was not in the history file). ...surely it does not make a connection to the other machine just for path completion. Just quite intrigued, any info is welcome.
|
I wouldn't have thought so, either... give's the example of
what it expanded? I had cases that an expansion gave me a "path" on the remote machine when part of it matched ... E.g. I was in ~, have a directory downloads ... scp test.tar.gz tink@machine:/home/do<TAB> and it completed the "wnloads" for me ... of course, the "full" path didn't exist on the remote machine ... Cheers, Tink |
It does make an ssh connection. I suspect it only works with the use of passwordless publickeys.
Here is a real example (except for hostname): I have a /tmp/mp3 directory on both the host and the client, but they have totally different file structures. I know I have not accessed these on the host, but when I do the following scp /etc/hosts myhomecomputer.net:/tmp/add Then hit tab (a few times, response is not immediate like on the local machine), I get the following: $ scp /etc/hosts myhomecomputer.net:/tmp/mp3/add_200 /tmp/mp3/add_2004-03-21/ /tmp/mp3/add_2004-07-31/ /tmp/mp3/add_2004-12-10/ /tmp/mp3/add_2004-05-05/ /tmp/mp3/add_2004-11-07/ /tmp/mp3/add_2005-01-14/ /tmp/mp3/add_2004-06-23/ /tmp/mp3/add_2004-11-08/ /tmp/mp3/add_2005_01_08/ Those are the directories that begin with add. It adds the 200 and then gives the directories (there are three per line, wrapped in this window). if I type "scp /etc/hosts myhomecomputer.net:/tmp/sa" and then hit tab, I get $ scp /etc/hosts fsbooks.homeunix.org:/tmp/save /tmp/save/ /tmp/save2/ I have a /tmp/save, a /tmp/sage, but no /tmp/save2 on the local computer. Proof is in the log files. I use public keys, so everytime I get a little more information with the tab key (viewed with tail -f /var/log/messages in another terminal window), I get a line in the host /var/log/messages file (again computer name, login name, and IP obscured): Feb 26 23:37:22 myhomecomputer sshd[9984]: Accepted publickey for fsbooks from ::ffff:000.000.00.0 port 52307 ssh2 Feb 26 23:37:33 myhomecomputer sshd[9992]: Accepted publickey for fsbooks from ::ffff:000.000.00.0 port 52325 ssh2 Kind of cool. |
How odd ... I can't replicate that behaviour, even though
I have passwordless ssh connections to two machines set-up here ... bash-completion is on a pretty high level, too, but only the original version of gnu.org ... maybe the distro you're using has hacked that thing? Cheers, Tink |
The package bash-completion-20040711-noarch-1 (which is installed on this slackware-current box) adds this capability. I came across the file /etc/bash_completion accidentally.
Quote:
|
Still odd ... I do (and did back then) indeed use the
same thing :} Cheers, Tink |
All times are GMT -5. The time now is 08:40 PM. |