]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
Add llama-cli bash completion
authorMathieu Baudier <redacted>
Fri, 30 May 2025 07:53:58 +0000 (09:53 +0200)
committerMathieu Baudier <redacted>
Fri, 30 May 2025 10:02:08 +0000 (12:02 +0200)
debian/control
debian/llama-cpp-tools.bash-completion [new file with mode: 0644]
debian/rules

index d4e1d67c377f6b6abd55cb44500ab055aa2e4968..5d6c24f3470ad4924554e977a85a903b54fbf309 100644 (file)
@@ -6,6 +6,7 @@ Build-Depends: debhelper-compat (= 13), pkgconf,
        cmake-data, cmake,
        ggml-dev,
        libcurl4-openssl-dev,
+       bash-completion, dh-sequence-bash-completion,
 Standards-Version: 4.7.0
 Vcs-Git: https://git.djapps.eu/pkg/ggml/sources/llama.cpp
 Vcs-Browser: https://git.djapps.eu/?p=pkg/ggml/sources/llama.cpp;a=summary
diff --git a/debian/llama-cpp-tools.bash-completion b/debian/llama-cpp-tools.bash-completion
new file mode 100644 (file)
index 0000000..432aa94
--- /dev/null
@@ -0,0 +1,3 @@
+completions/llama-cli
+# completions/llama-quantize does not actually use these options
+completions/llama-bench
index f60e7520eeb17b7aca043ab35187daf3f8572b03..811e1879c80a16dfb90b0f27f53205d1272cc743 100755 (executable)
@@ -39,13 +39,23 @@ override_dh_auto_configure:
 override_dh_auto_install:
        dh_auto_install
        
+       # Generate bash completion file
+       LD_LIBRARY_PATH=$(install_lib_multiarch) \
+               $(install_bin)/llama-cli --device none --completion-bash \
+               > llama-tools-completion
+       sed -i '/complete -F _llama_completions .*/d' llama-tools-completion
+
        # Move executables to libexec, so that they can load the GGML backends
        # and link them to bin
        mkdir -p $(install_libexec_multiarch)/ggml
+       mkdir -p completions
        for file in $(install_bin)/llama-*; do \
        mv $$file $(install_libexec_multiarch)/ggml/$$(basename "$$file"); \
                ln -s --relative -t $(install_bin) $(install_libexec_multiarch)/ggml/$$(basename "$$file"); \
+               cp llama-tools-completion completions/$$(basename "$$file"); \
+               echo "complete -F _llama_completions $$(basename "$$file")" >> completions/$$(basename "$$file"); \
        done
+       
 
 override_dh_auto_test:
        # tests which depends on remote location are failing