2 export COMPLETION_DIR_SSH=~/.ssh/hosts
3 export COMPLETION_DIR_TELNET=~/.telnet/hosts
4 export COMPLETION_DIR_RDP=~/.ssh/hosts
5 export COMPLETION_DIR_PING="$COMPLETION_DIR_SSH $COMPLETION_DIR_TELNET $COMPLETION_DIR_RDP"
7 function _generic_completion() {
8 COMPLETION_DIR=${1+"$@"}
10 cur=${COMP_WORDS[COMP_CWORD]}
12 HOSTS="$(find $COMPLETION_DIR -type f -perm -100 | sed 's@.*/@@')"
14 COMPREPLY=($(compgen -W "$HOSTS" -- "$cur"))
18 # Process completion for killall.
20 cur=${COMP_WORDS[COMP_CWORD]}
22 PROCESSES="$(ps agx --no-heading | awk '{ print $5 }' | sed 's@.*/@@' | sort | uniq)"
24 COMPREPLY=($(compgen -W "$PROCESSES" -- "$cur"))
28 # Process completion for kill, strace etc.
30 cur=${COMP_WORDS[COMP_CWORD]}
32 PROCESSES="$(find /proc -name '[0-9]*' -maxdepth 1 | sed 's@.*/@@')"
34 COMPREPLY=($(compgen -W "$PROCESSES" -- "$cur"))
38 # Complete ssh with hostnames from the Window Maker menu.
40 _generic_completion $COMPLETION_DIR_SSH
44 # Complete telnet with hostnames from the Window Maker menu.
46 _generic_completion $COMPLETION_DIR_TELNET
50 # Complete rdesktop with hostnames from the Window Maker menu.
52 _generic_completion $COMPLETION_DIR_RDP
56 # Ping hosts from any of the above lists.
58 _generic_completion $COMPLETION_DIR_PING
61 # Hacked up make rule.
64 cur=${COMP_WORDS[COMP_CWORD]}
66 RULES="all check clean dep depend install reinstall setup uninstall"
68 COMPREPLY=($(compgen -W "$RULES" -- "$cur"))
72 complete -F _ssh rollout
74 complete -F _ssh sshterm
75 complete -F _ping telnet
76 complete -F _telnet telnetterm
77 complete -F _rdp rdesktop
78 complete -F _ping ping
79 complete -F _ping traceroute
80 complete -F _ping dnsip
81 complete -F _make make
82 complete -F _process killall
84 complete -F _pid strace