X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=.profile.d%2Fcompletion.bashrc;h=8ff324d9192081e0d3800e4c85524b970a316b46;hb=d6ccc8abb1b587d6c9e2b4f416c1236cc61e7c3c;hp=90db89c973ff2eff31cbc35cb23624c8b1a8f620;hpb=ba8e8ba49ac7d26a21537f55af435119dcb510de;p=profile.git diff --git a/.profile.d/completion.bashrc b/.profile.d/completion.bashrc index 90db89c..8ff324d 100644 --- a/.profile.d/completion.bashrc +++ b/.profile.d/completion.bashrc @@ -1,9 +1,11 @@ -# $Id$ +# Old bash doesn't have completion support. +if ! builtin complete 2>&1 | grep 'not a shell builtin' >/dev/null; then + # Helper! -export COMPLETION_DIR_SSH=~/.ssh/hosts -export COMPLETION_DIR_TELNET=~/.telnet/hosts -export COMPLETION_DIR_RDP=~/.ssh/hosts -export COMPLETION_DIR_PING="$COMPLETION_DIR_SSH $COMPLETION_DIR_TELNET $COMPLETION_DIR_RDP" +COMPLETION_DIR_SSH=${PROFILE_HOME:-~}/.ssh/hosts +COMPLETION_DIR_TELNET=${PROFILE_HOME:-~}/.telnet/hosts +COMPLETION_DIR_RDP=${PROFILE_HOME:-~}/.rdp/hosts +COMPLETION_DIR_PING="$COMPLETION_DIR_SSH $COMPLETION_DIR_TELNET $COMPLETION_DIR_RDP" function _generic_completion() { COMPLETION_DIR=${1+"$@"} @@ -103,6 +105,15 @@ function _rmmod() { return 0 } +# Find tags with GNU GLOBAL. +function _global() { + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + + COMPREPLY=($(global -c "$cur")) + return 0 +} + complete -F _ssh rollout complete -F _ssh ssh complete -F _ssh sshterm @@ -120,3 +131,6 @@ complete -F _known_hosts kill_known_host complete -F _known_hosts knh complete -F _modprobe modprobe complete -F _rmmod rmmod +complete -F _global global + +fi