llama.cpp 配置

This commit is contained in:
2026-04-29 19:40:22 +08:00
parent 0240ff10e1
commit 7950532491
4 changed files with 77 additions and 0 deletions

View File

@@ -30,6 +30,60 @@ generate-bash-completion() {
fi
}
load-bash-completion() {
local silence=false
local -a files=()
while [[ $# -gt 0 ]]; do
case "$1" in
-s)
silence=true
shift
;;
--)
shift
files+=("$@")
break
;;
*)
files+=("$1")
shift
;;
esac
done
if [[ ${#files[@]} -eq 0 ]]; then
echo "usage: load-bash-completion [-s] <path1> [path2 ...]" >&2
echo "" >&2
echo " -s: if some completion file not exist, just skip it silently" >&2
echo "" >&2
echo "example: load-bash-completion pnpm npm" >&2
return 1
fi
local completion_dir="${HOME}/.local/share/bash-completion/completions"
for file in "${files[@]}"; do
local completion_file="$(realpath -m "${completion_dir}/${file}")"
if [[ ! -e "$completion_file" ]]; then
if [[ "$silence" == false ]]; then
echo "WARNING: cannot found completion file '${file}'" >&2
fi
continue
fi
if [[ ! -r "$completion_file" ]]; then
if [[ "$silence" == false ]]; then
echo "WARNING: cannot read completion file '$file'" >&2
fi
continue
fi
source "$completion_file"
done
}
add-to-path() {
local silence=false
local -a dirs=()

View File

@@ -0,0 +1,13 @@
basedir=$(realpath -m $(dirname "${BASH_SOURCE[0]:-$0}"))
source "${basedir}/function.bash"
unset basedir
if [[ -e "$(type -p llama-cli)" ]]; then
completion_file="llama-cpp"
generate-bash-completion "$completion_file" "llama-cli --completion-bash"
load-bash-completion -s "$completion_file"
unset completion_file
fi