# cursor shapes
set -g fish_cursor_default block
set -g fish_cursor_insert line
set -g fish_cursor_replace_one underscore
set -g fish_cursor_visual block
set -g fish_vi_force_cursor

# XDG thingy
set -gx XDG_BIN_HOME {{ xdg_dir.bin_home }}
set -gx XDG_CONFIG_HOME {{ xdg_dir.config_home }}
set -gx XDG_CACHE_HOME {{ xdg_dir.cache_home }}
set -gx XDG_DATA_HOME {{ xdg_dir.data_home }}
set -gx XDG_STATE_HOME {{ xdg_dir.state_home }}

# Respect defined XDG specs
set -gx MIX_XDG true
set -gx GHCUP_USE_XDG_DIRS true
####
set -gx ANSIBLE_LOCAL_TEMP $XDG_CACHE_HOME/ansible
set -gx APPTAINER_CACHEDIR $XDG_CACHE_HOME/apptainer
set -gx LINUXKIT_CACHE $XDG_CACHE_HOME/linuxkit
set -gx MAGEFILE_CACHE $XDG_CACHE_HOME/magefile
set -gx TF_PLUGIN_CACHE_DIR $XDG_CACHE_HOME/terraform/plugin-cache
####
set -gx DOCKER_CONFIG $XDG_CONFIG_HOME/docker
set -gx LUAROCKS_CONFIG $XDG_CONFIG_HOME/luarocks/config.lua
set -gx MOST_INITFILE $XDG_CONFIG_HOME/mostrc
set -gx NPM_CONFIG_USERCONFIG $XDG_CONFIG_HOME/npm/npmrc
set -gx RIPGREP_CONFIG_PATH $XDG_CONFIG_HOME/ripgrep/config
# set -gx WGETRC $XDG_CONFIG_HOME/wgetrc
set -gx _JAVA_OPTIONS -Djava.util.prefs.userRoot=$XDG_CONFIG_HOME/java
####
set -gx ANSIBLE_HOME $XDG_DATA_HOME/ansible
set -gx CARGO_HOME $XDG_DATA_HOME/cargo
set -gx CDKTF_HOME $XDG_DATA_HOME/terraform-cdk
set -gx GNUPGHOME $XDG_DATA_HOME/gnupg
set -gx GOPATH $XDG_DATA_HOME/go
set -gx GRADLE_USER_HOME $XDG_DATA_HOME/gradle
set -gx KREW_ROOT $XDG_DATA_HOME/krew
set -gx MINIKUBE_HOME $XDG_DATA_HOME
set -gx NPM_CONFIG_PREFIX $XDG_DATA_HOME/npm
set -gx OPAMROOT $XDG_DATA_HOME/opam
set -gx PNPM_HOME $XDG_DATA_HOME/pnpm
set -gx PULUMI_HOME $XDG_DATA_HOME/pulumi
set -gx PYENV_ROOT $XDG_DATA_HOME/pyenv
set -gx RUSTUP_HOME $XDG_DATA_HOME/rustup
set -gx STACK_ROOT $XDG_DATA_HOME/stack
set -gx TERMINFO $XDG_DATA_HOME/terminfo
set -gx TERMINFO_DIRS $XDG_DATA_HOME/terminfo:/usr/share/terminfo
set -gx XCURSOR_PATH $XDG_DATA_HOME/icons
####
set -gx NODE_REPL_HISTORY $XDG_STATE_HOME/node/repl_history
set -gx SQLITE_HISTORY $XDG_STATE_HOME/sqlite/history

# set -gx MANPATH :$XDG_DATA_HOME/man

# set necessary Guix paths for user env
set -gx GUIX_PROFILE $HOME/.guix-profile
set -gx GUIX_LOCPATH $GUIX_PROFILE/lib/locale
set -gx GUIX_EXTENSIONS_PATH $GUIX_PROFILE/share/guix/extensions

