# HG changeset patch
# User Raphael Pinson <[EMAIL PROTECTED]>
# Date 1216911887 -7200
# Node ID 26d9cf6f08a155818cab92eb1275a932a017d19b
# Parent  ae394e5c16338ed8622274199c4ad5900fff20b8
Add bash_completion script for augtool

diff -r ae394e5c1633 -r 26d9cf6f08a1 augeas.bash_completion
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/augeas.bash_completion    Thu Jul 24 17:04:47 2008 +0200
@@ -0,0 +1,71 @@
+# bash_completion script for augeas
+# Author: Raphael Pinson <[EMAIL PROTECTED]>
+
+
+_augtool ()
+{
+       local cur prev
+       cur="${COMP_WORDS[COMP_CWORD]}"
+       prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+       OPTS="-c -b -n -r -I"
+       CMDS="exit quit ls match rm set clear get print ins save help"
+
+
+        case $prev in 
+
+           ls|match|rm|set|clear|get|print)
+
+                 # Initialize rootdir
+                 rootdir=""
+                 # Remove $0 from the full command
+                 full_cmd="[EMAIL PROTECTED]:1}"
+                 # Reset getopts counter
+                 OPTIND=0
+                 # analyze options silently (put colon first)
+                 while getopts :c:b:n:r:I: option $full_cmd; do
+                    case $option in
+                         r)
+                               rootdir="$OPTARG"
+                               ;;
+                    esac
+                 done
+
+                case $cur in 
+                   /augeas*)
+                       files=$( find ${rootdir}/${cur##/augeas}*  -maxdepth 1 
2>/dev/null | sed -e "[EMAIL PROTECTED]@/[EMAIL PROTECTED]" | sed -re 
"s@/+@/@g" )
+                      COMPREPLY=( $( compgen -W "${files}" -- $cur ) )
+                      ;;
+                   /files*)
+                       files=$( find ${rootdir}/${cur##/files}*  -maxdepth 1 
2>/dev/null | sed -e "[EMAIL PROTECTED]@/[EMAIL PROTECTED]" | sed -re 
"s@/+@/@g" )
+                      COMPREPLY=( $( compgen -W "${files}" -- "$cur" ) )
+                      ;;
+                   *)
+                      COMPREPLY=( $( compgen -o nospace -W "/augeas /augeas/ 
/files /files/" -- $cur ) )
+                      ;;
+                esac
+                      
+             ;;
+             
+          -I|-r)
+             _filedir
+             ;;
+
+           *)
+             case $cur in
+          
+                -*)
+                   COMPREPLY=( $( compgen -W "$OPTS -" -- $cur ) )
+                ;;
+
+                *)
+                   COMPREPLY=( $( compgen -W "$CMDS -" -- $cur ) )
+                ;;
+
+             esac
+             ;;
+
+        esac
+}
+
+[ "${have:-}" ] && complete -F _augtool $filenames augtool

_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel

Reply via email to