Skip to content

Implement bash tab completion

Grant Miller requested to merge GrantM11235/pmbootstrap:argcomplete into master

If argcomplete is installed, bash tab completion will be enabled for pmbootstrap's arguments.

If argcomplete is not installed, pmbootstrap continues to work as before.

Benchmarks

My Desktop My Laptop
Age 6 years 9 years
CPU i5 3570K Turion 64 X2 Mobile
Storage SSD 5400 RPM HDD
Latency 0.12s - 0.14s 0.30s - 0.40s

I didn't notice much variation depending on what was being completed, even completing a package name didn't seem to add much if any extra time.

Methodology

--- ~/.local/share/bash-completion/completions/pmbootstrap.orig
+++ ~/.local/share/bash-completion/completions/pmbootstrap
@@ -15,7 +15,7 @@
     if compopt +o nospace 2> /dev/null; then
         SUPPRESS_SPACE=1
     fi
-    COMPREPLY=( $(IFS="$IFS" \
+    time COMPREPLY=( $(IFS="$IFS" \
                   COMP_LINE="$COMP_LINE" \
                   COMP_POINT="$COMP_POINT" \
                   COMP_TYPE="$COMP_TYPE" \

Todo

  • Actually implement package completion
  • Measure response time and compare with zsh script
  • Only suggest long options if "--" has already been typed, never suggest short options (like what git does)
Edited by Grant Miller

Merge request reports