# common envs
set -gx VISUAL nvim
set -gx EDITOR $VISUAL
set -gx LESS "-R -i -M --incsearch"
set -gx LESSOPEN "|bat %s"
set -gx LESSHISTFILE -
set -gx PAGER less
# set -gx MANPAGER "less -R --use-color -Dd+b -Du+g -DS+kc"
set -gx MANPAGER "nvim +Man!"

# what fish uses to open fish_config settings
set -gx BROWSER xdg-open

# Rust: don't build openssl-sys
set -gx OPENSSL_NO_VENDOR 1
# Rust: miles faster to update crates.io index
set -gx CARGO_REGISTRIES_CRATES_IO_PROTOCOL sparse

# don't ping {proxy,sum}.golang.org all the time
set -gx GOPROXY direct
set -gx GOSUMDB off
set -gx GOTOOLCHAIN local

# Update check + telemetry
## .NET
set -gx DOTNET_CLI_TELEMETRY_OPTOUT true
set -gx DOTNET_SKIP_FIRST_TIME_EXPERIENCE true
## Pulumi
set -gx PULUMI_SKIP_UPDATE_CHECK true
set -gx PULUMI_AUTOMATION_API_SKIP_VERSION_CHECK true
## helmfile
set -gx HELMFILE_UPGRADE_NOTICE_DISABLED true
set -gx HELMFILE_DISABLE_INSECURE_FEATURES true
set -gx HELMFILE_SKIP_INSECURE_TEMPLATE_FUNCTIONS true
## kopia
set -gx KOPIA_CHECK_FOR_UPDATES false
set -gx KOPIA_PERSIST_CREDENTIALS_ON_CONNECT false
## qsv
set -gx QSV_NO_UPDATE true
set -gx QSV_PROGRESSBAR true
## atlas
set -gx ATLAS_NO_UPDATE_NOTIFIER true
## azure
set -gx AZURE_CORE_COLLECT_TELEMETRY false
## gcloud
set -gx CLOUDSDK_COMPONENT_MANAGER_DISABLE_UPDATE_CHECK true
set -gx CLOUDSDK_CORE_DISABLE_USAGE_REPORTING true
## awscli
set -gx SAM_CLI_TELEMETRY 0
## kubeshark
set -gx KUBESHARK_DISABLE_VERSION_CHECK true
## driftctl
set -gx DCTL_NO_VERSION_CHECK true
## deno
set -gx DENO_NO_UPDATE_CHECK true
## turbo
set -gx TURBO_TELEMETRY_DISABLED 1
## tabbyml
set -gx TABBY_DISABLE_USAGE_COLLECTION 1
## Hashicorp stuff phoning home
set -gx CHECKPOINT_DISABLE true
set -gx DISABLE_VERSION_CHECK true
set -gx VAGRANT_I_KNOW_WHAT_IM_DOING_PLEASE_BE_QUIET true
set -gx VAGRANT_BOX_UPDATE_CHECK_DISABLE true
set -gx VAGRANT_DISABLE_RESOLV_REPLACE true
set -gx VAGRANT_PREFER_SYSTEM_BIN true
## OPA (send every report into the blackhole)
set -gx OPA_TELEMETRY_SERVICE_URL http://0.0.0.0
## Kics
set -gx DISABLE_CRASH_REPORT 0
## Ref: https://consoledonottrack.com/
set -gx DO_NOT_TRACK 1

# the downloaded Electron binary won't work on musl anyway
set -gx ELECTRON_SKIP_BINARY_DOWNLOAD 1

# Debian and Alpine support this (check the script at /usr/bin/chromium-browser)
set -gx CHROMIUM_USER_FLAGS "
--ozone-platform-hint=auto
--disable-sync-preferences
--enable-features=WaylandWindowDecorations,WebRTCPipeWireCapturer
--disk-cache-dir=$XDG_RUNTIME_DIR/chromium-cache
--gtk-version=4"

