blob: 769133301c7463cd60765f0fa6f69e0e6ff275d5 [file] [log] [blame]
Andy Shene0d85822010-12-04 11:03:33 +11001#!/bin/bash
2# Bash completion support for ssh.
3
4export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
5
6_sshcomplete() {
7 if [ -f $HOME/.ssh/config ]; then
8 COMPREPLY=($(compgen -W "`ruby -e"puts open('${HOME}/.ssh/config', 'r') { |f| f.readlines }.find_all { |l| l =~ /^Host/ }.inject([]) { |hosts, line| hosts << line[5..-1].split }.flatten.sort.uniq"`" -- ${COMP_WORDS[COMP_CWORD]}))
9 return 0
10 fi
11}
12
13complete -o default -o nospace -F _sshcomplete ssh