mirror of
https://github.com/nushell/nushell.git
synced 2026-10-28 17:05:03 +08:00
34 lines
990 B
Nu
34 lines
990 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.
|
|
@category "toolkit"
|
|
@search-terms plugin add plugins nu_plugin register
|
|
@example "Register all available plugins" { toolkit add 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)"
|
|
}
|