I'm using scp to copy files from a remote server to a local one. What's really uncomfortable is that I need to type the file path precisely. I'm used to relying on autocompletion, because file names and folder structures can be long. I want to be able to see the names of files in each directory and autocomplete just like when browsing files locally.Now, I could do SSH separately, find the file names, and use them in the SCP command. But of course, that would be a huge waste of effort. Also, I could use a GUI, but I prefer to avoid that because a command line is more lightweight.Any way to use SCP without having to remember file names exactly?
Seeing file names in SCP
ssh;autocomplete;scp
bash-completion (which is available in Cygwin, Debian, Ubuntu and no doubt many other distributions) supports scp auto-completion, as long as the shell can access the required server with no prompting (it uses ssh in batch mode, see the ssh_config(5) manual page for details).The easiest way to enable this is to use ssh-agent. This is probably enabled by default by your desktop environment; simply tryssh-addto add your default key to the currently-running agent (if any). If no agent is running, you can start one by runningeval $(ssh-agent)Once your key is known to the agent, you'll be able to auto-complete scp commands involving servers you can access with the key.I'm pretty sure zsh also supports scp auto-completion with the same caveats; the necessary support is in the zsh-common package in Debian. It needs to be enabled in your .zshrc though with something likeautoload -U compinit && compinit(which loads all the supported completions).