Remove most templating from config.fish

Chezmoi templating causes issues when fish is run
somewhere without the expected packages installed
e.g., in a Toolbx container.

bladee.bsky.social d51a1e19 bc9bc94e

verified
Changed files
+63 -44
dot_config
private_fish
+63 -44
dot_config/private_fish/config.fish.tmpl
···
-
{{ $brewPath := lookPath "brew" }}
-
{{ if $brewPath -}}
+
#
# Set up Homebrew.
-
set -x HOMEBREW_NO_INSTALL_CLEANUP 1
-
set -x HOMEBREW_NO_ANALYTICS 1
-
set -x HOMEBREW_NO_AUTO_UPDATE 1
-
set -x HOMEBREW_NO_INSTALL_CLEANUP 1
-
set -x HOMEBREW_NO_INSTALL_UPGRADE 1
-
set -x HOMEBREW_NO_UPDATE_REPORT_NEW 1
-
set -x HOMEBREW_NO_ENV_HINTS 1
-
eval ({{ $brewPath | quote }} shellenv)
-
{{ end -}}
+
#
+
{{ $brewPath := lookPath "brew" -}}
+
if test -x {{ $brewPath | quote }}
+
set -x HOMEBREW_NO_ANALYTICS 1
+
set -x HOMEBREW_NO_AUTO_UPDATE 1
+
set -x HOMEBREW_NO_ENV_HINTS 1
+
set -x HOMEBREW_NO_INSTALL_CLEANUP 1
+
set -x HOMEBREW_NO_INSTALL_UPGRADE 1
+
set -x HOMEBREW_NO_UPDATE_REPORT_NEW 1
+
eval ({{ $brewPath | quote }} shellenv)
+
end
-
# Add directories to path.
+
#
+
# Add directories to PATH.
+
#
fish_add_path --global {{ joinPath .chezmoi.homeDir ".cargo/bin" | quote }}
fish_add_path --global {{ joinPath .chezmoi.homeDir ".local/bin" | quote }}
+
{{ if eq .chezmoi.os "linux" -}}
+
#
# Set XDG data directories.
+
#
set -x XDG_CACHE_HOME {{ joinPath .chezmoi.homeDir ".cache" | quote }}
set -x XDG_CONFIG_HOME {{ joinPath .chezmoi.homeDir ".config" | quote }}
set -x XDG_DATA_HOME {{ joinPath .chezmoi.homeDir ".local/share" | quote }}
set -x XDG_STATE_HOME {{ joinPath .chezmoi.homeDir ".local/state" | quote }}
+
{{- end }}
-
{{ $editorName := .editor | default "vi" -}}
-
{{ $editorPath := lookPath $editorName -}}
-
{{ if $editorPath -}}
-
set -x EDITOR {{ $editorPath | quote }}
-
{{ end -}}
+
#
+
# Set editor.
+
#
+
{{ $editorName := .editor -}}
+
if command --query {{ $editorName | quote }}
+
set -x EDITOR {{ $editorName | quote }}
+
end
-
{{ $batPath := lookPath "bat" }}
-
{{ if $batPath -}}
-
# Configure 'bat'.
-
alias cat bat
-
set -x MANPAGER "sh -c 'col -bx | bat -l man -p'"
-
set -x MANROFFOPT "-c"
-
set -x BAT_PAGER "less -FIKMFRS"
-
{{ end -}}
+
#
+
# Configure bat.
+
#
+
if command --query bat
+
alias cat bat
+
set -x MANPAGER "sh -c 'col -bx | bat -l man -p'"
+
set -x MANROFFOPT "-c"
+
set -x BAT_PAGER "less -FIKMFRS"
+
end
-
# Set default less options.
-
set -x SYSTEMD_LESS FIKMRS
+
{{ if eq .chezmoi.os "linux" -}}
+
#
+
# Configure systemd.
+
#
+
set -x SYSTEMD_LESS "FIKMRS"
+
{{- end }}
-
{{ $jjPath := lookPath "jj" }}
-
{{ if $jjPath -}}
-
# Enable JJ completions.
-
COMPLETE=fish {{ $jjPath | quote }} | source
-
{{ end -}}
+
#
+
# Enable Jujutsu completions.
+
#
+
if command --query jj
+
COMPLETE=fish jj | source
+
end
-
{{ $gioPath := lookPath "gio" }}
-
{{ if $gioPath -}}
-
# Disable rm if the trash is enabled.
-
alias ts "{{ $gioPath }} trash"
-
function rm
-
echo "'rm' is disabled. use 'ts' to move items to trash, or 'command rm' to use rm."
-
return 1
+
{{ if eq .chezmoi.os "linux" -}}
+
#
+
# Replace 'rm' with 'ts'.
+
#
+
if command --query gio
+
alias ts "gio trash"
+
function rm
+
echo "'rm' is disabled. use 'ts' to move items to trash, or 'command rm' to use rm."
+
return 1
+
end
end
-
{{ end -}}
+
{{- end }}
if status --is-interactive
-
{{ $atuinPath := lookPath "atuin" }}
-
{{ if $atuinPath }}
+
#
# Enable atuin.
-
atuin init fish | source
-
{{ end }}
+
#
+
if command --query atuin
+
atuin init fish | source
+
end
end