update dotfiles

This commit is contained in:
2026-05-29 02:51:42 +03:00
parent 200ff2d852
commit 1de712a83b
20 changed files with 1120 additions and 115 deletions
@@ -0,0 +1,273 @@
##
## Supported major.minor versions of Python.
## Unit tests are run in CI against these versions.
##
set -g _fish_ai_supported_versions 3.10 3.11 3.12 3.13 3.14
set -g _fish_ai_install_dir (test -z "$XDG_DATA_HOME"; and echo "$HOME/.local/share/fish-ai"; or echo "$XDG_DATA_HOME/fish-ai")
set -g _fish_ai_config_path (test -z "$XDG_CONFIG_HOME"; and echo "$HOME/.config/fish-ai.ini"; or echo "$XDG_CONFIG_HOME/fish-ai.ini")
##
## This section creates the keybindings for fish-ai. Modify your `fish-ai.ini`
## and restart the terminal emulator to change the keybindings from their defaults.
##
function _fish_ai_bind --description "Create keybindings for fish-ai."
if test -n ("$_fish_ai_install_dir/bin/lookup_setting" keymap_1)
"$_fish_ai_install_dir/bin/lookup_setting" keymap_1 | string unescape | read -g -a _fish_ai_keymap_1
else
# prefer fish key names above fish 4.x
if string match -r '^[0-3]\.' "$FISH_VERSION" &>/dev/null
set -g _fish_ai_keymap_1 \cp
else
set -g _fish_ai_keymap_1 ctrl-p
end
end
if test -n ("$_fish_ai_install_dir/bin/lookup_setting" keymap_2)
"$_fish_ai_install_dir/bin/lookup_setting" keymap_2 | string unescape | read -g -a _fish_ai_keymap_2
else
# prefer fish key names above fish 4.x
if string match -r '^[0-3]\.' "$FISH_VERSION" &>/dev/null
set -g _fish_ai_keymap_2 -k nul
else
set -g _fish_ai_keymap_2 ctrl-space
end
end
if test "$fish_key_bindings" = fish_vi_key_bindings
set -g _fish_ai_bind_command bind -M insert
else
set -g _fish_ai_bind_command bind
end
bind -M insert $_fish_ai_keymap_1 _fish_ai_codify_or_explain
bind $_fish_ai_keymap_1 _fish_ai_codify_or_explain
bind -M insert $_fish_ai_keymap_2 _fish_ai_autocomplete_or_fix
bind $_fish_ai_keymap_2 _fish_ai_autocomplete_or_fix
end
if status is-interactive && test -d "$_fish_ai_install_dir"
_fish_ai_bind
end
##
## This section contains the plugin lifecycle hooks invoked by the fisher package
## manager.
##
function _fish_ai_install --on-event fish_ai_install
_fish_ai_set_python_version
if type -q uv
echo "🥡 Setting up a virtual environment using uv..."
uv venv --quiet --seed --python $_fish_ai_python_version "$_fish_ai_install_dir"
else
echo "🥡 Setting up a virtual environment using venv..."
python$_fish_ai_python_version -m venv "$_fish_ai_install_dir"
end
if test $status -ne 0
echo "💔 Installation failed. Check previous terminal output for details."
return 1
end
echo "🍬 Installing dependencies. This may take a few seconds..."
"$_fish_ai_install_dir/bin/pip" -qq install "$(_fish_ai_get_installation_url)"
if test $status -ne 0
echo "💔 Installation from '$(_fish_ai_get_installation_url)' failed. Check previous terminal output for details."
return 2
end
_fish_ai_python_version_check
_fish_ai_symlink_truststore
_fish_ai_autoconfig_gh_models
_fish_ai_bind
if ! test -f "$_fish_ai_config_path"
echo "🤗 You must create a configuration file before the plugin can be used!"
end
end
function _fish_ai_update --on-event fish_ai_update
# Upgrade to fish-ai 1.9.0
if test -d "$HOME/.fish-ai"
echo "👷 Moving installation directory to '$_fish_ai_install_dir'."
mv "$HOME/.fish-ai" "$_fish_ai_install_dir"
end
if test -f "$HOME/.config/fish-ai.ini"
if test "$_fish_ai_config_path" != "$HOME/.config/fish-ai.ini"
echo "👷 Moving configuration file to '$_fish_ai_config_path'."
mv "$HOME/.config/fish-ai.ini" "$_fish_ai_config_path"
end
end
# Upgrade to fish-ai 2.0.0
set -l provider ("$_fish_ai_install_dir/bin/lookup_setting" provider)
if test "$provider" = huggingface
echo "🌇 The provider for Hugging Face has been removed. Switch to a different provider."
end
# Upgrade to fish-ai 2.3.0
if test -n "$FISH_AI_KEYMAP_1"
echo "👷 Migrating custom keybinding FISH_AI_KEYMAP_1 to '$_fish_ai_config_path'."
"$_fish_ai_install_dir/bin/put_setting" fish-ai keymap_1 (echo -n "$FISH_AI_KEYMAP_1" | string escape)
set -e -Ug FISH_AI_KEYMAP_1
end
if test -n "$FISH_AI_KEYMAP_2"
echo "👷 Migrating custom keybinding FISH_AI_KEYMAP_2 to '$_fish_ai_config_path'."
"$_fish_ai_install_dir/bin/put_setting" fish-ai keymap_2 (echo -n "$FISH_AI_KEYMAP_2" | string escape)
set -e -Ug FISH_AI_KEYMAP_2
end
# Upgrade to fish-ai 2.8.0
if test -f "$_fish_ai_config_path"
if grep -q '^temperature\s*=' "$_fish_ai_config_path"
sed -i '/^temperature\s*=/d' "$_fish_ai_config_path"
echo "🌇 The 'temperature' parameter is no longer supported and has been removed from your configuration."
end
end
# Upgrade to fish-ai 2.10.6
if test "$provider" = cohere
set -l model ("$_fish_ai_install_dir/bin/lookup_setting" model)
if test -z "$model"
echo "👋 Please specify the Cohere model you want to use in '$_fish_ai_config_path'."
end
end
# Upgrade to fish-ai 2.13.0
if grep -qE 'provider\s*=\s*"?mistral"?' "$_fish_ai_config_path"
echo "🍿 Migrating the Mistral AI provider to OpenAI SDK."
sed -i -E 's|^provider\s*=\s*"?mistral"?|provider = self-hosted\nserver = https://api.mistral.ai/v1|g' "$_fish_ai_config_path"
end
_fish_ai_set_python_version
if type -q uv
uv venv --quiet --clear --seed --python $_fish_ai_python_version "$_fish_ai_install_dir"
else
python$_fish_ai_python_version -m venv --upgrade "$_fish_ai_install_dir"
end
if test $status -ne 0
echo "💔 Installation failed. Check previous terminal output for details."
return 1
end
echo "🐍 Now using $($_fish_ai_install_dir/bin/python3 --version)."
echo "🍬 Upgrading dependencies. This may take a few seconds..."
$_fish_ai_install_dir/bin/pip install -qq --upgrade "$(_fish_ai_get_installation_url)"
if test $status -ne 0
echo "💔 Installation failed. Check previous terminal output for details."
return 2
end
_fish_ai_python_version_check
_fish_ai_symlink_truststore
_fish_ai_warn_plaintext_api_keys
end
function _fish_ai_uninstall --on-event fish_ai_uninstall
if test -d "$_fish_ai_install_dir"
echo "💣 Nuking the virtual environment..."
rm -r "$_fish_ai_install_dir"
end
end
function _fish_ai_set_python_version
if test -n "$FISH_AI_PYTHON_VERSION"
echo "🐍 Using Python $FISH_AI_PYTHON_VERSION as specified by the environment variable 'FISH_AI_PYTHON_VERSION'."
set -g _fish_ai_python_version $FISH_AI_PYTHON_VERSION
else if type -q uv
# Use the last supported version of Python
set -g _fish_ai_python_version $_fish_ai_supported_versions[-1]
else
# Use the Python version provided by the system
set -g _fish_ai_python_version 3
end
end
function _fish_ai_get_installation_url
set -f plugin (fisher list "fish-ai")
if test "$plugin" = ""
# fish-ai may be installed from an unknown source, assume
# that the Python packages can be installed from the
# current working directory.
echo -n (pwd)
else if test (string sub --start 1 --length 1 "$plugin") = /
# Install from a local folder (most likely a git clone)
echo -n "$plugin"
else
# Install from GitHub
echo -n "fish-ai@git+https://github.com/$plugin"
end
end
function _fish_ai_python_version_check
set -f current_python_version ("$_fish_ai_install_dir/bin/python3" -c 'import platform; major, minor, _ = platform.python_version_tuple(); print(major, end="."); print(minor, end="")')
if ! contains $current_python_version $_fish_ai_supported_versions
echo "🔔 This plugin has not been tested with Python $_fish_ai_python_version and may not function correctly."
echo "The following versions are supported: $_fish_ai_supported_versions"
echo "Consider setting the environment variable 'FISH_AI_PYTHON_VERSION' to a supported version and reinstalling the plugin. For example:"
set_color --italics blue
echo ""
echo " fisher remove realiserad/fish-ai"
echo " set -U FISH_AI_PYTHON_VERSION $_fish_ai_supported_versions[-1]"
echo " fisher install realiserad/fish-ai"
echo ""
set_color normal
end
end
function _fish_ai_symlink_truststore --description "Use the bundle with CA certificates trusted by the OS."
if test -f /etc/ssl/certs/ca-certificates.crt
echo "🔑 Symlinking to certificates stored in /etc/ssl/certs/ca-certificates.crt."
ln -snf /etc/ssl/certs/ca-certificates.crt ("$_fish_ai_install_dir/bin/python3" -c 'import certifi; print(certifi.where())')
else if test -f /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
echo "🔑 Symlinking to certificates stored in /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem."
ln -snf /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem ("$_fish_ai_install_dir/bin/python3" -c 'import certifi; print(certifi.where())')
else if test -f /etc/ssl/cert.pem
echo "🔑 Symlinking to certificates stored in /etc/ssl/cert.pem."
ln -snf /etc/ssl/cert.pem ("$_fish_ai_install_dir/bin/python3" -c 'import certifi; print(certifi.where())')
end
end
function _fish_ai_warn_plaintext_api_keys --description "Warn about plaintext API keys."
if ! test -f "$_fish_ai_config_path"
return
end
if grep -q "^api_key" "$_fish_ai_config_path"
echo -n "🚨 One or more plaintext API keys are stored in "
set_color --bold red
echo -n "$_fish_ai_config_path"
set_color normal
echo -n ". Consider moving them to your keyring using "
set_color --italics blue
echo -n fish_ai_put_api_key
set_color normal
echo "."
end
end
function _fish_ai_autoconfig_gh_models --description "Deploy configuration for GitHub Models."
if test -f "$_fish_ai_config_path"
return
end
if ! type -q gh
return
end
if test -z (gh auth token 2>/dev/null)
return
end
if test -z (gh ext ls | grep "gh models" 2>/dev/null)
return
end
echo "[fish-ai]" >>"$_fish_ai_config_path"
echo "configuration = github" >>"$_fish_ai_config_path"
echo "" >>"$_fish_ai_config_path"
echo "[github]" >>"$_fish_ai_config_path"
echo "provider = self-hosted" >>"$_fish_ai_config_path"
echo "server = https://models.github.ai/inference" >>"$_fish_ai_config_path"
echo "api_key = $(gh auth token)" >>"$_fish_ai_config_path"
echo "model = gpt-4o-mini" >>"$_fish_ai_config_path"
echo "😺 Access to GitHub Models has been automatically configured for you!"
end
function _fish_ai_show_progress_indicator --description "Show a progress indicator."
if type -q fish_right_prompt
set -f rplen (string length -v (fish_right_prompt)[-1])
else
set -f rplen 0
end
# Get the progress indicator from the configuration, use hourglass emoji if not set
set -f progress_indicator ("$_fish_ai_install_dir/bin/lookup_setting" progress_indicator '⏳')
set -f pilen (string length "$progress_indicator")
# Move the cursor to the end of the line and insert progress indicator
tput hpa (math $COLUMNS - $rplen - 1 - $pilen)
echo -n "$progress_indicator"
end
+17
View File
@@ -10,12 +10,29 @@ end
if status is-interactive
alias ls="eza --icons --group-directories-first"
alias c="clear"
alias cc="cybervis -m neural -c arctic -s 5 -d 8 --no-status"
function __ls_after_cd --on-variable PWD
ls
end
pfetch
# Commands to run in interactive sessions can go here
end
zoxide init fish --cmd cd | source
starship init fish | source
set EDITOR nvim
set PATH $PATH:/home/krosh/.local/bin
# Added by LM Studio CLI (lms)
set -gx PATH $PATH /home/krosh/.lmstudio/bin
# End of LM Studio CLI section
thefuck --alias | source
# Created by `pipx` on 2026-05-18 21:21:55
set PATH $PATH /home/krosh/.local/bin
+1
View File
@@ -0,0 +1 @@
realiserad/fish-ai
@@ -1,3 +1,7 @@
# This file contains fish universal variable definitions.
# VERSION: 3.0
SETUVAR __fish_initialized:4300
SETUVAR _fisher_plugins:realiserad/fish\x2dai
SETUVAR _fisher_realiserad_2F_fish_2D_ai_files:\x7e/\x2econfig/fish/functions/_fish_ai_autocomplete\x2efish\x1e\x7e/\x2econfig/fish/functions/_fish_ai_autocomplete_or_fix\x2efish\x1e\x7e/\x2econfig/fish/functions/_fish_ai_codify\x2efish\x1e\x7e/\x2econfig/fish/functions/_fish_ai_codify_or_explain\x2efish\x1e\x7e/\x2econfig/fish/functions/_fish_ai_explain\x2efish\x1e\x7e/\x2econfig/fish/functions/_fish_ai_fix\x2efish\x1e\x7e/\x2econfig/fish/functions/fish_ai_bug_report\x2efish\x1e\x7e/\x2econfig/fish/functions/fish_ai_put_api_key\x2efish\x1e\x7e/\x2econfig/fish/functions/fish_ai_switch_context\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/fish_ai\x2efish
SETUVAR _fisher_upgraded_to_4_4:\x1d
SETUVAR fish_greeting:
@@ -0,0 +1,12 @@
#!/usr/bin/env fish
function _fish_ai_autocomplete --description "Autocomplete the current command using AI." --argument-names command cursor_position
if test ("$_fish_ai_install_dir/bin/lookup_setting" "debug") = True
set -f selected_completion ("$_fish_ai_install_dir/bin/autocomplete" "$command" "$cursor_position" | \
string collect)
else
set -f selected_completion ("$_fish_ai_install_dir/bin/autocomplete" "$command" "$cursor_position" | \
string collect 2> /dev/null)
end
printf '%s' "$selected_completion"
end
@@ -0,0 +1,25 @@
#!/usr/bin/env fish
function _fish_ai_autocomplete_or_fix --description "Autocomplete the current command or fix the previous command using AI."
set -f previous_status (string join '+' $pipestatus | math)
set -f input (commandline --current-buffer | string collect)
_fish_ai_show_progress_indicator
if test -z "$input" && test $previous_status -ne 0
# Fix the previous command.
set -l previous_command (history | head -1)
set -l output (_fish_ai_fix "$previous_command" | string collect)
commandline --replace "$output"
else if test -n "$input"
# Autocomplete the current command.
set -l cursor_position (commandline --cursor)
set -l output (_fish_ai_autocomplete "$input" "$cursor_position" | string collect)
set -l completion_length (math (string length "$output") - (string length "$input"))
commandline --replace "$output"
commandline --cursor (math $cursor_position + $completion_length)
end
commandline -f repaint
end
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env fish
function _fish_ai_codify --description "Turn a comment into a command using AI." --argument-names comment
if test ("$_fish_ai_install_dir/bin/lookup_setting" "debug") = True
set -f output ("$_fish_ai_install_dir/bin/codify" "$comment" | \
fish_indent | \
string collect)
else
set -f output ("$_fish_ai_install_dir/bin/codify" "$comment" | \
fish_indent | \
string collect 2> /dev/null)
end
printf '%s' "$output"
end
@@ -0,0 +1,21 @@
#!/usr/bin/env fish
function _fish_ai_codify_or_explain --description "Transform a command into a comment and vice versa using AI."
set -f input (commandline --current-buffer | string collect)
if test -z "$input"
return
end
_fish_ai_show_progress_indicator
if string match -q "# *" (string trim "$input")
set -f output (_fish_ai_codify "$input" | string collect)
else
set -f output (_fish_ai_explain "$input" | string collect)
end
commandline --replace "$output"
commandline -f repaint
end
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env fish
function _fish_ai_explain --description "Turn a command into a comment using AI." --argument-names command
if test ("$_fish_ai_install_dir/bin/lookup_setting" "debug") = True
set -f output ("$_fish_ai_install_dir/bin/explain" "$command" | \
string collect)
else
set -f output ("$_fish_ai_install_dir/bin/explain" "$command" | \
string collect 2> /dev/null)
end
echo -n "$output"
end
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env fish
function _fish_ai_fix --description "Fix a command using AI." --argument-names previous_command
if test ("$_fish_ai_install_dir/bin/lookup_setting" "debug") = True
set -f output ("$_fish_ai_install_dir/bin/fix" "$previous_command")
else
set -f output ("$_fish_ai_install_dir/bin/fix" "$previous_command" 2> /dev/null)
end
echo -n "$output"
end
@@ -0,0 +1,184 @@
#!/usr/bin/env fish
function fish_ai_bug_report
print_header Environment
print_environment
print_header "Key bindings"
print_key_bindings
print_header "Proxy settings"
print_proxy_settings
print_header Dependencies
print_dependencies
print_header "Fish plugins"
print_fish_plugins
print_header Configuration
print_configuration
print_header "Functionality tests"
perform_functionality_tests
print_header "Compatibility check"
perform_compatibility_check
print_header "Logs from the last session"
print_logs
if test "$_fish_ai_error_found" = true
echo "❌ Problems were found (see output above for details)."
return 1
end
end
function print_header --argument-names title
set_color --bold blue
echo "$title"
echo ""
set_color normal
end
function print_proxy_settings
# https://www.python-httpx.org/environment_variables
set proxy_variables (string join '|' 'HTTP_PROXY' 'HTTPS_PROXY' 'ALL_PROXY' 'NO_PROXY')
if test (env | grep -qiE "$proxy_variables")
env | grep -iE "$proxy_variables"
else
echo "No proxy is configured."
end
echo ""
end
function print_environment
if test -f /etc/os-release
echo "Running on $(cat /etc/os-release | grep PRETTY | cut -d= -f2 | tr -d '\"')"
echo "Machine hardware: $(uname -m)"
else if type -q sw_vers
echo "Running on macOS $(sw_vers --productVersion)"
echo "Machine hardware: $(uname -m)"
else
echo "❌ Running on an unsupported platform."
set -g _fish_ai_error_found true
end
echo ""
end
function print_key_bindings
bind | grep --color=never _fish_ai
echo ""
echo "Key bindings in use: $fish_key_bindings"
echo ""
end
function print_dependencies
if ! test -d "$_fish_ai_install_dir"
echo "❌ The virtual environment '$_fish_ai_install_dir' does not exist."
set -g _fish_ai_error_found true
return
end
if type -q uv
echo "😎 This system has uv installed."
end
echo "Python version used by fish-ai: $($_fish_ai_install_dir/bin/python3 --version)"
if type -q python3
echo "Python version used by the system: $(python3 --version)"
end
fish --version
fisher --version
git --version
echo ""
"$_fish_ai_install_dir/bin/pip" list
if ! test ("$_fish_ai_install_dir/bin/pip" list | grep fish_ai)
echo "❌ The Python package 'fish_ai' could not be found."
set -g _fish_ai_error_found true
end
echo ""
end
function print_fish_plugins
fisher list
echo ""
end
function print_configuration
if ! test -f "$_fish_ai_config_path"
echo "😕 The configuration file '$_fish_ai_config_path' does not exist."
else
# Remove api_key and password from the configuration
# password is no longer used but may be present in old configurations
sed /api_key/d "$_fish_ai_config_path" | sed /password/d
end
echo ""
end
function perform_functionality_tests
if ! test -f "$_fish_ai_config_path"
echo "😴 No configuration available. Skipping."
echo ""
return
end
echo "🔥 Running functionality tests..."
set -l start (date +%s)
set -l result (_fish_ai_codify 'print the current date')
set -l duration (math (date +%s) - $start)
echo "codify 'print the current date' -> '$result' (in $duration seconds)"
set -l start (date +%s)
set -l result (_fish_ai_explain 'date' | \
string trim --chars '# ' | \
string shorten --max 50)
set -l duration (math (date +%s) - $start)
echo "explain 'date' -> '$result' (in $duration seconds)"
echo ""
end
function perform_compatibility_check
set -f current_python_version ("$_fish_ai_install_dir/bin/python3" -c 'import platform; major, minor, _ = platform.python_version_tuple(); print(major, end="."); print(minor, end="")')
if ! contains $current_python_version $_fish_ai_supported_versions
echo "🔔 This plugin has not been tested with Python $_fish_ai_python_version and may not function correctly."
echo "The following versions are supported: $_fish_ai_supported_versions"
set -g _fish_ai_error_found true
else
echo "👍 Python $_fish_ai_python_version is supported."
end
echo ""
end
function print_logs
set -f log_file ("$_fish_ai_install_dir/bin/lookup_setting" log)
if ! test -f "$log_file"
echo "😴 No log file available."
echo "Enable with '$_fish_ai_install_dir/bin/put_setting fish-ai log /tmp/fish-ai.log'."
return
end
print_last_section "$log_file"
if test ("$_fish_ai_install_dir/bin/lookup_setting" debug) != True
echo ""
echo "🙏 Consider enabling debug mode to get more log output."
echo "Turn on with '$_fish_ai_install_dir/bin/put_setting fish-ai debug True'."
end
end
function print_last_section --argument-names log_file
set -l len (wc -l $log_file | awk '{ print $1 }')
for i in (seq $len -1 1)
set -l line (sed -n "$i p" "$log_file")
if test "$line" = "----- BEGIN SESSION -----"
for j in (seq $i $len)
echo (sed -n "$j p" "$log_file")
end
return
end
end
end
@@ -0,0 +1,5 @@
#!/usr/bin/env fish
function fish_ai_put_api_key --description "Put an API key on the user's keyring."
"$_fish_ai_install_dir/bin/put_api_key"
end
@@ -0,0 +1,5 @@
#!/usr/bin/env fish
function fish_ai_switch_context --description "Interactively switch to a different context."
"$_fish_ai_install_dir/bin/switch_context"
end