Live data from Hacker News

Ask HN: Are alternative (oil, nu, etc.) shells usable as daily drivers?

news.ycombinator.com

51–60 of 146 posts

Re: Ask HN: Are alternative (oil, nu, etc.) shells usable as daily drivers?

#51
Nushell is great for simple tasks. i.e.

  ls **/data.json | each {|it| mv $it.name $"(dirname $it.name)/data.yml" }
Will be much more complex in bash

  find -name "data.json" | xargs -i bash -c "mv \"{}\" \"\$(dirname '{}')/data.yml\""
Note the escaped quotes and dollar signs in bash. It is really difficult to get them right.

In Nutshell we are actually using "functions" (supported syntax-wise) to do the job, so it will be much more simpler.

---

A more complex example from my recent code:

  ls $"(which npm.ps1 | get 0.path | path dirname)/*.ps1" | each {|it| get name | path basename }
    | each {|script_file| $"alias ($script_file | str replace ".ps1" "") = powershell.exe ($script_file)" }
    | str join "\n" | save --force ~/.config/nushell/env-generated.nu
Will be something like this in bash,

  find "$(dirname "$(which npm.ps1)")/" -maxdepth 1 -name "*.ps1" | sed -r "s/^.*\/([^\/]+)\.ps1/alias \1 = powershell.exe \1.ps1/g" >> "$NU_CONFIG_FILE"
Although the bash one is shorter, it takes me 10x more time to write and test. I initially tried to write it with xrgs but given up due to the complexity involved.

I think Nushell is more readable and easy to write for me.

Re: Ask HN: Are alternative (oil, nu, etc.) shells usable as daily drivers?

#53
post #32

How about instead of changing the shell get more out from your existing one. Starship [0] and fzf [1] will make your life much easier in any shell. I use fish but they work with bash, zsh and the like. [0] https://starship.rs/ [1] https://github.com/junegunn/fzf

Why not both? I use starship and fzf with a fish shell.

Fzf is a great productivity boost, especially because it integrates with everything so well. Starship is... nice and flashy, but I don't think it actually improves my productivity a lot. The biggest feature for me is giving me the current git branch, and I used to do it with my fish theme. I mean it's nice to know what version of Python I have currently, it's just not a killer feature.

Re: Ask HN: Are alternative (oil, nu, etc.) shells usable as daily drivers?

#54
post #7

I'm a Linux native guy and I haven't hardly touched Windows in years but I still find myself curious about PowerShell. Is PowerShell even remotely suitable as a Linux shell? Is there any hope for PowerShell on Linux, it's an interesting take on shells.

I use Powershell as standard shell on WSL (Linux on Windows) Everything is the same as Windows

Re: Ask HN: Are alternative (oil, nu, etc.) shells usable as daily drivers?

#55
post #7

I'm a Linux native guy and I haven't hardly touched Windows in years but I still find myself curious about PowerShell. Is PowerShell even remotely suitable as a Linux shell? Is there any hope for PowerShell on Linux, it's an interesting take on shells.

I switched my shell to pwsh a few years back when work had me doing heavy pwsh development. It worked, but…

1. It didn’t execute native commands directly, at least then, so I was cobbling together pwsh functions to imitate ls, etc.

2. The pipeline is awesome, but incompatible with the default UNIX/style, where commands produce and expect text.

Having said all of that, it worked and worked well, at least for my purposes (immersion and education).

The pwsh pipeline is far more powerful, esp. since it passes objects and can maintain those: command B can perform work on the results of command A and C can access the results of both A and B with relative ease. The same trick is possible in bash, e.g., but requires some funky redirect and pipe management.

One the pwsh work was done, I switched back to bash.

Re: Ask HN: Are alternative (oil, nu, etc.) shells usable as daily drivers?

#57
post #51

Nushell is great for simple tasks. i.e. ls **/data.json | each {|it| mv $it.name $"(dirname $it.name)/data.yml" } Will be much more complex in bash find -name "data.json" | xargs -i bash -c "mv \"{}\" \"\$(dirname '{}')/data.yml\"" Note the escaped quotes and dollar signs in bash. It is really difficult to get them right. In Nutshell we are actually using "functions" (supported syntax-wise) to do the job, so it will…

> find -name "data.json" | xargs -i bash -c "mv \"{}\" \"\$(dirname '{}')/data.yml\""

Albeit this task needn't involve a shell at all - just `find` and `rename`:

    find . -name data.json -exec rename .json .yml {} +

Re: Ask HN: Are alternative (oil, nu, etc.) shells usable as daily drivers?

#58
post #53
post #32

How about instead of changing the shell get more out from your existing one. Starship [0] and fzf [1] will make your life much easier in any shell. I use fish but they work with bash, zsh and the like. [0] https://starship.rs/ [1] https://github.com/junegunn/fzf

Why not both? I use starship and fzf with a fish shell. Fzf is a great productivity boost, especially because it integrates with everything so well. Starship is... nice and flashy, but I don't think it actually improves my productivity a lot. The biggest feature for me is giving me the current git branch, and I used to do it with my fish theme. I mean it's nice to know what version of Python I have currently, it's ju…

Sure, I too use fish as I wrote in the original post.

Starship gives me quite a bit of situational awareness:

- git status, with branch, uncommited stuff, all that

- my python venv I'm in, not just the system python version

- my aws profile active

- etc

Forgot to add zoxide [0] and ripgrep [1].

[0] https://github.com/ajeetdsouza/zoxide

[1] https://github.com/BurntSushi/ripgrep

Re: Ask HN: Are alternative (oil, nu, etc.) shells usable as daily drivers?

#59
I've been using nushell for a couple of weeks and I'm finding it good enough for a daily driver. I was never much of a shell script person so I don't miss any bash-isms, on the contrary I find that I can easily perform some tasks I'd normally have fired up a Ruby REPL to do, both because the language is much more sane and because it handles structured data and file formats natively. As for normal shell usage (running commands) I definitely prefer it to bash, the completion UI is much nicer and you can set it up very easily for external commands. Also it supports Windows so I don't have to switch to powershell mode when I'm on my gaming PC.

Again, I'm not a shell script person and I never liked sh/bash so I don't have any 1000 line shell scripts that I'll be porting over to nu, and if I need to do something that would take more than a couple lines of code I'll switch to a proper programming language. I definitely wouldn't ship nushell scripts in production or for anything that isn't my local configuration because the commands and the language itself are far from having a stable API.

Re: Ask HN: Are alternative (oil, nu, etc.) shells usable as daily drivers?

#60

I use `fish` as my main shell. It's closer to POSIX than eshell or oil, but it's definitely not POSIX. Personally, the main thing I like about it is that I can't copy paste bash commands. It forces me to read and understand and then convert. It also has some quality of life stuff I really like. I think next time I'm just going to go back to ZSH though as I feel I have learnt enough from the experience of using it tha…

It's gradually got more bash compatibility, with things like X=Y run-command, &&/|| as aliases for and/or, $() expansion, changes to * to match more items. I don't think it's impossible that a future edition of fish starts to support e.g. export or a subset of bash conditionals.
Post reply on HN