this post was submitted on 21 Sep 2023
46 points (100.0% liked)

Free and Open Source Software

17779 readers
33 users here now

If it's free and open source and it's also software, it can be discussed here. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 2 years ago
MODERATORS
 
top 22 comments
sorted by: hot top controversial new old
[–] dylanmorgan@slrpnk.net 10 points 1 year ago (4 children)

This may be the wrong place to ask, but what am I missing about shells? Other than executing commands, what do you do with them?

[–] TiphaineRupa@feddit.de 11 points 1 year ago

Many Linux users spend a considerable amount of time using the command line interface, so the right shell configuration can make them much more productive.

[–] hallettj@beehaw.org 10 points 1 year ago (1 children)

I think the best way to get an idea is to look at feature lists for fancy shells like zsh or fish. But in short there are a number of things a good shell can do to help to execute commands faster and more easily. Stuff like autocompletions which make you faster, and also make things more discoverable; fuzzy searching/matching; navigating command history; syntax highlighting which helps to spot errors, and helps to understand the syntax of the command you're writing.

[–] Tin@beehaw.org 3 points 1 year ago

I use fish mainly just for the quality of life increase that its predictive features and command history give. I also really like that it uses functions to play the role of aliases, and it's super easy to write and save new functions on the fly.

That said... I haven't put in the time to really learn its nuances and I still write shell scripts using bash. Maybe I'm doing it wrong, but it works for me.

[–] starman@programming.dev 8 points 1 year ago

Execute complicated commands, wrire scripts, automate tasks, etc.

[–] SWW13@lemmy.brief.guru 2 points 1 year ago (1 children)

You can do most things by combining simple cmdline tools. E.g. filter out some specific lines from all files in a directory, get the value after the second :, write those to another file and then sort, deduplicate and count them.

This may sound complicated, but it's pretty easy and fast if your are familiar with a shell. To be that efficient with your shell you want it to actually be powerful and not just a plain text input. Also writing cmdline tools is rather easy compared to a usable GUI tool.

[–] smeg@feddit.uk 1 points 1 year ago (2 children)

Genuine question: why not use grep, awk, sed, or any of the other gnu tools that can already do that?

[–] SWW13@lemmy.brief.guru 1 points 11 months ago

That's what I meant, using your shell to run command line tools to solve your issue at hand. And having a powerful shell with e.g. context dependend autocomplete (and a lot more) helps to speed up that task.

[–] colournoun@beehaw.org 1 points 1 year ago (1 children)

You could, but maybe a good shell makes it easier than the external tool. Or maybe you use the shell to effectively combine the inputs and outputs of the other tools.

[–] smeg@feddit.uk 1 points 1 year ago (1 children)

I guess that's convenient if you're only ever on one machine, I prefer commands that work (almost) everywhere!

[–] colournoun@beehaw.org 2 points 1 year ago

Me too. I could never get into nushell or fish because they’re not posix and I don’t need to learn two ways to do something.

[–] eric@lemmy.ca 5 points 1 year ago (1 children)

I liked it when I tried it but I can't quit zsh.

[–] FUsername@feddit.de 2 points 1 year ago* (last edited 1 year ago) (1 children)

...so you're locked in ever since? 🤪 Is it a serious case of Stockholm Syndrome or do you like it?

[–] eric@lemmy.ca 2 points 1 year ago

My workflow works the best in bash/zsh shells. Shells that are too different are too much of a change. I like fish as well. Probably a touch of Stockholm Syndrome too haha

[–] hallettj@beehaw.org 5 points 1 year ago (1 children)

Well I might be hooked. It didn't take me long to reproduce the niceties in Nushell I'm used to from my zsh config. Some of the important parts were setting up zoxide with a key binding for interactive mode, switching on vi key bindings, setting up my starship prompt.

Home Manager is preconfigured for the above integrations which made things easier.

One feature that is missing that I like to use is curly brace expansion to produce multiple arguments. For example,

$ mv *.{jpg,jpeg}

Unless there is a way to do something like this in Nushell that I haven't seen yet?

Something I enjoyed was automating a sequence of steps I've been running a lot lately due to a program that often partially crashes,

def nkill [name_substring] {
  ps | where name =~ $name_substring | each { |p| kill $p.pid; $p }
}

I realized after writing this that I basically recreated killall -r. But it's nice that it was so easy to make a custom command to do a very specific thing. And my version gives me a nice report of exactly what was killed.

Thanks for making this post OP! When I've heard mentions of Nushell I'm the past I think I conflated it with Powershell, and wrote it off as a Windows thing. (Maybe because it's introduced as being "like Powershell".) But now that I see that it's cross-platform I'm enjoying digging into it!

[–] tad_lispy@lemm.ee 2 points 1 year ago (1 children)

One feature that is missing that I like to use is curly brace expansion to produce multiple arguments. For example,

$ mv *.{jpg,jpeg}

Maybe this will work for expansion: https://github.com/nushell/nu_scripts/blob/main/modules/filesystem/expand.nu

It's in the "filesystem" section, but I think it works on any string, not only paths. See the ugly duck example. I didn't try it myself yet.

BTW the nu_scripts goodies are available in Nixpkgs, so since you are using Home Manager, it's easy to integrate. Take a look at my config for starters: https://gitlab.com/tad-lispy/nixos-configuration/-/blob/bb614ae3639a504912db167f5bd7e6651d28f604/tad.nix#L39-47

[–] hallettj@beehaw.org 1 points 1 year ago

Thanks for the tip about nu_scripts, those look handy!

The expand command is nice. I don't see how to use it to my mv command work. But that's not a huge deal.

[–] agressivelyPassive@feddit.de 4 points 1 year ago

NuShella. It's right there.

[–] emptyother@programming.dev 3 points 1 year ago

Powershell for those that don't like powershell. Good. Pwsh need some competition in the object-piping category.

[–] dog@suppo.fi 2 points 1 year ago

Bookmarking this.

[–] TiphaineRupa@feddit.de 2 points 1 year ago

Definitely an interesting project especially for those Linux users that mostly stick to one machine and like to experiment with new features.
For the regular sys admin type of person that needs to jump from one Maschine to another it's probably a little too non-standard and hard to get productive with

[–] Hawk@lemmynsfw.com 1 points 1 year ago

If you want something more Unix like and less PowerShell (but absolutely not POSIX), checkout Elvish.