From 5dd28d229c3b1cb9650039f7b0f425634eb2321d Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 31 Mar 2025 12:15:28 +0100 Subject: [PATCH 1/6] Add support for Nushell env var settings Currently, swiftly incorrectly generates Bash env var scripts when it is installed in Nushell. --- Sources/Swiftly/Init.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sources/Swiftly/Init.swift b/Sources/Swiftly/Init.swift index 0895b38c..a629e2a6 100644 --- a/Sources/Swiftly/Init.swift +++ b/Sources/Swiftly/Init.swift @@ -156,6 +156,15 @@ struct Init: SwiftlyCommand { set -x PATH "$SWIFTLY_BIN_DIR" $PATH end + """ + } else shell.hasSuffix("/nu") { + env = """ + $env.SWIFTLY_HOME_DIR = "\(Swiftly.currentPlatform.swiftlyHomeDir.path)" + $env.SWIFTLY_BIN_DIR = "\(Swiftly.currentPlatform.swiftlyBinDir.path)" + if "$SWIFTLY_BIN_DIR" not-in $env.PATH { + $env.PATH = ($env.PATH | split row (char esep) | prepend $env.SWIFTLY_BIN_DIR) + } + """ } else { env = """ From 61c43b0972faf9110de6e3d1e5528fa37d3e7ff5 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 31 Mar 2025 12:19:01 +0100 Subject: [PATCH 2/6] Update Install.swift --- Sources/Swiftly/Install.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Swiftly/Install.swift b/Sources/Swiftly/Install.swift index fa32a38c..31415fc8 100644 --- a/Sources/Swiftly/Install.swift +++ b/Sources/Swiftly/Install.swift @@ -109,8 +109,8 @@ 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") { + // 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") { SwiftlyCore.print(""" NOTE: We have updated some elements in your path and your shell may not yet be aware of the changes. You can run this command to update your shell. From 54519539cb6c909a5da9503ebd0db82c6fe01a3c Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 31 Mar 2025 12:29:29 +0100 Subject: [PATCH 3/6] Update Init.swift --- Sources/Swiftly/Init.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sources/Swiftly/Init.swift b/Sources/Swiftly/Init.swift index a629e2a6..9d965f13 100644 --- a/Sources/Swiftly/Init.swift +++ b/Sources/Swiftly/Init.swift @@ -102,6 +102,13 @@ struct Init: SwiftlyCommand { envFile = Swiftly.currentPlatform.swiftlyHomeDir.appendingPathComponent("env.fish", isDirectory: false) sourceLine = """ + # Added by swiftly + source "\(envFile.path)" + """ + } else if shell.hasSuffix("/nu") { + envFile = Swiftly.currentPlatform.swiftlyHomeDir.appendingPathComponent("env.nu", isDirectory: false) + sourceLine = """ + # Added by swiftly source "\(envFile.path)" """ @@ -157,7 +164,7 @@ struct Init: SwiftlyCommand { end """ - } else shell.hasSuffix("/nu") { + } else if shell.hasSuffix("/nu") { env = """ $env.SWIFTLY_HOME_DIR = "\(Swiftly.currentPlatform.swiftlyHomeDir.path)" $env.SWIFTLY_BIN_DIR = "\(Swiftly.currentPlatform.swiftlyBinDir.path)" From c459ee3d08a8f056939c13a03ea13ccff2b6aebb Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 8 Apr 2025 15:21:53 +0100 Subject: [PATCH 4/6] Update Init.swift --- Sources/Swiftly/Init.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Swiftly/Init.swift b/Sources/Swiftly/Init.swift index d5ad4be4..e0f8bee3 100644 --- a/Sources/Swiftly/Init.swift +++ b/Sources/Swiftly/Init.swift @@ -200,8 +200,8 @@ struct Init: SwiftlyCommand { """ } else if shell.hasSuffix("/nu") { env = """ - $env.SWIFTLY_HOME_DIR = "\(Swiftly.currentPlatform.swiftlyHomeDir.path)" - $env.SWIFTLY_BIN_DIR = "\(Swiftly.currentPlatform.swiftlyBinDir.path)" + $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) } From 77155832a2ee776e30d39be2a83cd8fceda81f08 Mon Sep 17 00:00:00 2001 From: Chris McGee <87777443+cmcgee1024@users.noreply.github.com> Date: Fri, 11 Apr 2025 17:30:34 -0400 Subject: [PATCH 5/6] Update Init.swift --- Sources/Swiftly/Init.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Swiftly/Init.swift b/Sources/Swiftly/Init.swift index e0f8bee3..4694161a 100644 --- a/Sources/Swiftly/Init.swift +++ b/Sources/Swiftly/Init.swift @@ -140,7 +140,7 @@ struct Init: SwiftlyCommand { source "\(envFile.path)" """ } else if shell.hasSuffix("/nu") { - envFile = Swiftly.currentPlatform.swiftlyHomeDir.appendingPathComponent("env.nu", isDirectory: false) + envFile = Swiftly.currentPlatform.swiftlyHomeDir(ctx).appendingPathComponent("env.nu", isDirectory: false) sourceLine = """ # Added by swiftly From d1ecc16594232c34ef32e2a9a70416397b6630d4 Mon Sep 17 00:00:00 2001 From: Chris McGee <87777443+cmcgee1024@users.noreply.github.com> Date: Fri, 11 Apr 2025 17:39:01 -0400 Subject: [PATCH 6/6] Update Install.swift --- Sources/Swiftly/Install.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Swiftly/Install.swift b/Sources/Swiftly/Install.swift index 940510da..8e98e020 100644 --- a/Sources/Swiftly/Install.swift +++ b/Sources/Swiftly/Install.swift @@ -135,9 +135,9 @@ struct Install: SwiftlyCommand { hash -r - or restarting your shell. + or restarting your shell. - """) + """) } if let postInstallScript {