config: make fish_plugins conditional and add PATH entries

- Convert fish_plugins to template with conditional sdkman plugin
- Add humanlog and foundry to PATH in commonrc scripts
- Fix WSL chassis detection by moving WSL check earlier
This commit is contained in:
Ryan Walters
2025-12-31 16:40:52 -06:00
parent d557965502
commit cbb871094d
4 changed files with 24 additions and 7 deletions
+9 -7
View File
@@ -1,3 +1,9 @@
{{- /* Detect if running in WSL first (needed for chassis detection) */ -}}
{{- $wsl := false -}}
{{- if eq .chezmoi.os "linux" -}}
{{- $wsl = (.chezmoi.kernel.osrelease | lower | contains "microsoft") -}}
{{- end -}}
{{- /* Detect chassis type (likely: laptop | desktop | container) */ -}} {{- /* Detect chassis type (likely: laptop | desktop | container) */ -}}
{{- /* Chassis type mapping: https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.6.0.pdf */ -}} {{- /* Chassis type mapping: https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.6.0.pdf */ -}}
{{- $chassisType := "desktop" }} {{- $chassisType := "desktop" }}
@@ -7,7 +13,7 @@
{{- else }} {{- else }}
{{- $chassisType = "desktop" }} {{- $chassisType = "desktop" }}
{{- end }} {{- end }}
{{- else if eq .chezmoi.os "linux" }} {{- else if and (eq .chezmoi.os "linux") (not $wsl) }}
{{- $chassisRaw := output "cat" "/sys/class/dmi/id/chassis_type" | trim }} {{- $chassisRaw := output "cat" "/sys/class/dmi/id/chassis_type" | trim }}
{{- if or (eq $chassisRaw "8") (eq $chassisRaw "9") (eq $chassisRaw "10") (eq $chassisRaw "14") }} {{- if or (eq $chassisRaw "8") (eq $chassisRaw "9") (eq $chassisRaw "10") (eq $chassisRaw "14") }}
{{- $chassisType = "laptop" }} {{- $chassisType = "laptop" }}
@@ -16,7 +22,7 @@
{{- else }} {{- else }}
{{- $chassisType = "desktop" }} {{- $chassisType = "desktop" }}
{{- end }} {{- end }}
{{- else if eq .chezmoi.os "windows" }} {{- else if or (eq .chezmoi.os "windows") $wsl }}
{{- $chassisType = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "if ((Get-CimInstance -Class Win32_Battery | Measure-Object).Count -gt 0) { Write-Output 'laptop' } else { Write-Output 'desktop' }") | trim }} {{- $chassisType = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "if ((Get-CimInstance -Class Win32_Battery | Measure-Object).Count -gt 0) { Write-Output 'laptop' } else { Write-Output 'desktop' }") | trim }}
{{- end }} {{- end }}
@@ -34,11 +40,7 @@
{{- $cpuThreads = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "(Get-CimInstance -ClassName 'Win32_Processor').NumberOfLogicalProcessors") | trim | atoi }} {{- $cpuThreads = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "(Get-CimInstance -ClassName 'Win32_Processor').NumberOfLogicalProcessors") | trim | atoi }}
{{- end -}} {{- end -}}
{{- /* Detect if running in WSL */ -}}
{{- $wsl := false -}}
{{- if eq .chezmoi.os "linux" -}}
{{- $wsl = (.chezmoi.kernel.osrelease | lower | contains "microsoft") -}}
{{- end -}}
encryption = "age" encryption = "age"
@@ -88,6 +88,9 @@ test -d $HOME/.opencode/bin && set -a paths_to_add $HOME/.opencode/bin
# pulumi # pulumi
test -d $HOME/.pulumi/bin && set -a paths_to_add $HOME/.pulumi/bin test -d $HOME/.pulumi/bin && set -a paths_to_add $HOME/.pulumi/bin
# humanlog
test -d $HOME/.humanlog/bin && set -a paths_to_add $HOME/.humanlog/bin
# dotnet # dotnet
if test -d $HOME/.dotnet if test -d $HOME/.dotnet
set -gx DOTNET_ROOT $HOME/.dotnet set -gx DOTNET_ROOT $HOME/.dotnet
@@ -102,6 +105,10 @@ end
# Batch add all collected paths (single PATH reconstruction instead of 17+ calls) # Batch add all collected paths (single PATH reconstruction instead of 17+ calls)
test -n "$paths_to_add[1]" && fish_add_path $paths_to_add test -n "$paths_to_add[1]" && fish_add_path $paths_to_add
# foundry (appended to PATH - lower priority)
if test -d $HOME/.foundry/bin
set -gx PATH $PATH $HOME/.foundry/bin
end
# Note: Fish uses mise (via conf.d/mise.fish) for unified version management. # Note: Fish uses mise (via conf.d/mise.fish) for unified version management.
# Bash uses mise as well, falling back to legacy managers if needed. # Bash uses mise as well, falling back to legacy managers if needed.
@@ -84,6 +84,12 @@ esac
# Pulumi (Infrastructure as Code) # Pulumi (Infrastructure as Code)
[ -d "$HOME/.pulumi/bin" ] && export PATH="$PATH:$HOME/.pulumi/bin" [ -d "$HOME/.pulumi/bin" ] && export PATH="$PATH:$HOME/.pulumi/bin"
# humanlog (JSON log formatting)
[ -d "$HOME/.humanlog/bin" ] && export PATH="$PATH:$HOME/.humanlog/bin"
# Foundry (Ethereum development framework - appended to PATH)
[ -d "$HOME/.foundry/bin" ] && export PATH="$PATH:$HOME/.foundry/bin"
# .NET SDK # .NET SDK
if [ -d "$HOME/.dotnet" ]; then if [ -d "$HOME/.dotnet" ]; then
export DOTNET_ROOT="$HOME/.dotnet" export DOTNET_ROOT="$HOME/.dotnet"
@@ -2,4 +2,6 @@
jorgebucaran/fisher jorgebucaran/fisher
ilancosman/tide@v6 ilancosman/tide@v6
patrickf1/fzf.fish patrickf1/fzf.fish
{{- if stat (joinPath .chezmoi.homeDir ".sdkman") }}
reitzig/sdkman-for-fish reitzig/sdkman-for-fish
{{- end }}