[augeas-devel] [PATCH] Add bash_completion script for augtool
raphink at gmail.com
raphink at gmail.com
Thu Jul 24 15:04:57 UTC 2008
# HG changeset patch
# User Raphael Pinson <raphink at gmail.com>
# 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 <raphink at gmail.com>
+
+
+_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="${COMP_WORDS[@]: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 "s@^${rootdir}@/augeas at g" | sed -re "s@/+@/@g" )
+ COMPREPLY=( $( compgen -W "${files}" -- $cur ) )
+ ;;
+ /files*)
+ files=$( find ${rootdir}/${cur##/files}* -maxdepth 1 2>/dev/null | sed -e "s@^${rootdir}@/files at g" | 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
More information about the augeas-devel
mailing list