Files
nushell/toolkit/plugins.nu
T
rose a6d689d493 Refactor toolkit.nu into module (#16701)
Refactors the toolkit into a module. Was getting a bit large

This PR preserves the actual `toolkit.nu` file by making it `export use
toolkit *`. This way, anyone using `use toolkit.nu` can still expect it
to work the same way. This does have the unfortunate side effect that it
introduces a `toolkit toolkit` command, which does the same thing as
just `toolkit` (i.e., runs `help main`)
2025-09-17 13:53:27 +03:00

31 lines
851 B
Nu

def windows? [] {
$nu.os-info.name == windows
}
# filter out files that end in .d
def keep-plugin-executables [] {
if (windows?) { where name ends-with '.exe' } else { where name !~ '\.d' }
}
# add all installed plugins
export def "add plugins" [] {
let plugin_path = (which nu | get path.0 | path dirname)
let plugins = (ls $plugin_path | where name =~ nu_plugin | keep-plugin-executables | get name)
if ($plugins | is-empty) {
print $"no plugins found in ($plugin_path)..."
return
}
for plugin in $plugins {
try {
print $"> plugin add ($plugin)"
plugin add $plugin
} catch { |err|
print -e $"(ansi rb)Failed to add ($plugin):\n($err.msg)(ansi reset)"
}
}
print $"\n(ansi gb)plugins registered, please restart nushell(ansi reset)"
}