3 export COMPLETION_DIR_SSH=~/.ssh/hosts
4 export COMPLETION_DIR_TELNET=~/.telnet/hosts
5 export COMPLETION_DIR_RDP=~/.ssh/hosts
6 export COMPLETION_DIR_PING="$COMPLETION_DIR_SSH $COMPLETION_DIR_TELNET $COMPLETION_DIR_RDP"
8 function _generic_completion() {
9 COMPLETION_DIR=${1+"$@"}
11 cur=${COMP_WORDS[COMP_CWORD]}
13 HOSTS="$(find $COMPLETION_DIR -type f -perm -100 2>/dev/null | sed 's@.*/@@')"
15 COMPREPLY=($(compgen -W "$HOSTS" -- "$cur"))
19 # Process completion for killall.
21 cur=${COMP_WORDS[COMP_CWORD]}
23 PROCESSES="$(ps agx --no-heading | awk '{ print $5 }' | sed 's@.*/@@' | sort | uniq)"
25 COMPREPLY=($(compgen -W "$PROCESSES" -- "$cur"))
29 # Host completion for SSH known hosts.
30 function _known_hosts() {
31 cur=${COMP_WORDS[COMP_CWORD]}
33 HOSTS=$(sed 's/[ ].*//;s/,/\
34 /' ~/.ssh/known_hosts)
36 COMPREPLY=($(compgen -W "$HOSTS" -- "$cur"))
40 # Process completion for kill, strace etc.
42 cur=${COMP_WORDS[COMP_CWORD]}
44 PROCESSES="$(find /proc -name '[0-9]*' -maxdepth 1 2>/dev/null | sed 's@.*/@@')"
46 COMPREPLY=($(compgen -W "$PROCESSES" -- "$cur"))
50 # Complete ssh with hostnames from the Window Maker menu.
52 _generic_completion $COMPLETION_DIR_SSH
56 # Complete telnet with hostnames from the Window Maker menu.
58 _generic_completion $COMPLETION_DIR_TELNET
62 # Complete rdesktop with hostnames from the Window Maker menu.
64 _generic_completion $COMPLETION_DIR_RDP
68 # Ping hosts from any of the above lists.
70 _generic_completion $COMPLETION_DIR_PING
73 # Hacked up make rule.
76 cur=${COMP_WORDS[COMP_CWORD]}
78 RULES="all check clean dep depend install reinstall setup uninstall"
80 COMPREPLY=($(compgen -W "$RULES" -- "$cur"))
85 function _modprobe() {
87 cur=${COMP_WORDS[COMP_CWORD]}
90 MODULES="$(find /lib/modules/$ver -name \*.ko | sed -n 's@^.*/\([^/]*\).ko$@\1@p')"
92 COMPREPLY=($(compgen -W "$MODULES" -- "$cur"))
96 # Look for loaded modules.
99 cur=${COMP_WORDS[COMP_CWORD]}
101 MODULES="$(lsmod | sed '1d;s/ .*$//')"
103 COMPREPLY=($(compgen -W "$MODULES" -- "$cur"))
107 complete -F _ssh rollout
109 complete -F _ssh sshterm
110 complete -F _ping telnet
111 complete -F _telnet telnetterm
112 complete -F _rdp rdesktop
113 complete -F _ping ping
114 complete -F _ping traceroute
115 complete -F _ping dnsip
116 complete -F _make make
117 complete -F _process killall
118 complete -F _pid kill
119 complete -F _pid strace
120 complete -F _known_hosts kill_known_host
121 complete -F _known_hosts knh
122 complete -F _modprobe modprobe
123 complete -F _rmmod rmmod