diff --git a/Sources/Swiftly/Init.swift b/Sources/Swiftly/Init.swift index 6afc047b..8430ae7e 100644 --- a/Sources/Swiftly/Init.swift +++ b/Sources/Swiftly/Init.swift @@ -136,6 +136,13 @@ struct Init: SwiftlyCommand { envFile = Swiftly.currentPlatform.swiftlyHomeDir(ctx).appendingPathComponent("env.fish", isDirectory: false) sourceLine = """ + # Added by swiftly + source "\(envFile.path)" + """ + } else if shell.hasSuffix("/nu") { + envFile = Swiftly.currentPlatform.swiftlyHomeDir(ctx).appendingPathComponent("env.nu", isDirectory: false) + sourceLine = """ + # Added by swiftly source "\(envFile.path)" """ @@ -190,6 +197,15 @@ struct Init: SwiftlyCommand { set -x PATH "$SWIFTLY_BIN_DIR" $PATH end + """ + } else if shell.hasSuffix("/nu") { + env = """ + $env.SWIFTLY_HOME_DIR = "\(Swiftly.currentPlatform.swiftlyHomeDir(ctx).path)" + $env.SWIFTLY_BIN_DIR = "\(Swiftly.currentPlatform.swiftlyBinDir(ctx).path)" + if "$SWIFTLY_BIN_DIR" not-in $env.PATH { + $env.PATH = ($env.PATH | split row (char esep) | prepend $env.SWIFTLY_BIN_DIR) + } + """ } else { env = """ diff --git a/Sources/Swiftly/Install.swift b/Sources/Swiftly/Install.swift index ac056362..8e98e020 100644 --- a/Sources/Swiftly/Install.swift +++ b/Sources/Swiftly/Install.swift @@ -127,18 +127,17 @@ struct Install: SwiftlyCommand { try await Swiftly.currentPlatform.getShell() } - // Fish doesn't cache its path, so this instruction is not necessary. - if pathChanged && !shell.hasSuffix("fish") { - await ctx.print( - """ - NOTE: Swiftly has updated some elements in your path and your shell may not yet be - aware of the changes. You can update your shell's environment by running + // Fish or Nushell don't seem to cache their `PATH` env var, so this instruction is not necessary. + if pathChanged && !shell.hasSuffix("fish") && !shell.hasSuffix("/nu") { + await ctx.print(""" + NOTE: Swiftly has updated some elements in your path and your shell may not yet be + aware of the changes. You can update your shell's environment by running hash -r - or restarting your shell. + or restarting your shell. - """) + """) } if let postInstallScript {