X-Git-Url: http://git.iain.cx/?p=profile.git;a=blobdiff_plain;f=.profile.d%2Fcompletion.bashrc;h=0f71b59751e248a715d55937c32eff79e2365b7a;hp=fa86e5ea932e345e505ce03043c2a4b9e78c7438;hb=2067a62fdad120faa51c2ab6fedf33d55aec469d;hpb=9e07d4e358e5b0c7e9e9a949fab7293e770af6c5 diff --git a/.profile.d/completion.bashrc b/.profile.d/completion.bashrc index fa86e5e..0f71b59 100644 --- a/.profile.d/completion.bashrc +++ b/.profile.d/completion.bashrc @@ -1,8 +1,10 @@ -# $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_RDP=~/.rdp/hosts export COMPLETION_DIR_PING="$COMPLETION_DIR_SSH $COMPLETION_DIR_TELNET $COMPLETION_DIR_RDP" function _generic_completion() { @@ -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,8 +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 -unset COMPLETION_DIR_PING -unset COMPLETION_DIR_RDP -unset COMPLETION_DIR_SSH -unset COMPLETION_DIR_TELNET +fi