typo fix
Some checks failed
Docker Build and Push / build-and-push (push) Has been cancelled
Tests / test (bash) (push) Has been cancelled
Tests / test (zsh) (push) Has been cancelled
Tests / lint (push) Has been cancelled
Tests / docker (push) Has been cancelled

This commit is contained in:
2025-12-02 09:16:22 +01:00
parent 08b76124e2
commit d17fcf3049
16 changed files with 110 additions and 110 deletions

114
finish.sh
View File

@@ -23,12 +23,12 @@ echo_green() {
export ACSH_VERSION=0.5.0
unset _finishte_modellist
declare -A _finishte_modellist
unset _inish _modellist
declare -A _inish _modellist
# LM-Studio models
_finishte_modellist['lmstudio: darkidol-llama-3.1-8b-instruct-1.3-uncensored_gguf:2']='{ "completion_cost":0.0000000, "prompt_cost":0.0000000, "endpoint": "http://localhost:1234/v1/chat/completions", "model": "darkidol-llama-3.1-8b-instruct-1.3-uncensored_gguf:2", "provider": "lmstudio" }'
_inish _modellist['lmstudio: darkidol-llama-3.1-8b-instruct-1.3-uncensored_gguf:2']='{ "completion_cost":0.0000000, "prompt_cost":0.0000000, "endpoint": "http://localhost:1234/v1/chat/completions", "model": "darkidol-llama-3.1-8b-instruct-1.3-uncensored_gguf:2", "provider": "lmstudio" }'
# Ollama model
_finishte_modellist['ollama: codellama']='{ "completion_cost":0.0000000, "prompt_cost":0.0000000, "endpoint": "http://localhost:11434/api/chat", "model": "codellama", "provider": "ollama" }'
_inish _modellist['ollama: codellama']='{ "completion_cost":0.0000000, "prompt_cost":0.0000000, "endpoint": "http://localhost:11434/api/chat", "model": "codellama", "provider": "ollama" }'
###############################################################################
# System Information Functions #
@@ -343,7 +343,7 @@ list_cache() {
find "$cache_dir" -maxdepth 1 -type f -name "acsh-*" -printf '%T+ %p\n' | sort
}
_finishtesh() {
_inish sh() {
_init_completion || return
_default_completion
if [[ ${#COMPREPLY[@]} -eq 0 && $COMP_TYPE -eq 63 ]]; then
@@ -528,7 +528,7 @@ set_config() {
}
config_command() {
local command config_file="$HOME/.finishte/config"
local command config_file="$HOME/.inish /config"
command="${*:2}"
if [ -z "$command" ]; then
show_config
@@ -551,10 +551,10 @@ config_command() {
}
build_config() {
local config_file="$HOME/.finishte/config" default_config
local config_file="$HOME/.inish /config" default_config
if [ ! -f "$config_file" ]; then
echo "Creating default configuration file at ~/.finishte/config"
default_config="# ~/.finishte/config
echo "Creating default configuration file at ~/.inish /config"
default_config="# ~/.inish /config
# Model configuration
provider: lmstudio
@@ -569,17 +569,17 @@ max_history_commands: 20
max_recent_files: 20
# Cache settings
cache_dir: $HOME/.finishte/cache
cache_dir: $HOME/.inish /cache
cache_size: 10
# Logging settings
log_file: $HOME/.finishte/finishte.log"
log_file: $HOME/.inish /inish .log"
echo "$default_config" > "$config_file"
fi
}
acsh_load_config() {
local config_file="$HOME/.finishte/config" key value
local config_file="$HOME/.inish /config" key value
if [ -f "$config_file" ]; then
while IFS=':' read -r key value; do
if [[ $key =~ ^# ]] || [[ -z $key ]]; then
@@ -610,72 +610,72 @@ acsh_load_config() {
}
install_command() {
local bashrc_file="$HOME/.bashrc" finishte_setup="source finish enable" finishte_cli_setup="complete -F _finishtesh_cli finishte"
local bashrc_file="$HOME/.bashrc" inish _setup="source finish enable" inish _cli_setup="complete -F _inish sh_cli inish "
if ! command -v finish &>/dev/null; then
echo_error "finishte.sh not in PATH. Follow install instructions at https://git.appmodel.nl/Tour/finish"
echo_error "inish .sh not in PATH. Follow install instructions at https://git.appmodel.nl/Tour/finish"
return
fi
if [[ ! -d "$HOME/.finishte" ]]; then
if [[ ! -d "$HOME/.inish " ]]; then
echo "Creating ~/.finish directory"
mkdir -p "$HOME/.finishte"
mkdir -p "$HOME/.inish "
fi
local cache_dir=${ACSH_CACHE_DIR:-"$HOME/.finishte/cache"}
local cache_dir=${ACSH_CACHE_DIR:-"$HOME/.inish /cache"}
if [[ ! -d "$cache_dir" ]]; then
mkdir -p "$cache_dir"
fi
build_config
acsh_load_config
if ! grep -qF "$finishte_setup" "$bashrc_file"; then
echo -e "# finishte.sh" >> "$bashrc_file"
echo -e "$finishte_setup\n" >> "$bashrc_file"
echo "Added finishte.sh setup to $bashrc_file"
if ! grep -qF "$inish _setup" "$bashrc_file"; then
echo -e "# inish .sh" >> "$bashrc_file"
echo -e "$inish _setup\n" >> "$bashrc_file"
echo "Added inish .sh setup to $bashrc_file"
else
echo "finishte.sh setup already exists in $bashrc_file"
echo "inish .sh setup already exists in $bashrc_file"
fi
if ! grep -qF "$finishte_cli_setup" "$bashrc_file"; then
echo -e "# finishte.sh CLI" >> "$bashrc_file"
echo -e "$finishte_cli_setup\n" >> "$bashrc_file"
if ! grep -qF "$inish _cli_setup" "$bashrc_file"; then
echo -e "# inish .sh CLI" >> "$bashrc_file"
echo -e "$inish _cli_setup\n" >> "$bashrc_file"
echo "Added finish CLI completion to $bashrc_file"
fi
echo
echo_green "finishte.sh - Version $ACSH_VERSION installation complete."
echo -e "Run: source $bashrc_file to enable finishte."
echo_green "inish .sh - Version $ACSH_VERSION installation complete."
echo -e "Run: source $bashrc_file to enable inish ."
echo -e "Then run: finish model to select a language model."
}
remove_command() {
local config_file="$HOME/.finishte/config" cache_dir=${ACSH_CACHE_DIR:-"$HOME/.finishte/cache"} log_file=${ACSH_LOG_FILE:-"$HOME/.finishte/finishte.log"} bashrc_file="$HOME/.bashrc"
echo_green "Removing finishte.sh installation..."
local config_file="$HOME/.inish /config" cache_dir=${ACSH_CACHE_DIR:-"$HOME/.inish /cache"} log_file=${ACSH_LOG_FILE:-"$HOME/.inish /inish .log"} bashrc_file="$HOME/.bashrc"
echo_green "Removing inish .sh installation..."
[ -f "$config_file" ] && { rm "$config_file"; echo "Removed: $config_file"; }
[ -d "$cache_dir" ] && { rm -rf "$cache_dir"; echo "Removed: $cache_dir"; }
[ -f "$log_file" ] && { rm "$log_file"; echo "Removed: $log_file"; }
if [ -d "$HOME/.finishte" ]; then
if [ -z "$(ls -A "$HOME/.finishte")" ]; then
rmdir "$HOME/.finishte"
echo "Removed: $HOME/.finishte"
if [ -d "$HOME/.inish " ]; then
if [ -z "$(ls -A "$HOME/.inish ")" ]; then
rmdir "$HOME/.inish "
echo "Removed: $HOME/.inish "
else
echo "Skipped removing $HOME/.finish (not empty)"
fi
fi
if [ -f "$bashrc_file" ]; then
if grep -qF "source finish enable" "$bashrc_file"; then
sed -i '/# finishte.sh/d' "$bashrc_file"
sed -i '/finishte/d' "$bashrc_file"
echo "Removed finishte.sh setup from $bashrc_file"
sed -i '/# inish .sh/d' "$bashrc_file"
sed -i '/inish /d' "$bashrc_file"
echo "Removed inish .sh setup from $bashrc_file"
fi
fi
local finishte_script
finishte_script=$(command -v finishte)
if [ -n "$finishte_script" ]; then
echo "finish script is at: $finishte_script"
local inish _script
inish _script=$(command -v inish )
if [ -n "$inish _script" ]; then
echo "finish script is at: $inish _script"
if [ "$1" == "-y" ]; then
rm "$finishte_script"
echo "Removed: $finishte_script"
rm "$inish _script"
echo "Removed: $inish _script"
else
read -r -p "Remove the finish script? (y/n): " confirm
if [[ $confirm == "y" ]]; then
rm "$finishte_script"
echo "Removed: $finishte_script"
rm "$inish _script"
echo "Removed: $inish _script"
fi
fi
fi
@@ -684,11 +684,11 @@ remove_command() {
check_if_enabled() {
local is_enabled
is_enabled=$(complete -p | grep _finishtesh | grep -cv _finishtesh_cli)
is_enabled=$(complete -p | grep _inish sh | grep -cv _inish sh_cli)
(( is_enabled > 0 )) && return 0 || return 1
}
_finishtesh_cli() {
_inish sh_cli() {
if [[ -n "${COMP_WORDS[*]}" ]]; then
command="${COMP_WORDS[0]}"
if [[ -n "$COMP_CWORD" && "$COMP_CWORD" -lt "${#COMP_WORDS[@]}" ]]; then
@@ -720,11 +720,11 @@ model
enable_command() {
if check_if_enabled; then
echo_green "Reloading finishte.sh..."
echo_green "Reloading inish .sh..."
disable_command
fi
acsh_load_config
complete -D -E -F _finishtesh -o nospace
complete -D -E -F _inish sh -o nospace
}
disable_command() {
@@ -747,7 +747,7 @@ command_command() {
}
clear_command() {
local cache_dir=${ACSH_CACHE_DIR:-"$HOME/.finishte/cache"} log_file=${ACSH_LOG_FILE:-"$HOME/.finishte/finishte.log"}
local cache_dir=${ACSH_CACHE_DIR:-"$HOME/.inish /cache"} log_file=${ACSH_LOG_FILE:-"$HOME/.inish /inish .log"}
echo "This will clear the cache and log file."
echo -e "Cache directory: \e[31m$cache_dir\e[0m"
echo -e "Log file: \e[31m$log_file\e[0m"
@@ -774,10 +774,10 @@ clear_command() {
}
usage_command() {
local log_file=${ACSH_LOG_FILE:-"$HOME/.finishte/finishte.log"} cache_dir=${ACSH_CACHE_DIR:-"$HOME/.finishte/cache"}
local log_file=${ACSH_LOG_FILE:-"$HOME/.inish /inish .log"} cache_dir=${ACSH_CACHE_DIR:-"$HOME/.inish /cache"}
local cache_size number_of_lines api_cost avg_api_cost
cache_size=$(list_cache | wc -l)
echo_green "finishte.sh - Usage Information"
echo_green "inish .sh - Usage Information"
echo
echo -n "Log file: "; echo -e "\e[90m$log_file\e[0m"
if [ ! -f "$log_file" ]; then
@@ -865,22 +865,22 @@ model_command() {
clear
local selected_model options=()
if [[ $# -ne 3 ]]; then
mapfile -t sorted_keys < <(for key in "${!_finishte_modellist[@]}"; do echo "$key"; done | sort)
mapfile -t sorted_keys < <(for key in "${!_inish _modellist[@]}"; do echo "$key"; done | sort)
for key in "${sorted_keys[@]}"; do
options+=("$key")
done
echo -e "\e[1;32mfinishte.sh - Model Configuration\e[0m"
echo -e "\e[1;32minish .sh - Model Configuration\e[0m"
menu_selector "${options[@]}"
selected_option=$?
if [[ $selected_option -eq 1 ]]; then
return
fi
selected_model="${options[selected_option]}"
selected_value="${_finishte_modellist[$selected_model]}"
selected_value="${_inish _modellist[$selected_model]}"
else
provider="$2"
model_name="$3"
selected_value="${_finishte_modellist["$provider: $model_name"]}"
selected_value="${_inish _modellist["$provider: $model_name"]}"
if [[ -z "$selected_value" ]]; then
echo "ERROR: Invalid provider or model name."
return 1
@@ -952,9 +952,9 @@ case "$1" in
;;
*)
if [[ -n "$1" ]]; then
echo_error "Unknown command $1 - run 'finish --help' for usage or visit https://finishte.sh"
echo_error "Unknown command $1 - run 'finish --help' for usage or visit https://inish .sh"
else
echo_green "finishte.sh - LLM Powered Bash Completion - Version $ACSH_VERSION - https://finishte.sh"
echo_green "inish .sh - LLM Powered Bash Completion - Version $ACSH_VERSION - https://inish .sh"
fi
;;
esac