3 ms·
I'm rebuilding my computer and going through around 15 years of linux improvements in the course of a couple weeks, and this week I'm hunting for bash replaceme
by rendaw 2y ago
I'm rebuilding my computer and going through around 15 years of linux improvements in the course of a couple weeks, and this week I'm hunting for bash replacements (bash won't let me automatically run a command before and after each interactive command I execute, which I want for task completion notifications).
There are a lot of new shells, but despite the overwhelming positivity of each thread here they've each been super incomplete/half baked. FWIW I'm looking for a non-posix de-crufted (no oil shell, no zsh) and lightweight/minimal (no fish) shell.
I haven't tried all of these out significantly (really diving in takes hours if not days) but considering my use cases and thoroughly reading the documentation/field reports:
Elvish seemed really cool but has no async/background task support. Furthermore AFAICT you can't iterate over the output of a process _while_ it's running. There are bugs (can't import edit module), there's TODO all over the docs despite supposedly being mature and stable, etc.
Nushell also has no async/background task support (pueue doesn't count, running in separate process trees has countless implications).
Ion shell sounds great on paper, but it's missing the entire first 2-3 chapters of its documentation. It doesn't seem to have any significant background job control, and seems more like a paper-overing of shellisms than a reinvention.
So xonsh seems like the best remaining competitor. It supports background processes with `Popen`, but I can't find an example for async iterating lines. I see lots of examples that are like, `for x in !(ls)` or `for x in $(whatever).splitlines()` but both of those require the command to finish before executing the loop.
Then I keep seeing reports of Ctrl+C breaking with loops, all the python module and environment dependency management madness (plus cross contamination), excessive slowness when mixing python and commands, etc etc.
I'd like to hear a critical rebuttal of these but I think these new shells are more intellectual curiosity than an actual step up. I'm probably going to give up and go with zsh, which while not an improvement at least it will do what I need I don't have to learn anything new.
One thing I've learned though is that although amazing testimony, being someone's main driver isn't a good enough review. Heck, bash has been my main driver for 15 years and it's _awful_. You learn the pain points and then subconsciously avoid doing anything with it near those points.
- arcanemachiner 2y ago> bash won't let me automatically run a command before and after each interactive command I execute, which I want for task completion notifications I remember seeing some simple CLI program that you could pipe your task into, and it would notify you when the task completed. the names escapes me at the moment.
- rendaw 2y agoI mean I can do `; notify-send done` too, but I forget (when it's most critical)
- deleted 2y ago[deleted]
- isr 2y ago> (bash won't let me automatically run a command before and after each interactive command I execute, which I want for task completion notifications Not to put you off investigating alternative shells (I've spent time with rc shell, xonsh (and tako), and even turned gauche scheme & tcl into a commandline shell), but isn't your bash problem solved by using $PS1 to launch your own functions to do whatever? At least, you can use $PS1 for the "after command" bit. For pre-command, just use a simple 1 letter wrapped script which does whatever, and then exec's the remaining arguments (aka "Bernstein chaining") (unless I've gotten the wrong end of the stick, and am missing what you meant)
- rendaw 2y agoNo, not at all! Yeah I could do that, and it's something I considered, but I feel like working in a shell shouldn't be such an unrelenting hack. FWIW I think every shell _but_ bash supports it, I was just hoping to move to something that's overall nice to use in the process.
- belden 2y agoI wonder if bash-preexec https://github.com/rcaloras/bash-preexec https://github.com/rcaloras/bash-preexec could be used here. Perhaps you could start a timer in a preexec, and stop it in precmd. If the elapsed time is greater than some value, notify-send yourself a message that a long-running command has finished.
- shiomiru 2y agoAnother solution for the pre-command part is "trap 'some command' DEBUG".
- isr 2y agoDidn't know about that. Thanks!
- lloeki 2y ago> bash won't let me automatically run a command before and after each interactive command I execute, which I want for task completion notifications Incorrect. This can be achieved because I've done it ;) It relies on trap DEBUG (preexec) and PROMPT_COMMAND (precmd), but to make this much easier for me I've ported zsh preexec and precmd callback support to bash: https://github.com/lloeki/dotfiles/blob/master/bash/ext https://github.com/lloeki/dotfiles/blob/master/bash/ext Then with those callbacks now available it is quite easy to e.g compute time between command start and command end: https://github.com/lloeki/dotfiles/blob/master/bash/rc https://github.com/lloeki/dotfiles/blob/master/bash/rc (The time thing is commented out because I don't need it right now, I used it to display command exec time on the prompt. Note that bash EPOCHREALTIME has second-level precision) And from there notifying completion of commands that run longer than X is absolutely trivial. Other things I've "backported": - chpwd callback - the %\n thing on lack of newline in command output - PROMPT and RPROMPT - zprompt colors
- ratorx 2y agoI’m curious what metric you’re evaluating minimality with? Naively I’d expect Fish to seem more minimal than something like xonsh (which embeds the entirety of Python).
- pmarreck 2y ago> all the python module and environment dependency management madness (plus cross contamination) this was a complete python non-starter for me as soon as I encountered it a couple of times, and it mystifies me how others tolerate this crap