-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.nu
More file actions
114 lines (96 loc) · 4.65 KB
/
env.nu
File metadata and controls
114 lines (96 loc) · 4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# ==============================================================================
# Nushell Environment Configuration
# ==============================================================================
#
# This file is loaded before config.nu and is used for setting up environment
# variables, PATH, and other environment-level configurations.
# ==============================================================================
# XDG Base Directory Specification
# ==============================================================================
$env.XDG_CONFIG_HOME = ($env.HOME | path join ".config")
$env.XDG_DATA_HOME = ($env.HOME | path join ".local" "share")
$env.XDG_CACHE_HOME = ($env.HOME | path join ".cache")
$env.XDG_STATE_HOME = ($env.HOME | path join ".local" "state")
# ==============================================================================
# Editor Configuration
# ==============================================================================
$env.EDITOR = "nvim"
$env.VISUAL = "nvim"
# ==============================================================================
# Homebrew Configuration
# ==============================================================================
# Initialize Homebrew for macOS
if (sys host | get name) == "Darwin" {
if ("/opt/homebrew/bin/brew" | path exists) {
^/opt/homebrew/bin/brew shellenv | lines | each { |line|
let parts = ($line | parse "{key}={value}")
if ($parts | length) > 0 {
let key = ($parts | get 0.key | str replace 'export ' '')
let value = ($parts | get 0.value | str replace --all '"' '')
load-env {$key: $value}
}
}
} else if ("/usr/local/bin/brew" | path exists) {
^/usr/local/bin/brew shellenv | lines | each { |line|
let parts = ($line | parse "{key}={value}")
if ($parts | length) > 0 {
let key = ($parts | get 0.key | str replace 'export ' '')
let value = ($parts | get 0.value | str replace --all '"' '')
load-env {$key: $value}
}
}
}
}
# Initialize Homebrew for Linux
if (sys host | get name) == "Linux" {
if ("/home/linuxbrew/.linuxbrew/bin/brew" | path exists) {
^/home/linuxbrew/.linuxbrew/bin/brew shellenv | lines | each { |line|
let parts = ($line | parse "{key}={value}")
if ($parts | length) > 0 {
let key = ($parts | get 0.key | str replace 'export ' '')
let value = ($parts | get 0.value | str replace --all '"' '')
load-env {$key: $value}
}
}
}
}
# ==============================================================================
# PATH Configuration
# ==============================================================================
# Add common binary directories to PATH
$env.PATH = ($env.PATH | split row (char esep) | append [
($env.HOME | path join ".local" "bin")
($env.HOME | path join "bin")
"/usr/local/bin"
"/usr/local/sbin"
])
# ==============================================================================
# Version Managers
# ==============================================================================
# mise (polyglot version manager)
# Note: We don't activate mise here as it requires sourcing a file
# that may not exist at parse time. Instead, we rely on mise's
# automatic activation in interactive shells or manual activation.
# ==============================================================================
# Tool Configuration
# ==============================================================================
# fzf configuration
$env.FZF_DEFAULT_OPTS = "--height 40% --layout=reverse --border"
# Dotfiles location
$env.DOTFILES = ($env.HOME | path join "set-me-up")
# ==============================================================================
# Additional Variables and Tool Configuration
# ==============================================================================
# Load additional environment variables and tool configurations
# Note: This loads version manager vars and tool-specific PATH additions
if ("~/.config/nushell/variables/variables.nu" | path expand | path exists) {
source ~/.config/nushell/variables/variables.nu
}
# ==============================================================================
# Local Configuration
# ==============================================================================
# Load local machine-specific environment configurations (not tracked in git)
# This file should contain machine-specific env vars (API keys, paths, etc.)
if (($env.HOME | path join ".nushell.local") | path exists) {
source ($env.HOME | path join ".nushell.local")
}