diff options
author | orchidman <lesibel@free.fr> | 2012-03-01 19:09:15 +0100 |
---|---|---|
committer | orchidman <lesibel@free.fr> | 2012-03-01 19:09:15 +0100 |
commit | ab5145143c9a6ca1c5d9888339eb9df742edec3a (patch) | |
tree | e7132e9e2296a8e5c728e76ebc8d397c4270e34d /boinc-nox/boinc.bash | |
parent | 3898a94c2a7401e1fd0e035585e38b81383ab7a8 (diff) | |
download | nutyx-extra-ab5145143c9a6ca1c5d9888339eb9df742edec3a.tar.gz nutyx-extra-ab5145143c9a6ca1c5d9888339eb9df742edec3a.tar.bz2 nutyx-extra-ab5145143c9a6ca1c5d9888339eb9df742edec3a.tar.xz nutyx-extra-ab5145143c9a6ca1c5d9888339eb9df742edec3a.zip |
boinc-nox 6.12.34-1 nx port
Diffstat (limited to 'boinc-nox/boinc.bash')
-rw-r--r-- | boinc-nox/boinc.bash | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/boinc-nox/boinc.bash b/boinc-nox/boinc.bash new file mode 100644 index 000000000..34daa3b97 --- /dev/null +++ b/boinc-nox/boinc.bash @@ -0,0 +1,99 @@ +# Source this file in BASH to get command completion (using tab) for +# boinc and boinccmd. Written by Frank S. Thomas <fst@debian.org>. +# See also: http://boinc.berkeley.edu/trac/wiki/BashCommandCompletion + +_boinc() +{ + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + opts="$(boinc_client --help | \ + sed -n -r 's/^[[:space:]]*(--[a-z_]*).*/\1/p')" + + # Handle options that require one or more arguments. + case "$prev" in + --attach_project|--detach_project|--reset_project|--update_prefs|\ + --gui_rpc_port) + return 0 + ;; + esac + + # Handle options that require two arguments. + if [[ COMP_CWORD -gt 1 ]]; then + pprev="${COMP_WORDS[COMP_CWORD-2]}" + + case "$pprev" in + --attach_project) + return 0 + ;; + esac + fi + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) + return 0 + fi +} +complete -F _boinc -o default boinc_client + +_boinccmd() +{ + local cur prev opts cmds + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + opts="--host --passwd -h --help -V --version" + cmds="$(boinc_cmd --help 2>&1 | \ + sed -n -r 's/^[[:space:]]*(--[a-z_]*).*/\1/p')" + + # The following construct assures that: + # - no command follows if one of $opts or $cmds was given + # - after --host follows only one command or --passwd and one command + # - after --passwd follows only one command + if [[ $COMP_CWORD -eq 1 ]]; then + COMPREPLY=( $(compgen -W "$opts $cmds" -- "$cur") ) + return 0 + else + if [[ "${COMP_WORDS[@]}" =~ ".* --host .* --passwd .*" ]]; then + if [[ $COMP_CWORD -eq 5 ]]; then + COMPREPLY=( $(compgen -W "$cmds" -- "$cur") ) + fi + elif [[ "${COMP_WORDS[@]}" =~ ".* --passwd .*" ]]; then + if [[ $COMP_CWORD -eq 3 ]]; then + COMPREPLY=( $(compgen -W "$cmds" -- "$cur") ) + fi + elif [[ "${COMP_WORDS[@]}" =~ ".* --host .*" ]]; then + if [[ $COMP_CWORD -eq 3 ]]; then + COMPREPLY=( $(compgen -W "--passwd $cmds" -- "$cur") ) + fi + fi + fi + + # Handle options/commands that require one or more arguments. + case "$prev" in + --get_messages|--passwd) + return 0 + ;; + + --host) + _known_hosts + return 0 + ;; + + --set_run_mode|--set_network_mode) + COMPREPLY=( $(compgen -W "always auto never" -- "$cur") ) + return 0 + ;; + + --set_screensaver_mode) + COMPREPLY=( $(compgen -W "on off" -- "$cur") ) + return 0 + ;; + esac +} +complete -F _boinccmd boinc_cmd + +# vim: syntax=sh |