Changeset 87
- Timestamp:
- 04/18/2006 22:10:47 (6 years ago)
- File:
-
- 1 edited
-
confman/bash_completions (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
confman/bash_completions
r86 r87 1 1 #!/bin/bash 2 2 # 3 # TODO3 # TODO 4 4 # 5 # More intelligently complete absolute paths in file/dir names 6 # e.g. et_TAB completes to etc_ rather than etc _ 7 # 5 # Can't think of any. -yontege 8 6 _confman() 9 7 { 10 8 local cur prev cmds twoback cmds fd_cmds mod_cmds chkpt_cmds 9 10 # Setup ConfMan specific vars 11 11 CONFMAN="/usr/local/rescomp/sbin/confman" 12 12 CONFMAN_CONF="/usr/local/rescomp/etc/confman.conf" … … 17 17 RECIPE_PATH=$(grep '^RECIPE_PATH' ${CONFMAN_RC}|cut -d'"' -f2) 18 18 fi 19 20 # Setup Standard command completion vars 19 21 COMPREPLY=() 20 22 cur="${COMP_WORDS[COMP_CWORD]}" … … 28 30 [ ! -x $CONFMAN ] && echo "confman support not available!!" && exit 1 29 31 32 # These vars are to better organize things to complete to as well as 33 # provide loose documention about what this does. 30 34 # 31 35 # fd_cmds: commands that take files and directories as args … … 38 42 fd_cmds="rm cp mv mkdir ls chown chgrp chmod chcom log install revert" 39 43 mod_cmds="create rmmod import checklook checknew checkclear rollback" 40 chkpt_cmds="checklook checknew checkclear rollback" 41 cmds="help setup update commit diff status $fd_cmds $mod_cmds" 44 # 'rollback' is also a chkpt_cmd, but needs to be handled separately 45 # because it's the only one that handles dated checkpoints. 46 chkpt_cmds="checklook checknew checkclear" 47 cmds="help setup update commit diff status rollback $fd_cmds $mod_cmds" 42 48 43 49 if [ "${prev}" == "confman" -o "${prev}" == "help" ] ; then … … 59 65 COMPREPLY=($(compgen -W "${checkpoints}" -- ${cur})) 60 66 return 0 61 elif [ `expr "rollback" : ".*\(${threeback}\).*"` ] ; then 67 elif [ "rollback" == "${twoback}" ] ; then 68 local module=${prev} 69 local named_checkpoints=$(confman checklook ${module}|\ 70 tr '\n' ' ') 71 local numbered_checkpoints=$(confman log |grep '^r[0-9][0-9]*' |\ 72 sed 's/.*\(20[0-9][0-9]\)-\([0-9][0-9]\)-\([0-9][0-9]\).*/"\1\2\3"/'|\ 73 tr '\n' ' ') 74 checkpoints="${named_checkpoints} ${numbered_checkpoints}" 75 COMPREPLY=($(compgen -W "${checkpoints}" -- ${cur})) 76 return 0 77 elif [ "rollback" == "${threeback}" ] ; then 62 78 local day=${prev:0:4}-${prev:4:2}-${prev:6:2} 63 79 local hoursmins=$(confman log |grep '^r[0-9][0-9]*' |\ … … 67 83 COMPREPLY=($(compgen -W "${hoursmins}" -- ${cur})) 68 84 return 0 69 elif [ `expr "rollback" : ".*\(${twoback}\).*"` ] ; then70 local module=${prev}71 local checkpoints=$(confman checklook ${module}|tr '\n' ' ')72 local num_checkpoints=$(confman log |grep '^r[0-9][0-9]*' |\73 sed 's/.*\(20[0-9][0-9]\)-\([0-9][0-9]\)-\([0-9][0-9]\).*/"\1\2\3"/'|\74 tr '\n' ' ')75 checkpoints="${checkpoints} ${num_checkpoints}"76 COMPREPLY=($(compgen -W "${checkpoints}" -- ${cur}))77 return 078 85 fi 79 86 80 87 return 0 81 88 } 89 90 # It's necessary to not define a catch-all completion above so that we 91 # can use the '-o filenames' switch to best handle {file,dir}name 92 # completions. 82 93 complete -F _confman -o filenames confman
Note: See TracChangeset
for help on using the changeset viewer.
