aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/sudoedit.bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash/bashrc.d/sudoedit.bash')
-rw-r--r--bash/bashrc.d/sudoedit.bash21
1 files changed, 21 insertions, 0 deletions
diff --git a/bash/bashrc.d/sudoedit.bash b/bash/bashrc.d/sudoedit.bash
new file mode 100644
index 00000000..a13f484e
--- /dev/null
+++ b/bash/bashrc.d/sudoedit.bash
@@ -0,0 +1,21 @@
+# Some imperfect but mostly-useful sudoedit(8) completion
+_sudoedit() {
+ word=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ # Completion for this word depends on the previous word
+ case $prev in
+
+ # If the previous word was an option for -g, complete with group names
+ -*g)
+ COMPREPLY=( $(compgen -A group -- "$word") )
+ ;;
+
+ # If the previous word was an option for -u, complete with user names
+ -*u)
+ COMPREPLY=( $(compgen -A user -- "$word") )
+ ;;
+ esac
+}
+complete -F _sudoedit -o default sudoedit
+