dots/stow/.config/fish/config.fish
Nico 04e18089cf
Revert "fish: make getting os-release info local to function"
This reverts commit 4c6086487dfefb83bb7f7947a390c3c56923daa6.
2026-02-20 17:14:03 +11:00

92 lines
2.2 KiB
Fish

if status is-interactive
# Commands to run in interactive sessions can go here
#
# shell prompt
#
# match prompt symbol to OS logo
if test -e /etc/os-release
posix-source /etc/os-release
end
if test -e /System
set os_icon ""
eval "$(/opt/homebrew/bin/brew shellenv)"
else if [ "$ID" = "nixos" ]
set os_icon ""
else if [ "$ID" = "debian" ]
set os_icon ""
else if [ "$ID" = "fedora" ]
set os_icon ""
else if [ "$ID" = "arch" ]
set os_icon "󰣇"
else
set os_icon "\$"
end
# set prompt colours
if test -e ~/.cache/zsh_colours.sh
posix-source-universal (string replace -fra "{|}|#|\"" "" (cat ~/.cache/zsh_colours.sh) | psub)
else
set -Ux PRIMARY_COLOUR blue
set -Ux SECONDARY_COLOUR purple
end
# construct final prompt
function fish_prompt
# turn os_icon red if an error occurs
set -l prompt_icon
if test $status -ne 0
set prompt_icon (set_color red)"$os_icon"(set_color normal)
else
set prompt_icon "$os_icon"
end
# set ssh status
set -l ssh_status
if set -q SSH_CONNECTION
set ssh_status (prompt_login)
end
# concatenate $HOME to a ~ eg. /home/user to ~
set shorten_path (string replace -r "^$HOME" "~" "$PWD")
echo (set_color $PRIMARY_COLOUR)$shorten_path $ssh_status (set_color $SECONDARY_COLOUR)$prompt_icon (set_color normal)
end
#
# shell intergration
#
zoxide init fish | source
#
# environment variables
#
set -gx EDITOR nvim
set fish_greeting ""
set HOMEBREW_AUTO_UPDATE_SECS 86400
# xdg variables
set -gx XDG_CONFIG_HOME "$HOME/.config" # config
set -gx XDG_CACHE_HOME "$HOME/.cache" # cache
set -gx XDG_DATA_HOME "$HOME/.local/share" # data files eg. /usr/share
set -gx XDG_STATE_HOME "$HOME/.local/state" # state files eg. /var/lib
# make apps use XDG folders
set -gx PYTHON_HISTORY "$XDG_STATE_HOME"/python_history
set -gx PYTHONPYCACHEPREFIX "$XDG_CACHE_HOME"/python
set -gx PYTHONUSERBASE "$XDG_DATA_HOME"/python
set -gx GOPATH "$XDG_STATE_HOME"/go
set -gx GOMODCACHE "$XDG_CACHE_HOME"/go/mod
set -gx NPM_CONFIG_USERCONFIG "$XDG_CONFIG_HOME"/npm/npmrc
function wget --wraps=wget
wget --hsts-file="$XDG_STATE_HOME/wget-hsts" $argv
end
end