I’ve been trying nushell and words fail me. It’s like it was made for actual humans to use! 🤯 🤯 🤯
It even repeats the column headers at the end of the table if the output takes more than your screen…
Trying to think of how to do the same thing with awk
/grep
/sort
/whatever
is giving me a headache. Actually just thinking about awk
is giving me a headache. I think I might be allergic.
I’m really curious, what’s your favorite shell? Have you tried other shells than your distro’s default one? Are you an awk wizard or do you run away very fast whenever it’s mentioned?
I used nushell for a good 6 months, it was nice having structured data, but the syntax difference to bash which I use for my day job was just too jarring to stick with.
Fish was (for me) the right balance of nice syntactic sugar and being able to reasonably expect a bash idiom will work.
Nushell looks cool but I prefer to stick with the POSIXes so that I know my scripts will always work and syntax always does what I expect it to. I use zsh as a daily driver, and put up with various bashes, ashes, dashes, that come pre-installed with systems I won’t be using loads (e.g. temporary vms).
I don’t really mind having a non-POSIX shell since it doesn’t prevent bash scripts from working, but I get that if you want portability bash is still best since it’ll work mostly anywhere.
Until you discover nushell’s (lack of) quoting rules
Can you elaborate?
Last I checked, there was no rigorous system for how quoting worked, such as how to escape a quote inside a string.
That looks a lot like PowerShell
thanks, good thread.
Looks like it’s taken a page from PowerShell in passing structured data rather than just text.
Oh I didn’t know powershell did that too! It sure beats endless parsing errors
That was the foundational concept in powershell; everything is an object. They then went a ruined it with insane syntax and a somewhat logical, but entirely
in practiceimpractical verb-noun command structure.Nushell is powershell for humans. And helps that it runs across all systems. It’s one of the first things I install.
somewhat logical, but entirely in practice verb-noun command structure.
That’s supposed to be “impractical”, not “in practice”, for others reading along.
For example, the “proper” command to list a directory is:
Get-ChildItem
The “proper” command to fetch a webpage is:Invoke-WebRequest https://example.com/
In these particular cases, they do have aliases defined, so you can use
ls
,dir
andcurl
instead, but …yeah, that’s still generally what the command names are like.It’s partially more verbose than C#, which is one of the most verbose programming languages out there. I genuinely feel like this kind of defeats the point of having a scripting language in the first place, when it isn’t succinct.
Like, you’re hardly going to use it interactively, because it is so verbose, so you won’t know the commands very well. Which means, if you go to write a script with Powershell, you’ll need to look up how to do everything just as much as with a full-fledged programming language. And I do typically prefer the better tooling of a full-fledged programming language…
I prefer getting comfortable with bash, because it’s everywhere and I need it for work anyway (no fancy shells in remote VMs). But you can customize bash a lot to give more colored feedback or even customize the shortcuts with readline. Another one is pwsh (powershell) because it’s by default in Windows machines that (sadly) I sometimes have to use as VMs too. But you can also install it in linux since it’s now open source.
But if I wanted to experiment personally I’d go for xonsh, it’s a python-based one. So you have all the tools and power of python with terminal convenience.
Yeah if you need to work on machines with bash it makes sense to stick with it. Sorry you have to work on Windows… how is powershell compared to bash?
I don’t know python but xonsh seems really cool, especially since like nushell it works on both linux and windows so you don’t have to bother about OS specific syntax
powershell, in concept, is pretty powerful since it’s integrated with C# and allows dealing with complex data structures as objects too, similar to nushell (though it does not “pretty-print” everything the way nushell does, at least by default).
But in practice, since I don’t use it as much I never really get used to it and I’m constantly checking how to do things… I’m too used to posix tools and I often end up bringing over a portable subset of msys2, cygwin or similar whenever possible, just so I can use grep, sed, sort, uniq, curl, etc in Windows ^^U …however, for scripts where you have to deal with structured data it’s superior since it has builtin methods for that.
I like nushell, but I love xonsh. Xonsh is the bastard love child of Python and Bash.
it can be thought of as:
- try this statement in Python
- if there’s an exception, try it in bash.
Now, that’s not a very accurate description, because the reality is more nuanced, but it allows for things like:
for file in !(find | grep -i '[.]mp3^'): file = Path(file.strip()) if file != Path('.') and file != file.with_suffix('.mp3'): mv @(file) @(file.with_suffix('.mp3'))
Now, there are things in there I wouldn’t bother with normally - like, rather than using
mv
, I’d just usefile.rename()
, but the snippet shows a couple of the tools for interaction between xonsh and sh.- !(foo) - if writing python, execute foo, and return lines
- @(foo) - if writing sh, substitute with the value of the foo variable.
But, either a line is treated in a pyhony way, or in a shelly way - and if a line is shelly, you can reference Python variables or expressions via @(), and if it’s Pythony, you can execute shell code with !() or $(), returning the lines or the exact value, respectively.
Granted, I love python and like shell well enough, and chimeras are my jam, so go figure.
I use zsh, mainly because I’ve been using it for a really long time and it felt like an upgraded bash.
I also have used fish a tiny amount and like the idea but zsh just works for my purposes and I already know how it works.
nushell looks really cool though!
I don’t have much occasion to use awk any more but it can be really useful!
I’ve also been using zsh until now, it’s clear it’s a massive improvement over bash. No more accidentally pasting code into the terminal!
I wasn’t even looking for a new interactive shell, zsh is fine, I was looking for a new language for shell scripts because I’m tired of bash’s legacy quirks… but the interactive nushell was too cool to resist!
nushell seriously looks amazing for working with data. I gotta remember it exists the next time I’m doing stuff like this.
It seems like a nice shell to have around and usable for cases like this regardless!