# make puppeteer use the system's chromium (for mermaid-cli)
set -gx PUPPETEER_EXECUTABLE_PATH '/usr/bin/chromium-browser'
set -gx PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true

# qt5ct
set -gx QT_QPA_PLATFORMTHEME qt5ct
set -gx QT_PLATFORM_PLUGIN qt5ct

# fzf
set -gx FZF_DEFAULT_OPTS "--multi --layout=reverse --inline-info --cycle --separator=─ --preview-label=' Preview '
{% if theme == 'nord' %}
--color fg:-1,bg:-1,hl:{{ colors.green }},fg+:{{ colors.white2 }},bg+:{{ colors.grey2 }},hl+:{{ colors.green }}
--color pointer:{{ colors.red }},info:{{ colors.highlight }},spinner:{{ colors.grey3 }},header:{{ colors.grey3 }},prompt:{{ colors.blue }},marker:{{ colors.yellow }}
--color separator:{{ colors.highlight }},label:{{ colors.white2 }},border:{{ colors.highlight }}"
{% elif theme == 'onedark' %}
--color fg:-1,bg:-1,hl:{{ colors.purple }},fg+:{{ colors.white2 }},bg+:{{ colors.grey2 }},hl+:{{ colors.purple }}
--color info:{{ colors.green }},prompt:{{ colors.blue }},pointer:{{ colors.red }},marker:{{ colors.yellow }},spinner:{{ colors.blue }},header:{{ colors.blue }}
--color separator:{{ colors.highlight }},label:{{ colors.white2 }},border:{{ colors.highlight }}"
{% endif %}
set -gx FZF_DEFAULT_COMMAND "fd --type f --follow --hidden --exclude .git --color never"
set -gx FZF_CTRL_T_OPTS "--no-height --preview '{{ xdg_dir.bin_home }}/preview.sh {} \$FZF_PREVIEW_COLUMNS \$FZF_PREVIEW_LINES 2>/dev/null'"
set -gx FZF_CTRL_T_COMMAND "fd . \$dir --follow --hidden --exclude .git --color never"
set -gx FZF_ALT_C_OPTS "--preview 'lsd -1FAL --group-dirs first --icon always --color always {} 2>/dev/null'"
set -gx FZF_ALT_C_COMMAND "fd --type d --follow --hidden --exclude .git --color never"
# set -gx FZF_TMUX 1

# zoxide
# set -gx _ZO_ECHO 1
set -gx _ZO_FZF_OPTS "$FZF_DEFAULT_OPTS --no-multi"
set -gx _ZO_RESOLVE_SYMLINKS 1

# magefile
set -gx MAGEFILE_ENABLE_COLOR true

# LS_COLORS used for fd, exa, ...
# if command -v vivid > /dev/null
#     not status is-login; and set -gx LS_COLORS (vivid generate {{ theme | capitalize }})
# end

# forgit
set -gx FORGIT_COPY_CMD wl-copy
set -gx FORGIT_GI_TEMPLATES $XDG_CACHE_HOME/forgit/gi/repos/dvcs/gitignore/templates
set -gx FORGIT_GI_REPO_LOCAL $XDG_CACHE_HOME/forgit/gi/repos/dvcs/gitignore
set -gx FORGIT_GI_REPO_REMOTE https://github.com/dvcs/gitignore
set -gx FORGIT_FZF_DEFAULT_OPTS "
$FZF_DEFAULT_OPTS
--ansi
--height='80%'
--bind='alt-k:preview-up,alt-p:preview-up'
--bind='alt-j:preview-down,alt-n:preview-down'
--bind='ctrl-r:toggle-all'
--bind='ctrl-s:toggle-sort'
--bind='?:toggle-preview'
--bind='alt-w:toggle-preview-wrap'
--preview-window='right:60%'
+1"
{% if ssh_client == 'dropbear' %}

# use dropbear-dbclient for rsync
set -gx RSYNC_RSH "dbclient -y"
{% endif %}
