chore: cleanup

This commit is contained in:
johannes committed 2026-07-30 00:08:37 +02:00
1 parent 2a0f4f6851
commit d3460b52ea
42 files changed
+14 -2560

No files matched your search

+2 -62
View File
@@ -103,6 +103,7 @@ source $"($nu.cache-dir)/starship.nu"
source $"($nu.cache-dir)/carapace.nu"
source $"($nu.cache-dir)/zoxide.nu"
source $"($nu.cache-dir)/atuin.nu"
source $"($nu.cache-dir)/mise.nu"
#--------
# Scripts
@@ -122,60 +123,7 @@ source scripts/commands.nu
source completions/pm.nu
#----------------
# Custom Banner
#----------------
def banner [] {
# Catppuccin Mocha Palette Mappings (assuming terminal theme is set, otherwise approximations)
let rosewater = (ansi -e '38;2;245;224;220m')
let flamingo = (ansi -e '38;2;242;205;205m')
let pink = (ansi -e '38;2;245;194;231m')
let mauve = (ansi -e '38;2;203;166;247m')
let red = (ansi -e '38;2;243;139;168m')
let maroon = (ansi -e '38;2;235;160;172m')
let peach = (ansi -e '38;2;250;179;135m')
let yellow = (ansi -e '38;2;249;226;175m')
let green = (ansi -e '38;2;166;227;161m')
let teal = (ansi -e '38;2;148;226;213m')
let sky = (ansi -e '38;2;137;220;235m')
let sapphire = (ansi -e '38;2;116;199;236m')
let blue = (ansi -e '38;2;137;180;250m')
let lavender = (ansi -e '38;2;180;190;254m')
let text = (ansi -e '38;2;205;214;244m')
let overlay1 = (ansi -e '38;2;127;132;156m')
let overlay0 = (ansi -e '38;2;108;112;134m')
let reset = (ansi reset)
# Dynamic accent choice
let accent = ([$mauve, $pink, $sapphire, $green, $peach] | shuffle | first)
let sys_info = (sys host)
let uptime = $sys_info.uptime
let kernel = $sys_info.kernel_version
# Calculate config load time (env.nu + config.nu execution)
let startup = ((date now) - ($env.__NU_START_TIME? | default (date now)))
let version = (version | get version)
# Styling elements
let pipe = $"($overlay0)│($reset)"
let sep = $"($overlay1)::($reset)"
let header_line = $"($overlay0)──────────────────────────────────($reset)"
print ""
print $" ($overlay0)╭──($reset) ($accent)SYSTEM_READY($reset) ($header_line)"
print $" ($pipe)"
print $" ($pipe) ($lavender)HOST_ID($reset) ($sep) ($text)($sys_info.hostname)($reset)"
print $" ($pipe) ($lavender)KERNEL_VER($reset) ($sep) ($text)($kernel)($reset)"
print $" ($pipe) ($lavender)UPTIME_DUR($reset) ($sep) ($text)($uptime)($reset)"
print $" ($pipe)"
print $" ($pipe) ($lavender)SHELL_ENV($reset) ($sep) ($text)nu ($version)($reset)"
print $" ($pipe) ($lavender)LOAD_TIME($reset) ($sep) ($accent)($startup)($reset)"
print $" ($pipe)"
print $" ($overlay0)╰──($reset) ($header_line) ($accent)[OK]($reset)"
print ""
}
banner
fastfetch
#----------------
# Custom Commands
@@ -208,11 +156,3 @@ $env.config.keybindings = (
# Load machine-local config if it exists
source "~/.local.nu"
# Shadow warning for critical commands
let crit_cmds = ["git" "nu"]
for cmd in $crit_cmds {
let p = (which $cmd | get path | get 0? | default "")
if ($p | str contains ".local/share/mise/installs") {
print $"[Warning] Critical command '($cmd)' is shadowed by mise: ($p)"
}
}
+8 -68
View File
@@ -26,76 +26,16 @@ if not ($nu.cache-dir | path exists) {
mkdir $"($nu.cache-dir)"
}
def create_cache [name: string, generator: closure] {
let file = $"($nu.cache-dir)/($name).nu"
if not ($file | path exists) {
do $generator | save -f $file
}
}
if (which starship | is-not-empty) { starship init nu | save -f $"($nu.cache-dir)/starship.nu" } else { "" | save -f $"($nu.cache-dir)/starship.nu" }
if (which zoxide | is-not-empty) { zoxide init nushell | save -f $"($nu.cache-dir)/zoxide.nu" } else { "" | save -f $"($nu.cache-dir)/zoxide.nu" }
if (which atuin | is-not-empty) { atuin init nu | save -f $"($nu.cache-dir)/atuin.nu" } else { "" | save -f $"($nu.cache-dir)/atuin.nu" }
$env.CARAPACE_BRIDGES = 'zsh,fish,bash,inshellisense'
if (which carapace | is-not-empty) { ^carapace _carapace nushell | str replace '$env.config = $current' '$env.config = ($env.config? | default {} | merge $current)' | save -f $"($nu.cache-dir)/carapace.nu" } else { "" | save -f $"($nu.cache-dir)/carapace.nu" }
create_cache starship { starship init nu }
create_cache zoxide { zoxide init nushell }
create_cache atuin { atuin init nu }
create_cache carapace {
$env.CARAPACE_BRIDGES = 'zsh,fish,bash,inshellisense';
^carapace _carapace nushell | str replace '$env.config = $current' '$env.config = ($env.config? | default {} | merge $current)'
}
def --env apply_mise_env [mise_bin: string] {
let vars = (
^$mise_bin hook-env -s nu
| from csv --noheaders --no-infer
| rename 'op' 'name' 'value'
)
for var in $vars {
if $var.op == "set" {
if ($var.name | str uppercase) == "PATH" {
$env.PATH = ($var.value | split row (char esep))
} else {
load-env {($var.name): $var.value}
}
} else if $var.op == "hide" and $var.name in $env {
hide-env -i $var.name
}
}
}
def --env add-hook [field: cell-path new_hook: any] {
let field = $field | split cell-path | update optional true | into cell-path
let old_config = $env.config? | default {}
let old_hooks = $old_config | get $field | default []
$env.config = ($old_config | upsert $field ($old_hooks ++ [$new_hook]))
}
let mise_candidates = if ($nu.os-info.name == "macos") {
["/opt/homebrew/bin/mise" "~/.local/bin/mise" "mise"]
if (which mise | is-not-empty) {
mise activate nu | save -f $"($nu.cache-dir)/mise.nu"
} else {
["~/.local/bin/mise" "/home/linuxbrew/.linuxbrew/bin/mise" "mise"]
}
let mise_bin = (
$mise_candidates
| each {|candidate|
if $candidate == "mise" {
if (which mise | is-empty) { null } else { "mise" }
} else {
let expanded = ($candidate | path expand)
if ($expanded | path exists) { $expanded } else { null }
}
}
| compact
| get 0?
)
if $mise_bin != null {
$env.MISE_SHELL = "nu"
apply_mise_env $mise_bin
let mise_hook = {
condition: { "MISE_SHELL" in $env }
code: { apply_mise_env $mise_bin }
}
add-hook hooks.pre_prompt $mise_hook
add-hook hooks.env_change.PWD $mise_hook
"" | save -f $"($nu.cache-dir)/mise.nu"
}
# Deduplicate PATH at the end