#!/usr/bin/env nu # Simple, working Nushell 0.109+ installer # Installs Nushell binary and plugins from local build directories def main [ --install-dir (-i): string = "" # Installation directory --interactive (-I) # Interactive mode --verify # Verify after install --test # Test mode (dry run) ] { print "๐Ÿš€ Nushell Distribution Installer" print "==================================" print "" # Set installation directory let install_dir = if ($install_dir == "") { $"($env.HOME)/.local/bin" } else { $install_dir } print $"๐Ÿ“ Installation directory: ($install_dir)" # Find binaries let nu_binary = if ("./nushell/target/release/nu" | path exists) { "./nushell/target/release/nu" } else { print "โŒ Error: Nushell binary not found at ./nushell/target/release/nu" print "Run 'just build-nushell' first" exit 1 } let plugins = (glob ./nu_plugin_*/target/release/nu_plugin_* | each {|p| {name: ($p | path basename), path: $p}}) print $"๐Ÿ“ฆ Found components:" print $" - Nushell binary: ($nu_binary | path basename)" print $" - Plugins: (($plugins | length))" ($plugins | each {|p| print $" โ€ข ($p.name)"}) if $test { print "" print "๐Ÿงช Test mode (dry run) - no changes made" print " Run without --test to actually install" return } print "" # Create directory mkdir -p $install_dir print $"โœ… Created: ($install_dir)" # Install Nushell print "" print "๐Ÿ“ฅ Installing Nushell..." cp $nu_binary $"($install_dir)/nu" chmod +x $"($install_dir)/nu" print $"โœ… Installed: ($install_dir)/nu" # Install plugins if ($plugins | length) > 0 { print "" print "๐Ÿ“ฅ Installing plugins..." for plugin in $plugins { cp $plugin.path $"($install_dir)/($plugin.name)" chmod +x $"($install_dir)/($plugin.name)" print $"โœ… Installed: ($plugin.name)" } } # Register plugins print "" print "๐Ÿ“ Registering plugins..." let nu_exe = $"($install_dir)/nu" let plugin_names = ($plugins | map {|p| $p.name}) for plugin_name in $plugin_names { let plugin_path = $"($install_dir)/($plugin_name)" try { ^$nu_exe -c $"plugin add ($plugin_path)" print $"โœ… Registered: ($plugin_name)" } catch {|err| print $"โš ๏ธ Failed to register ($plugin_name): ($err.msg)" } } # Summary print "" print "โœจ Installation Complete!" print "" print "๐Ÿ“‹ Next steps:" print $" 1. Add ($install_dir) to your PATH:" print $" export PATH=\"($install_dir):${'$'}PATH\"" print $" 2. Verify installation:" print $" ($install_dir)/nu -c \"version\"" print $" 3. Check registered plugins:" print $" ($install_dir)/nu -c \"plugin list\"" if $verify { print "" print "๐Ÿ” Verifying installation..." verify_installation $install_dir $plugin_names } } def verify_installation [install_dir: string, plugins: list] { let nu_exe = $"($install_dir)/nu" print "" print "Verification Results:" print "====================" # Check Nushell if ($nu_exe | path exists) { try { let version = (^$nu_exe -c "version") print $"โœ… Nushell: ($version)" } catch { print "โŒ Nushell binary not executable" } } else { print "โŒ Nushell binary not found" } # Check plugins for plugin in $plugins { let plugin_path = $"($install_dir)/($plugin)" if ($plugin_path | path exists) { print $"โœ… ($plugin): installed" } else { print $"โŒ ($plugin): not found" } } } main