Skip to main content
Notice removed Authoritative reference needed by Martin Vegter
Bounty Ended with Marlon Richert's answer chosen by Martin Vegter
Notice added Authoritative reference needed by Martin Vegter
Bounty Started worth 100 reputation by Martin Vegter
added 518 characters in body
Source Link
Martin Vegter
  • 848
  • 81
  • 257
  • 449

Lets say, I have one file in current directory, test.txt and I want to transfer it using scp to remote server.

When I use completion, ie:

scp -rp test<TAB> 

instead of completing the rest of the filename for me, zsh completion offers:

scp -rp test<TAB> test.txt testuser 

testuser happens to be local user on my system. Why would zsh completion complete local user, when I am connecting to remote server ?

That seems like a useless and stupid rule.

scp is using same completion file as ssh /usr/share/zsh/functions/Completion/Unix/_ssh, and ssh command has the same behavior, although in case of ssh it is less annoying, since ssh is not supposed to complete local filenames.

How can I modify the completion rules for scp so that it only offers local filenames, not local users?

UPDATE FOR BOUNTY

The accepted solution works for scp, but the problem still persist for ssh. When I want to connect to myserver.domain.org and use completion:

ssh m<TAB> 

the completion system offers myserver.domain.org (which is desired), but also local users man and messagebus, which is idiotic.

How can I change the completion system for ssh/scp so that instead of completing all local users from /etc/passwd, I can specify (hardcoded) list of users that I want to complete?

So, in other words: I don't want to disable user completion for ssh, as the accepted answer does for scp. But I want to provide my own list of users that will be completed, instead using all local users from /etc/passwd

Lets say, I have one file in current directory, test.txt and I want to transfer it using scp to remote server.

When I use completion, ie:

scp -rp test<TAB> 

instead of completing the rest of the filename for me, zsh completion offers:

scp -rp test<TAB> test.txt testuser 

testuser happens to be local user on my system. Why would zsh completion complete local user, when I am connecting to remote server ?

That seems like a useless and stupid rule.

scp is using same completion file as ssh /usr/share/zsh/functions/Completion/Unix/_ssh, and ssh command has the same behavior, although in case of ssh it is less annoying, since ssh is not supposed to complete local filenames.

How can I modify the completion rules for scp so that it only offers local filenames, not local users?

Lets say, I have one file in current directory, test.txt and I want to transfer it using scp to remote server.

When I use completion, ie:

scp -rp test<TAB> 

instead of completing the rest of the filename for me, zsh completion offers:

scp -rp test<TAB> test.txt testuser 

testuser happens to be local user on my system. Why would zsh completion complete local user, when I am connecting to remote server ?

That seems like a useless and stupid rule.

scp is using same completion file as ssh /usr/share/zsh/functions/Completion/Unix/_ssh, and ssh command has the same behavior, although in case of ssh it is less annoying, since ssh is not supposed to complete local filenames.

How can I modify the completion rules for scp so that it only offers local filenames, not local users?

UPDATE FOR BOUNTY

The accepted solution works for scp, but the problem still persist for ssh. When I want to connect to myserver.domain.org and use completion:

ssh m<TAB> 

the completion system offers myserver.domain.org (which is desired), but also local users man and messagebus, which is idiotic.

How can I change the completion system for ssh/scp so that instead of completing all local users from /etc/passwd, I can specify (hardcoded) list of users that I want to complete?

So, in other words: I don't want to disable user completion for ssh, as the accepted answer does for scp. But I want to provide my own list of users that will be completed, instead using all local users from /etc/passwd

Small clarification
Source Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k

Lets say, I have one file in current directory, test.txt and I want to transfer it using scp to remote server.

When I use completion, ie:

scp -rp test<TAB> 

instead of completing the rest of the filename for me, zsh completion offers:

scp -rp test<TAB> test.txt testuser 

testuser happens to be local user on my system. Why would zsh completion complete local user, when I am connecting to remote server ?

That seems like a useless and stupid rule.

scp is using same completion file as ssh /usr/share/zsh/functions/Completion/Unix/_ssh, and ssh command has the same behavior, although in case of ssh it is less annoying, since ssh is not supposed to complete local filenames.

How can I modify the completion rules for scp so that it doesonly offers local filenames, not offer local users  ?

Lets say, I have one file in current directory, test.txt and I want to transfer it using scp to remote server.

When I use completion, ie:

scp -rp test<TAB> 

instead of completing the rest of the filename for me, zsh completion offers:

scp -rp test<TAB> test.txt testuser 

testuser happens to be local user on my system. Why would zsh completion complete local user, when I am connecting to remote server ?

That seems like a useless and stupid rule.

scp is using same completion file as ssh /usr/share/zsh/functions/Completion/Unix/_ssh, and ssh command has the same behavior, although in case of ssh it is less annoying, since ssh is not supposed to complete local filenames.

How can I modify the completion rules for scp so that it does not offer local users  ?

Lets say, I have one file in current directory, test.txt and I want to transfer it using scp to remote server.

When I use completion, ie:

scp -rp test<TAB> 

instead of completing the rest of the filename for me, zsh completion offers:

scp -rp test<TAB> test.txt testuser 

testuser happens to be local user on my system. Why would zsh completion complete local user, when I am connecting to remote server ?

That seems like a useless and stupid rule.

scp is using same completion file as ssh /usr/share/zsh/functions/Completion/Unix/_ssh, and ssh command has the same behavior, although in case of ssh it is less annoying, since ssh is not supposed to complete local filenames.

How can I modify the completion rules for scp so that it only offers local filenames, not local users?

Source Link
Martin Vegter
  • 848
  • 81
  • 257
  • 449

zsh completion for scp completes local users when connecting to remote server

Lets say, I have one file in current directory, test.txt and I want to transfer it using scp to remote server.

When I use completion, ie:

scp -rp test<TAB> 

instead of completing the rest of the filename for me, zsh completion offers:

scp -rp test<TAB> test.txt testuser 

testuser happens to be local user on my system. Why would zsh completion complete local user, when I am connecting to remote server ?

That seems like a useless and stupid rule.

scp is using same completion file as ssh /usr/share/zsh/functions/Completion/Unix/_ssh, and ssh command has the same behavior, although in case of ssh it is less annoying, since ssh is not supposed to complete local filenames.

How can I modify the completion rules for scp so that it does not offer local users ?