macosbashsshosx-yosemitescp

Remote path completion with scp on OSX


On Linux, you can do

$ scp some-file.txt user@remote.host.com:/some/pa<tab>

and it would autocomplete the remote path, if you have key based authentication up and running for that host. However, on OSX it doesn't seem to work, using iTerm2. Any hints?


Solution

  • This depends on your shell. In case you are using bash you need the correct bash completion scripts.

    See the Bash completion project, and especially this script: https://github.com/scop/bash-completion/blob/master/completions/ssh

    Default location where those have to be put is /etc/bash_completion and then you can load them from your .bashrcor .profile file by adding something like . /etc/bash_completion (mind the . to source the file)

    While focused on Linux they should work on Mac, too.

    Homebrew and other software managers provide bash-completion, too. If installed check your .bashrc/.profile according to the instructions to properly load it.