aboutsummaryrefslogtreecommitdiff
path: root/bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-02-13 00:45:59 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-02-13 00:45:59 +1300
commite58c2922c37f346c372d524f354cc8a0b124745b (patch)
tree735056d7cb7ddb6c64cf210a6c450376dd5d31ec /bash
parentUse backslash to escape single char (diff)
downloaddotfiles-e58c2922c37f346c372d524f354cc8a0b124745b.tar.gz
dotfiles-e58c2922c37f346c372d524f354cc8a0b124745b.zip
Add chgrp(1) completion
Diffstat (limited to 'bash')
-rw-r--r--bash/bash_completion.d/chgrp.bash20
1 files changed, 20 insertions, 0 deletions
diff --git a/bash/bash_completion.d/chgrp.bash b/bash/bash_completion.d/chgrp.bash
new file mode 100644
index 00000000..d047f97f
--- /dev/null
+++ b/bash/bash_completion.d/chgrp.bash
@@ -0,0 +1,20 @@
+# Complete group names for first non-option chgrp(1) argument
+_chgrp() {
+ local i
+ for ((i = 1; i < COMP_CWORD; i++)) ; do
+ case ${COMP_WORDS[i]} in
+ -*) ;;
+ *) return 1 ;;
+ esac
+ done
+ while read -r group ; do
+ COMPREPLY[${#COMPREPLY[@]}]=$group
+ done < <(compgen -A group -- "${COMP_WORDS[COMP_CWORD]}")
+}
+
+# bashdefault requires Bash >=3.0
+if ((BASH_VERSINFO[0] >= 3)) ; then
+ complete -F _chgrp -o bashdefault -o default chgrp
+else
+ complete -F _chgrp -o default chgrp
+fi