Skip to content

scp remote path completion #42

Description

@ridiculousfish

pants writes:

There doesn't seem to be one of these available in the archives, and
it's the thing I've missed most since moving from zsh, so I figured I'd
really get fishy and write it. Appending the following to your scp.fish
(or making an alternate scp.fish in .config/fish/completions) will allow
you to preform tab completion of remote paths for scp! Identical
completions could also provide identical functionality in rsync. It
would be nice to integrate fish's built-in description methods, but I
can't think of a way to do that without ensuring fish is installed on
the remote system (not a general fix) or mounting an sshfs (gross).

Code:
complete -c scp -d "Remote Path" -n "echo (commandline -ct)|sgrep -o '.*:';and true" -a "

(
#Prepend any user@host information supplied before the remote completion
echo (commandline -ct)|sgrep -o '.:'
)(
#Get the list of remote files from the specified ssh server
ssh -o "BatchMode yes" (echo (commandline -ct)|sed -ne 's/(.
):./\1/p') ls\ -d\ (echo (commandline -ct)|sed -ne 's/.://p')*
)

"

Enjoy!

Cheers,

pants.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions