Files
dotfiles/home/.chezmoi.toml.tmpl
Ryan Walters 625cf3c3ae fix: correct WSL detection and improve platform-specific configuration
- Set WSL detection to false by default for proper conditional evaluation
- Add delta as diff pager for improved git diff output
- Change Windows cd command from nu to powershell.exe with -NoLogo flag
- Refactor .chezmoiignore to use clearer platform-specific sections
- Fix WSL-only files to be properly excluded on non-WSL systems
- Separate Linux/Unix and Windows file exclusions for better clarity
- Remove zsh profile from Cursor settings (migrated to Fish shell)
2025-10-27 20:01:56 -05:00

79 lines
2.9 KiB
TOML

{{- /* Detect chassis type (likely: laptop | desktop | container) */ -}}
{{- /* https://www.freedesktop.org/software/systemd/man/latest/hostnamectl.html#chassis%20%5BTYPE%5D */ -}}
{{- $chassisType := "desktop" }}
{{- if eq .chezmoi.os "darwin" }}
{{- if contains "MacBook" (output "sysctl" "-n" "hw.model") }}
{{- $chassisType = "laptop" }}
{{- else }}
{{- $chassisType = "desktop" }}
{{- end }}
{{- else if eq .chezmoi.os "linux" }}
{{- $chassisType = (output "hostnamectl" "--json=short" | mustFromJson).Chassis }}
{{- else if eq .chezmoi.os "windows" }}
{{- $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 }}
{{- /* Detect number of CPU cores and threads */ -}}
{{- $cpuCores := 1 }}
{{- $cpuThreads := 1 }}
{{- if eq .chezmoi.os "darwin" }}
{{- $cpuCores = (output "sysctl" "-n" "hw.physicalcpu_max") | trim | atoi }}
{{- $cpuThreads = (output "sysctl" "-n" "hw.logicalcpu_max") | trim | atoi }}
{{- else if eq .chezmoi.os "linux" }}
{{- $cpuCores = (output "sh" "-c" "lscpu --online --parse | grep --invert-match '^#' | sort --field-separator=',' --key='2,4' --unique | wc --lines") | trim | atoi }}
{{- $cpuThreads = (output "sh" "-c" "lscpu --online --parse | grep --invert-match '^#' | wc --lines") | trim | atoi }}
{{- else if eq .chezmoi.os "windows" }}
{{- $cpuCores = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "(Get-CimInstance -ClassName 'Win32_Processor').NumberOfCores") | trim | atoi }}
{{- $cpuThreads = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "(Get-CimInstance -ClassName 'Win32_Processor').NumberOfLogicalProcessors") | trim | atoi }}
{{- end -}}
{{- /* Detect if running in WSL */ -}}
{{- $wsl := false -}}
{{- if eq .chezmoi.os "linux" -}}
{{- $wsl = (.chezmoi.kernel.osrelease | lower | contains "microsoft") -}}
{{- end -}}
encryption = "age"
[merge]
command = "bash"
args = [
"-c",
"cp {{ "{{" }} .Target {{ "}}" }} {{ "{{" }} .Target {{ "}}" }}.base && code --new-window --wait --merge {{ "{{" }} .Destination {{ "}}" }} {{ "{{" }} .Target {{ "}}" }} {{ "{{" }} .Target {{ "}}" }}.base {{ "{{" }} .Source {{ "}}" }}",
]
[data]
chassis = {{ $chassisType | quote }}
wsl = {{ $wsl }}
[diff]
pager = "delta"
scriptContents = false
[data.cpu]
cores = {{ $cpuCores }}
threads = {{ $cpuThreads }}
[age]
identity = "{{ .chezmoi.homeDir }}/key.txt"
recipient = "age1s3ctpj9lafl6qwyvd89sn448us7gdzd53d8yyhsc7zny78c0k4sqerrkze"
[doppler]
project = "dotfiles"
config = "production"
[hooks.init.pre]
command = "bun"
args = ["{{ .chezmoi.sourceDir }}/hooks/.init_pre.ts"]
[hooks.update.pre]
command = "bun"
args = ["{{ .chezmoi.sourceDir }}/hooks/.update_pre.ts"]
{{ if eq .chezmoi.os "windows" }}
[cd]
command = "powershell.exe"
args = ["-NoLogo"]
{{ else }}
[cd]
command = "fish"
{{ end }}