this post was submitted on 24 Jan 2025
43 points (100.0% liked)

Programming

17941 readers
145 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 2 years ago
MODERATORS
 

For those of you unaware: https://nushell.sh/

This is by far the most unique shell out there, since it doesn't use raw text as output/input to command line calls, but instead an actual data structure. It's like if every CLI call returned a database table, in a way.

you are viewing a single comment's thread
view the rest of the comments
[–] brian 17 points 3 days ago

I love alternative shells. my shell has been set to fish and zsh for about a year each, xonsh for a few years, and now nushell for a couple years, and I think that's probably my ranking as well.

fish and zsh are both nicer than bash, but they don't give you as much as xonsh and nu do. you get nice completion and configuration and such, but it's still a shell when it comes to the programming tasks.

I don't want just a shell, I want a programming language with a good repl that makes it easy to deal with commands. xonsh and nushell both do that.

my major problem with xonsh was that there was python syntax, and there was shell syntax. it didn't feel great to interleave sh cmds and py fns. everything had to be parsed and then everything had to be formatted to go back into sh cmds. the standard library of sh cmds doesn't really exist either. you either use the py version of libraries for paths/processes/whatever, or you call and parse the os version. the former seems like the intended one. I found myself having to find a pip package for whatever task.

nu solves all my problems with xonsh without sacrificing much. there isn't really a split between nu commands and shell ones syntactically. parsing is easy, most cli things output data as lines, ascii tables, or have a json flag, and nu has nice ways to deal with all of those. nu commands generally work given a single element or a list or a full table if they make sense to. running a command on each element in a list and dealing with the output is easy as opposed to having to break your pipeline and write a for loop. they also have plenty of builtins and plugins so the things I generally want to parse are already done. ls returns a table, ps returns a table, I can pass lists into rm, etc. there's community plugins for git so I don't have to remember their syntax for searching for commits, I just query in nu. aws cli has a json flag so I can explore logs and such as nu data. and if I just want.

now downsides to nu. it's not bash so you can't just source whatever file that a command probably gives you, and there's no source-bash like xonsh has, so you're stuck translating it to nu. if it just sets env vars it's not awful since you can just shell out to bash, but doesn't work for more complicated. for things like python you have to make sure you use the correct tool to make your venv since builtin one doesn't give you a nu file to load. not sure about support in other tools.

overall it's great and not really that much learning, especially if you just use it like a shell to begin with. it's not much commitment to try a new shell since you can still call scripts written in your previous one. I'd say try it and see how it goes