1

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.

3

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).

3
  • So this could be something configured to work on OSX if desired? – icicleking Apr 27 '17 at 17:30
  • 1
    Probably! A quick search leads to this (which I haven’t tested). – Stephen Kitt Apr 27 '17 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. – Gilles 'SO- stop being evil' Apr 27 '17 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.