Skip to content

Add support for Nushell env var settings #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Sources/Swiftly/Init.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
"""
Expand Down Expand Up @@ -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 = """
Expand Down
15 changes: 7 additions & 8 deletions Sources/Swiftly/Install.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down