Skip to main content

Posts

Showing posts from February, 2018

Make scp autocomplete server names and file/folders names on Ubuntu 16.04

I was struggling to make scp  auto-complete servers names but also complete local  files names under Ubuntu bash. For some strange reason, out of the box solutions just didn't work, I could make the server completion work or the local files completion work but not both. And I'm not even talking about remote file names over SSH, just local file names. Installing auto-complete on Ubuntu if not already there: https://unix.stackexchange.com/questions/136351/autocomplete-server-names-for-ssh-and-scp/335143 Replace /etc/bash_completion.d/ssh with the following content:           ssh ( )          {          local cur  prev  opts          COMPREPLY =( )          cur="${COMP_WORDS[COMP_CWORD]}"           prev ="${COMP_WORDS[COMP_CWORD-1]}"          opts=$(grep '^Host' ~/. ssh /config | grep -v ' [?* ]' | cut -d ' ' -f 2-)                   _ longopt          RESULT="$COMPREPLY $opts"          COM