Skip to content

Instantly share code, notes, and snippets.

@oogali
Created July 11, 2013 13:58
Show Gist options
  • Save oogali/5975670 to your computer and use it in GitHub Desktop.
Save oogali/5975670 to your computer and use it in GitHub Desktop.
Should have known better than to paste into HN...
# Tab completion for scp/sftp/ssh based on ~/.ssh/config
complete -o default -o nospace -W "$(/usr/bin/ruby -ne 'puts $_.split(/[\s,]+/)[1..-1].reject { |h| h.match /\*|\?/ } if $_.match /^\s*Host[s]*\s+/' < ~/.ssh/config)" scp sftp ssh 2>/dev/null
@davidgiesberg
Copy link

Doesn't seem to work properly for me, here's what I'm doing:

# Tab completion for scp/sftp/ssh based on ~/.ssh/config
complete -W "$(grep '^Host' ~/.ssh/config | sort -u | sed s/Host\ //)" ssh scp sftp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment