scp remote path completion #42

Closed
ridiculousfish opened this Issue Jun 6, 2012 · 3 comments

Comments

Projects
None yet
2 participants
@ridiculousfish
Member

ridiculousfish commented Jun 6, 2012

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.

@ridiculousfish

This comment has been minimized.

Show comment
Hide comment
@ridiculousfish

ridiculousfish Jul 12, 2012

Member

Thanks! Integrated here:

To git@github.com:fish-shell/fish-shell.git
1cd6195..830fba6 master -> master

Member

ridiculousfish commented Jul 12, 2012

Thanks! Integrated here:

To git@github.com:fish-shell/fish-shell.git
1cd6195..830fba6 master -> master

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jul 24, 2012

I do not know if this is necessary with the latest git version (I'm using the tar archive from the homepage), but adding the "-p" switch to the 'ls' command appends a slash '/' if the completed name is a directory. This makes completion even more convenient (for me) because I do not have to use backspace + '/' in order to continue after completing a path.

But I do not know how portable the '-p' switch is (should be there on GNU systems).

ghost commented Jul 24, 2012

I do not know if this is necessary with the latest git version (I'm using the tar archive from the homepage), but adding the "-p" switch to the 'ls' command appends a slash '/' if the completed name is a directory. This makes completion even more convenient (for me) because I do not have to use backspace + '/' in order to continue after completing a path.

But I do not know how portable the '-p' switch is (should be there on GNU systems).

@ecraven

This comment has been minimized.

Show comment
Hide comment
@ecraven

ecraven Aug 2, 2012

Contributor

I'd second lyro's suggestion, otherwise you have to add / all over the place

Contributor

ecraven commented Aug 2, 2012

I'd second lyro's suggestion, otherwise you have to add / all over the place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment