+# 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"
+
+function _generic_completion() {
+ COMPLETION_DIR=${1+"$@"}
+ COMPREPLY=()
+ cur=${COMP_WORDS[COMP_CWORD]}
+
+ HOSTS="$(find $COMPLETION_DIR -type f -perm -100 | sed 's@.*/@@')"
+
+ COMPREPLY=($(compgen -W "$HOSTS" -- "$cur"))
+ return 0
+}
+
+# Process completion for killall.
+function _process() {
+ cur=${COMP_WORDS[COMP_CWORD]}
+
+ PROCESSES="$(ps agx --no-heading | awk '{ print $5 }' | sed 's@.*/@@' | sort | uniq)"
+
+ COMPREPLY=($(compgen -W "$PROCESSES" -- "$cur"))
+ return 0
+}
+
+# Process completion for kill, strace etc.
+function _pid() {
+ cur=${COMP_WORDS[COMP_CWORD]}
+
+ PROCESSES="$(find /proc -name '[0-9]*' -maxdepth 1 | sed 's@.*/@@')"
+
+ COMPREPLY=($(compgen -W "$PROCESSES" -- "$cur"))
+ return 0
+}
+
+# Complete ssh with hostnames from the Window Maker menu.
+function _ssh() {
+ _generic_completion $COMPLETION_DIR_SSH
+ return 0
+}
+
+# Complete telnet with hostnames from the Window Maker menu.
+function _telnet() {
+ _generic_completion $COMPLETION_DIR_TELNET
+ return 0
+}
+
+# Complete rdesktop with hostnames from the Window Maker menu.
+function _rdp() {
+ _generic_completion $COMPLETION_DIR_RDP
+ return 0
+}
+
+# Ping hosts from any of the above lists.
+function _ping() {
+ _generic_completion $COMPLETION_DIR_PING
+}
+
+# Hacked up make rule.
+function _make() {
+ COMPREPLY=()
+ cur=${COMP_WORDS[COMP_CWORD]}
+
+ RULES="all check clean dep depend install reinstall setup uninstall"
+
+ COMPREPLY=($(compgen -W "$RULES" -- "$cur"))
+ return 0
+}
+
+complete -F _ssh rollout
+complete -F _ssh ssh
+complete -F _ssh sshterm
+complete -F _ping telnet
+complete -F _telnet telnetterm
+complete -F _rdp rdesktop
+complete -F _ping ping
+complete -F _ping traceroute
+complete -F _ping dnsip
+complete -F _make make
+complete -F _process killall
+complete -F _pid kill
+complete -F _pid strace