Re:The fish shell is amazing
by macromagnon on Thursday November 25, 2021 @04:22PM
(#29345112)
Is it that hard to remember a bash for loop?
for i in $(seq 1 10)
do echo $i
done
Then you can just replace new lines with ; if writing a one liner. for i in $(seq 1 10); do echo $i; done
I guess it isn't as simple as python for i in range(10): print(i)
but it's pretty close aside from the variable binding.Bash has some subtleties around loops that can be frustrating, like the body of your loop _may_ actually be running in a subshell (common when iterating over a file), making it difficult to extract what you want from it.
i bet it's the `cat file | while read …` loop what you are referring to, not any loop. but correct me.
In zsh you can avoid the do if you have a single instruction:
for i in {1..10}; echo $i
to me is as clear as the python version.
Very compact and useful for one liners.As someone dealing with new remote machines on a daily basis, I cannot fantasize about any other shell. Bash is pretty straightforward.
for i in {1..10}And look at all of those finger bending symbols!
> I moved from bash => zsh => fish
Did the same, but moved on.
Now it is: bash => zsh => fish => nu
What did you prefer about nu?
Working with tables of data feels more right, more like programming then the usual shell. I also work quite often with CSV and it's nice to be able to manipulate/filter it like any other data that nu is able to read (just: open file.csv | find "foobar" | select name message).
Not quite a straightforward as nu seams to be, but I used to have ipython as my shell when I did a lot of work with CSV. It’s “not a shell” but includes some shell like functions to make listing dirs and such easier.
The fact that I can write a simple for loop without needing to look up how to do it by far beats the POSIX compatibility, if I need it I can still write a bash script, but when using the shell I don't need to recall where semicolons or `do`, brackets (and how many) go.