Skip to content
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

Feature request: nushell #704

Open
MilesCranmer opened this issue May 14, 2024 · 7 comments
Open

Feature request: nushell #704

MilesCranmer opened this issue May 14, 2024 · 7 comments

Comments

@MilesCranmer
Copy link

Just wondering if anybody has started a nushell integration for Lmod?

See https://github.com/nushell/nushell and https://www.nushell.sh/ for info.

Perhaps one way to do it is through the overlay system: https://www.nushell.sh/book/overlays.html. But maybe it is enough to just write some aliases so nushell is interfaced as if it were bash.

@rtmclay
Copy link
Member

rtmclay commented May 14, 2024

You are the first person to mention nushell. If you are interested in having Lmod be supported by nushell, please submit a pull request to support this shell.

@MilesCranmer
Copy link
Author

Sure, how should I get started?

@rtmclay
Copy link
Member

rtmclay commented May 14, 2024

Here are my suggestions:

  1. Study the init/sh.in file in the source and see how that works. It will work with bash
  2. See if you can define a shell function that works in nushell in your personal account for the "module" command
  3. Do the same for "ml" and "clearMT"
  4. If nushell supports system startup files like /etc/profile does for bash then figure how that works for nushell
  5. Now extend the your nushell startup files to do all the things that init/bash.in does
  6. Add your startup file for nushell to Lmod in the init directory and update the docs in docs/source/030_installing.rst on how your startup files work.
  7. Create a pull request

@rtmclay
Copy link
Member

rtmclay commented Jun 2, 2024

I'm closing this issue. If you get a chance to work on this, you can re-open this issue.

@rtmclay rtmclay closed this as completed Jun 2, 2024
@MilesCranmer
Copy link
Author

MilesCranmer commented Jun 2, 2024

I'm still interested; please re-open. Just haven't had a chance to work much on this yet.

@MilesCranmer
Copy link
Author

I don't think it will be that difficult. Basically whenever bash has

export CMD="..."

the nushell version would be

$env.CMD = "..."

The tricky part would be things like PATH as nushell treats that as an array rather than a :-separated string. For that one would do

std path add "/path/to/bin"

And string interpolation for e.g., "${MY_DIR}/path" would be

$"($env.MY_DIR)/path"

@rtmclay rtmclay reopened this Jun 2, 2024
@rtmclay
Copy link
Member

rtmclay commented Jun 2, 2024

Lmod does not add to path and path-like variables. Instead it sets the variable to all values. I did not think about nushell would have a different syntax from Bash. You will have to create a lua file called nushell.lua which works like Bash.lua or Rc.lua. You will have to modify BaseShell.lua. All of these files are in the shells directory.

The way that Lmod works is that it generates text which is then evaluated by the shell. You should write a text file that contains some nushell commands and make sure that you can evaluate commands. In Bash/Zsh this looks like

     eval "$(...)"

where the ... is some like cat nushell.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants