aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--mkhint.bash-completion16
2 files changed, 16 insertions, 2 deletions
diff --git a/README.md b/README.md
index 4ffdbca..e2fb4a3 100644
--- a/README.md
+++ b/README.md
@@ -142,4 +142,4 @@ mkhint -h
- Hint files are backed up to `.bak` before any modification.
- If DOWNLOAD or DOWNLOAD_x86_64 is `UNSUPPORTED` or `UNTESTED`, that URL is skipped and its MD5SUM is left unchanged.
- `--no-dl` / `-N` does **not** skip downloads — it downloads and recalculates checksums as normal, then appends `NODOWNLOAD=yes` to the hint file.
-- Bash completion for `-f`/`--hintfile`, `-n`/`--new`, and `-d`/`--delete` autocompletes package names from their respective directories. Short flags (`-v`, `-f`, `-n`, `-l`, `-c`, `-d`, `-N`, `-h`) are also completed.
+- Bash completion for `-f`/`--hintfile`, `-n`/`--new`, and `-d`/`--delete` autocompletes package names from their respective directories. When `-f <package>` is already on the command line, `-v [TAB]` suggests the current `VERSION` from that package's hint file. If the hint file is absent, no version is suggested. Short flags (`-v`, `-f`, `-n`, `-l`, `-c`, `-d`, `-N`, `-h`) are also completed.
diff --git a/mkhint.bash-completion b/mkhint.bash-completion
index 29e2523..dee57e7 100644
--- a/mkhint.bash-completion
+++ b/mkhint.bash-completion
@@ -26,7 +26,21 @@ _mkhintfile_completions() {
COMPREPLY=($(compgen -W "${words[*]}" -- "$cur"))
;;
--version|-v)
- # no completion, raw text
+ local pkg="" i
+ for (( i=1; i<${#COMP_WORDS[@]}-1; i++ )); do
+ if [[ "${COMP_WORDS[i]}" == "--hintfile" || "${COMP_WORDS[i]}" == "-f" ]]; then
+ pkg="${COMP_WORDS[i+1]}"
+ break
+ fi
+ done
+ if [[ -n "$pkg" ]]; then
+ local hint_file="$hint_dir/${pkg}.hint"
+ if [[ -f "$hint_file" ]]; then
+ local ver
+ ver=$(grep -m1 '^VERSION=' "$hint_file" | cut -d= -f2 | tr -d '"')
+ [[ -n "$ver" ]] && COMPREPLY=($(compgen -W "$ver" -- "$cur"))
+ fi
+ fi
;;
*)
COMPREPLY=($(compgen -W "$all_flags" -- "$cur"))