refactor: reorganize Nushell configurations with Windows support

- Add shared Nushell config templates in .chezmoitemplates/
- Create Windows-specific Nushell configs in AppData/Roaming/
- Add Windows Terminal settings.json configuration
- Update PowerShell profile template
- Consolidate Nushell env.nu and config.nu templates across platforms
This commit is contained in:
Ryan Walters
2025-10-27 01:51:21 -05:00
parent 4f0b832564
commit 48d40b2872
8 changed files with 1531 additions and 1247 deletions

View File

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,242 @@
# {{ template "banner.tmpl" .}}
# Nushell Environment Config File
# Cross-platform configuration for Windows and Linux
# version = "0.98.0"
def create_left_prompt [] {
let dir = match (try { $env.PWD | path relative-to $nu.home-path } catch { null }) {
null => $env.PWD
'' => '~'
$relative_pwd => ([~ $relative_pwd] | path join)
}
let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold })
let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold })
let path_segment = $"($path_color)($dir)(ansi reset)"
$path_segment | str replace --all (char path_sep) $"($separator_color)(char path_sep)($path_color)"
}
def create_right_prompt [] {
let time_segment = ([
(ansi reset)
(ansi magenta)
(date now | format date '%x %X')
] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" |
str replace --regex --all "([AP]M)" $"(ansi magenta_underline)${1}")
let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([
(ansi rb)
($env.LAST_EXIT_CODE)
] | str join)
} else { "" }
([$last_exit_code, (char space), $time_segment] | str join)
}
$env.PROMPT_COMMAND = {|| create_left_prompt }
$env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt }
$env.PROMPT_INDICATOR = {|| "> " }
$env.PROMPT_INDICATOR_VI_INSERT = {|| ": " }
$env.PROMPT_INDICATOR_VI_NORMAL = {|| "> " }
$env.PROMPT_MULTILINE_INDICATOR = {|| "::: " }
# Environment variable conversions
$env.ENV_CONVERSIONS = {
"PATH": {
from_string: { |s| $s | split row (char esep) | path expand --no-symlink }
to_string: { |v| $v | path expand --no-symlink | str join (char esep) }
}
"Path": {
from_string: { |s| $s | split row (char esep) | path expand --no-symlink }
to_string: { |v| $v | path expand --no-symlink | str join (char esep) }
}
}
# Library and plugin directories
$env.NU_LIB_DIRS = [
($nu.default-config-dir | path join 'scripts')
($nu.data-dir | path join 'completions')
]
$env.NU_PLUGIN_DIRS = [
($nu.default-config-dir | path join 'plugins')
]
# Editor configuration
$env.EDITOR = "micro"
$env.MICRO_TRUECOLOR = 1
# OpenAI API Key
$env.OPENAI_API_KEY = "{{ dopplerProjectJson.OPENAI_CHATGPT_CLI }}"
# Initialize PATH as a list for easier manipulation
$env.PATH = ($env.PATH | split row (char esep))
# Platform-specific PATH additions
{{ if eq .chezmoi.os "windows" }}
# Windows PATH additions
# User local bin
$env.PATH = ($env.PATH | prepend ($env.USERPROFILE | path join ".local" "bin"))
# Go
let go_user = ($env.USERPROFILE | path join "go" "bin")
let go_system = "C:\\Program Files\\Go\\bin"
if ($go_user | path exists) { $env.PATH = ($env.PATH | prepend $go_user) }
if ($go_system | path exists) { $env.PATH = ($env.PATH | prepend $go_system) }
# Rust/Cargo
let cargo_bin = ($env.USERPROFILE | path join ".cargo" "bin")
if ($cargo_bin | path exists) { $env.PATH = ($env.PATH | prepend $cargo_bin) }
# Deno
let deno_bin = ($env.USERPROFILE | path join ".deno" "bin")
if ($deno_bin | path exists) {
$env.DENO_INSTALL = ($env.USERPROFILE | path join ".deno")
$env.PATH = ($env.PATH | prepend $deno_bin)
}
# Node/pnpm
let pnpm_home = ($env.LOCALAPPDATA | path join "pnpm")
if ($pnpm_home | path exists) {
$env.PNPM_HOME = $pnpm_home
$env.PATH = ($env.PATH | prepend $pnpm_home)
}
# Bun
let bun_bin = ($env.USERPROFILE | path join ".bun" "bin")
if ($bun_bin | path exists) {
$env.BUN_INSTALL = ($env.USERPROFILE | path join ".bun")
$env.PATH = ($env.PATH | prepend $bun_bin)
}
# Python/pyenv
let pyenv_root = ($env.USERPROFILE | path join ".pyenv" "pyenv-win")
if ($pyenv_root | path exists) {
$env.PYENV_ROOT = $pyenv_root
$env.PATH = ($env.PATH | prepend ($pyenv_root | path join "bin"))
$env.PATH = ($env.PATH | prepend ($pyenv_root | path join "shims"))
}
# .NET
let dotnet_root = ($env.USERPROFILE | path join ".dotnet")
if ($dotnet_root | path exists) {
$env.DOTNET_ROOT = $dotnet_root
$env.PATH = ($env.PATH | prepend $dotnet_root)
$env.PATH = ($env.PATH | prepend ($dotnet_root | path join "tools"))
}
# Bob (Neovim version manager)
let bob_bin = ($env.LOCALAPPDATA | path join "bob" "nvim-bin")
if ($bob_bin | path exists) { $env.PATH = ($env.PATH | prepend $bob_bin) }
# Spicetify
let spicetify = ($env.USERPROFILE | path join ".spicetify")
if ($spicetify | path exists) { $env.PATH = ($env.PATH | prepend $spicetify) }
# Pulumi
let pulumi_bin = ($env.USERPROFILE | path join ".pulumi" "bin")
if ($pulumi_bin | path exists) { $env.PATH = ($env.PATH | prepend $pulumi_bin) }
# Scoop
let scoop_shims = ($env.USERPROFILE | path join "scoop" "shims")
if ($scoop_shims | path exists) { $env.PATH = ($env.PATH | prepend $scoop_shims) }
{{ else }}
# Linux/macOS PATH additions
# User local bin
$env.PATH = ($env.PATH | prepend ($env.HOME | path join ".local" "bin"))
# System bins
$env.PATH = ($env.PATH | prepend "/usr/local/bin")
$env.PATH = ($env.PATH | prepend ($env.HOME | path join "bin"))
# Go
let go_bin = "/usr/local/go/bin"
let go_user = ($env.HOME | path join "go" "bin")
if ($go_bin | path exists) { $env.PATH = ($env.PATH | prepend $go_bin) }
if ($go_user | path exists) { $env.PATH = ($env.PATH | prepend $go_user) }
# Rust/Cargo
let cargo_bin = ($env.HOME | path join ".cargo" "bin")
if ($cargo_bin | path exists) { $env.PATH = ($env.PATH | prepend $cargo_bin) }
# Deno
let deno_bin = ($env.HOME | path join ".deno" "bin")
if ($deno_bin | path exists) { $env.PATH = ($env.PATH | prepend $deno_bin) }
# Bob (Neovim version manager)
let bob_bin = ($env.HOME | path join ".local" "share" "bob" "nvim-bin")
if ($bob_bin | path exists) { $env.PATH = ($env.PATH | prepend $bob_bin) }
# Homebrew (Linux)
let brew_bin = "/home/linuxbrew/.linuxbrew/bin"
if ($brew_bin | path exists) {
$env.PATH = ($env.PATH | prepend $brew_bin)
$env.PATH = ($env.PATH | prepend "/home/linuxbrew/.linuxbrew/sbin")
}
# pnpm
let pnpm_home = ($env.HOME | path join ".local" "share" "pnpm")
if ($pnpm_home | path exists) {
$env.PNPM_HOME = $pnpm_home
$env.PATH = ($env.PATH | prepend $pnpm_home)
}
# Bun
let bun_bin = ($env.HOME | path join ".bun" "bin")
if ($bun_bin | path exists) {
$env.BUN_INSTALL = ($env.HOME | path join ".bun")
$env.PATH = ($env.PATH | prepend $bun_bin)
}
# pyenv
let pyenv_root = ($env.HOME | path join ".pyenv")
if ($pyenv_root | path exists) {
$env.PYENV_ROOT = $pyenv_root
$env.PATH = ($env.PATH | prepend ($pyenv_root | path join "bin"))
}
# jenv (Java)
let jenv_bin = ($env.HOME | path join ".jenv" "bin")
if ($jenv_bin | path exists) { $env.PATH = ($env.PATH | prepend $jenv_bin) }
# .NET
let dotnet_root = ($env.HOME | path join ".dotnet")
if ($dotnet_root | path exists) {
$env.DOTNET_ROOT = $dotnet_root
$env.PATH = ($env.PATH | prepend $dotnet_root)
$env.PATH = ($env.PATH | prepend ($dotnet_root | path join "tools"))
}
# Spicetify
let spicetify = ($env.HOME | path join ".spicetify")
if ($spicetify | path exists) { $env.PATH = ($env.PATH | prepend $spicetify) }
# Pulumi
let pulumi_bin = ($env.HOME | path join ".pulumi" "bin")
if ($pulumi_bin | path exists) { $env.PATH = ($env.PATH | prepend $pulumi_bin) }
# Perl (if installed)
let perl_bin = ($env.HOME | path join "perl5" "bin")
if ($perl_bin | path exists) {
$env.PATH = ($env.PATH | prepend $perl_bin)
$env.PERL5LIB = ($env.HOME | path join "perl5" "lib" "perl5")
$env.PERL_LOCAL_LIB_ROOT = ($env.HOME | path join "perl5")
}
# hishtory
let hishtory_bin = ($env.HOME | path join ".hishtory")
if ($hishtory_bin | path exists) { $env.PATH = ($env.PATH | prepend $hishtory_bin) }
{{ end }}
# Remove duplicates from PATH
$env.PATH = ($env.PATH | uniq)
# WSL-specific settings
{{ if .wsl }}
# Ensure CLI apps open URLs in Windows browser
$env.BROWSER = 'powershell.exe /c start'
{{ end }}