Changes between Version 5 and Version 6 of BashCommandCompletion
- Timestamp:
- Apr 30, 2008, 1:04:57 AM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
BashCommandCompletion
v5 v6 1 = Command completion for boinc _client and boinc_cmd =1 = Command completion for boinc and boinccmd = 2 2 3 The bash shell has a useful facility to complete commands when you press [TAB]. There is a script which goes a bit further and lets bash complete [UnixClient boinc_client's] and [BoincCmd boinc_cmd's] commands and options.3 The bash shell has a useful facility to complete commands when you press `[TAB]`. There is a script which goes a bit further and lets bash complete [UnixClient boinc's] and [BoincCmd boinccmd's] commands and options. 4 4 5 For example if you type ''' boinc_cmd --get_[TAB]''' it gives you all commands which begin with --get_:5 For example if you type '''`boinccmd --get_[TAB]`''' it gives you all commands which begin with `--get_`: 6 6 {{{ 7 ~$ boinccmd --get_ 7 8 --get_cc_status --get_project_status 8 9 --get_disk_usage --get_proxy_settings … … 13 14 --get_project_config_poll 14 15 }}} 15 If you now press 'p'the selection is reduced to:16 If you now press `p` and then `[TAB]` again the selection is reduced to: 16 17 {{{ 18 ~$ boinccmd --get_pro 17 19 --get_project_config --get_project_status 18 20 --get_project_config_poll --get_proxy_settings 19 21 }}} 20 and so on. The script also completes host names after the --hostoption.22 and so on. The script also completes host names after the `--host` option. 21 23 22 To use this command completion, save the following script on a file and source it in bash.24 To use this command completion, save the following script on a file (e.g. `boinc.bash`) and source it in bash: 23 25 {{{ 24 #!comment 25 instructions are needed on what exactly users are supposed to do to use the script, ie what "source it in bash" means. 26 ~$ source boinc.bash 26 27 }}} 28 27 29 ---- 30 28 31 {{{ 29 32 #!bash 30 33 # Source this file in bash to get command completion (using tab) 31 # for boinc _client and boinc_cmd34 # for boinc and boinccmd 32 35 # Written by Frank S. Thomas 33 36 34 _boinc _client()37 _boinc() 35 38 { 36 39 local cur prev opts … … 39 42 prev="${COMP_WORDS[COMP_CWORD-1]}" 40 43 41 opts="$(boinc _client--help | \44 opts="$(boinc --help | \ 42 45 sed -n -r 's/^[[:space:]]*(--[a-z_]*).*/\1/p')" 43 46 … … 66 69 fi 67 70 } 68 complete -F _boinc _client -o default boinc_client71 complete -F _boinc -o default boinc 69 72 70 _boinc _cmd()73 _boinccmd() 71 74 { 72 75 local cur prev opts cmds … … 76 79 77 80 opts="--host --passwd -h --help -V --version" 78 cmds="$(boinc _cmd --help 2>&1 | \81 cmds="$(boinccmd --help 2>&1 | \ 79 82 sed -n -r 's/^[[:space:]]*(--[a-z_]*).*/\1/p')" 80 83 … … 124 127 esac 125 128 } 126 complete -F _boinc _cmd boinc_cmd129 complete -F _boinccmd boinccmd 127 130 # vim: syntax=sh 128 131 }}}