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 # Process completion for kill, strace etc.
31 cur=${COMP_WORDS[COMP_CWORD]}
33 PROCESSES="$(find /proc -name '[0-9]*' -maxdepth 1 2>/dev/null | sed 's@.*/@@')"
35 COMPREPLY=($(compgen -W "$PROCESSES" -- "$cur"))
39 # Complete ssh with hostnames from the Window Maker menu.
41 _generic_completion $COMPLETION_DIR_SSH
45 # Complete telnet with hostnames from the Window Maker menu.
47 _generic_completion $COMPLETION_DIR_TELNET
51 # Complete rdesktop with hostnames from the Window Maker menu.
53 _generic_completion $COMPLETION_DIR_RDP
57 # Ping hosts from any of the above lists.
59 _generic_completion $COMPLETION_DIR_PING
62 # Hacked up make rule.
65 cur=${COMP_WORDS[COMP_CWORD]}
67 RULES="all check clean dep depend install reinstall setup uninstall"
69 COMPREPLY=($(compgen -W "$RULES" -- "$cur"))
73 complete -F _ssh rollout
75 complete -F _ssh sshterm
76 complete -F _ping telnet
77 complete -F _telnet telnetterm
78 complete -F _rdp rdesktop
79 complete -F _ping ping
80 complete -F _ping traceroute
81 complete -F _ping dnsip
82 complete -F _make make
83 complete -F _process killall
85 complete -F _pid strace