Templatize Nushell configs for cross-platform use

This commit is contained in:
Riz Ashraf
2026-04-07 00:53:34 +01:00
parent c33ea4edac
commit 728e5e2f95
3 changed files with 67 additions and 43 deletions
+50
View File
@@ -0,0 +1,50 @@
# Nushell Environment Configuration (Templated)
{{ if eq .chezmoi.os "windows" -}}
$env.CACHE_DIR = ($env.HOME | path join "AppData" "Local" "nushell" "cache")
{{- else -}}
$env.CACHE_DIR = ($env.HOME | path join ".cache" "nushell")
{{- end }}
# Ensure cache directory exists
try { mkdir $env.CACHE_DIR }
# Initialize Zoxide
if (which zoxide | is-not-empty) {
zoxide init nushell | save -f ($env.CACHE_DIR | path join "zoxide.nu")
} else {
"" | save -f ($env.CACHE_DIR | path join "zoxide.nu")
}
# Initialize Starship
if (which starship | is-not-empty) {
starship init nu | save -f ($env.CACHE_DIR | path join "starship.nu")
} else {
"" | save -f ($env.CACHE_DIR | path join "starship.nu")
}
# Set default editor and pager
{{ if eq .chezmoi.os "windows" -}}
$env.EDITOR = "nvim.exe"
$env.VISUAL = "nvim.exe"
{{- else -}}
$env.EDITOR = "nvim"
$env.VISUAL = "nvim"
{{- end }}
{{- if (which bat | is-not-empty) }}
$env.PAGER = "bat --paging=always"
{{- else if (which batcat | is-not-empty) }}
$env.PAGER = "batcat --paging=always"
{{- end }}
{{ if eq .chezmoi.os "windows" -}}
# Modern PowerShell 7 wrapper (pw7) for Nushell (Windows Only)
def --env pw7 [cmd: string] {
let profile = "{{ joinPath .chezmoi.homeDir "onedrive" "Documents" "PowerShell" "Gemini_Profile.ps1" }}"
^pwsh.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command $". '($profile)'; ($cmd) | Out-String"
}
{{- end }}
# Useful env variables
$env.BAT_THEME = "TwoDark"