I recently switched from OSX to Linux for my personal use. I have a home media server running headless Ubuntu, and now a laptop running Mint. My habit is to move things to the server with scp. In the past, on OSX, when I typed to copy target I would painstakingly type each character of the path, because if out of habit I tried to tab complete the machine would get all cranky and I'd have to start over again. However, I just set up the ssh keys of my new computer and was in the process of scping a file from laptop to server, when I accidentally hit tab, and much to my surprise, it completed the path correctly! Is this normal behavior? Why did it not work on term2 on OSX? Note, I did have an open connection to the the server in another terminal window.

1 Answer 1


This is your shell’s command completion in action: it “knows” that when the current command-line starts with scp, in certain contexts it needs to connect to the target system (if it can) to complete paths there. This can be done transparently because you’ve loaded your key.

You’ll see this typically implemented in /usr/share/bash-completion/completions/scp (if you’re using Bash), or /usr/share/zsh/functions/Completion/Unix/_ssh (for Zsh).

  • So this could be something configured to work on OSX if desired?
    – icicleking
    Apr 27, 2017 at 17:30
  • 1
    Probably! A quick search leads to this (which I haven’t tested). Apr 27, 2017 at 17:50
  • 1
    @icicleking Yes. On OSX I recommend switching to zsh, because OSX's version of bash is old and won't change, but even on that old version you can have context-sensitive completion. Apr 27, 2017 at 22:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .