-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenv.nu
More file actions
56 lines (51 loc) · 1.9 KB
/
env.nu
File metadata and controls
56 lines (51 loc) · 1.9 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
# Extends env file (`$nu.env-path` `C:\Users\USER\AppData\Roaming\nushell\env.nu`)
# Sourced there through `source `~\.config\nushell\env.nu``
# Windows Installation path fixup https://github.com/nushell/nushell/issues/13065
$env.NU_PLUGIN_DIRS = ($env.NU_PLUGIN_DIRS | prepend ($nu.current-exe | path dirname))
const cfgpath = '~\.config\nushell'
const nuscriptspath2 = $'($cfgpath)\nu_scripts\modules'
$env.NU_LIB_DIRS = [...$env.NU_LIB_DIRS $nuscriptspath2 ]
def is-old [filepath: path] {
not ($filepath | path exists) or (ls $filepath | get modified | ($in | length) == 1 and (date now) - $in.0 > 1day)
}
def call-if-old [filepath: path, fn: closure] {
if (is-old $filepath) {
print $'Generating ($filepath)…'
do $fn $filepath
}
}
mkdir $nu.cache-dir
$nu.vendor-autoload-dirs | last | mkdir $in
$nu.user-autoload-dirs | last | mkdir $in
[
{
enabled: true
path: $'($nu.user-autoload-dirs | last)/starship-init.nu'
condition: { which starship | is-not-empty }
command: {|filepath| starship init nu | save -f $filepath }
}
{
enabled: true
path: $'($nu.user-autoload-dirs | last)/starship-completions.nu'
condition: { which starship | is-not-empty }
command: {|filepath| starship completions nushell | save -f $filepath }
}
{
enabled: true
path: $'($nu.user-autoload-dirs | last)/jj-completions.nu'
condition: { which jj | is-not-empty }
command: {|filepath| jj util completion nushell | save -f $filepath }
}
{
enabled: false
path: $'($nu.cache-dir)/pueue-completions.nu'
condition: { which pueue | is-not-empty }
command: {|filepath| pueue completions nushell | save -f $filepath }
}
{
enabled: false
path: 'config-zoxide.nu'
condition: { which zoxide | is-not-empty }
command: {|filepath| zoxide init nushell | save -f $filepath }
}
] | each {|x| if ($x.enabled and (do $x.condition)) { call-if-old $x.path $x.command } } | ignore