5 ms·
Show HN: A smarter Unix shell and scripting environment
- ape4 3y agoSome good ideas there. I wonder if the autocomplete for `kill` could be scripted for other shells.
- n8henrie 3y agoIf you're an fzf user, its integration for `kill *<tab>` has been a game changer.
- DiabloD3 3y agotbf, thats an existing bash-complete-ism, fzf.bash just makes it cooler.
- Rediscover 3y agoMy own, personal, use-case is to completely nuke `bash-complet*` off my machine. To me, bash-completion is horrible. I am looking for a tarball to unwind, and I only remember that it it started with "foo-" and it sure did not end in ".tar" (trying to save keystrokes, y'know). Trying C-i does not pull up anything. Argghh. I am on a machine with bash-completion! --- I often hit C-a then "a" to get an invalid command (still saved to my hist), or C-a C-k if I think there is nothing else going into the kill-ring. bash-completion absolutely messes with me. If it works for You, that is great. I really dislike it.
- n8henrie 3y agoHuh, I had no idea. Just `kill <tab>` then? Will give it a shot next time I'm ak.
- DiabloD3 3y ago`kill <tab>` will list all pids, `killall <tab>` lists every process name. fzf.bash just turns `kill` into `ps (args) | fzf`, and does not yet have an equivalent for `killall`.
- zeroonetwothree 3y agoI’m just curious why you need to kill stuff so often. I think I probably do it once a month at most.
- bee_rider 3y agoNot the person you responded to, but I probably kill an octave or matlab terminal daily. Oops, it turns out this matrix is too big to solve directly. Oops, norm2 takes forever and norm1 would have been good enough.
- hnlmorg 3y agoI suspect they're talking about fzf in general, using `kill` as an example, rather than saying they `kill` stuff often. But I could have misinterpreted their comment.
- n8henrie 3y agoI didn't mean to imply that I use it "so often," just that it makes it much easier when I do. I have to `kill -9` neovim once or twice per week due to <https://neovim.discourse.group/t/how-to-debug-intermittent-neovim-freezes/2225 https://neovim.discourse.group/t/how-to-debug-intermittent-n...>, that's probably the most frequent culprit. I really need to compile a debug version and help get that sorted.
- arp242 3y agozsh has completion for kill, pkill, etc. out of the box. The default for kill is to only shown processes from the current pty, but you can change that with something like: zstyle ':completion:*:*:kill:*:processes' command 'ps xo pid,user:10,cmd' I also filter some processes that I almost never want to kill to clean it a bit up: zstyle ':completion:*:*:kill:*:processes' command 'ps xo pid,user:10,cmd | grep -Ev "(ps xo|firefox|/bin/zsh|-zsh|runsv)"' As with most things in zsh, you can make it as fancy as you want, but this is enough for me. zsh is really powerful, but the downside is that a lot of these things have a bit of a "magic incantation factor" unless you're pretty familiar with zsh scripting. I guess this is why people use oh-my-zsh and things like that.
- sureglymop 3y agoThe main issue I always have is that as soon as I have to use another system or ssh into another system I lose all of that.
- arp242 3y agoCan't have it all I'm afraid. For this reason I keep my zshrc contained to one file so I can easily move it around, but it does require zsh to be available in the first place of course. All things considered, I'd rather optimize for the 99% of the time I'm on my local machine than the 1% I'm on a remote machine.
- ComputerGuru 3y agoFish autocompletes kill, fg, bg, killall, etc out-of-the-box already.
- SushiHippie 3y agoReminds me somewhat of nushell[0]. It's mindblowing what's possible with it. It makes the oneliners you normally write more readable, but I'm still using a "normal" shell (zsh) as I can't use these everywhere I want, compared to most of the oneliners that only depend on coreutils and can be run on any gnu/linux system. If I'd need to install another tool to take my scripts with me, I'll probably would just use another scripting language like Python. [0] https://www.nushell.sh/ https://www.nushell.sh/
- hnlmorg 3y agoNushell is pretty awesome but the one problem with Nushell is it requires commands to "speak" nushell for it's magic to work. Take the example on the landing page with `ls`. `ls` is actually a nushell builtin rather than GNU / BSD / whatever coreutils: https://www.nushell.sh/commands/docs/ls.html https://www.nushell.sh/commands/docs/ls.html Whereas Murex colours pipelines with type annotations so that it can perform it's magic with your existing system's coreutils. That's not to say that Nushell's approach is wrong. It's a popular approach used by a few alt shells, including PowerShell. But it does come with trade offs: 1. your coreutil muscle memory needs to remember whether you're in Nushell or Zsh (eg `ls` flags will differ depending on your shell) 2. the developers of Nushell need to re-implement coreutils to expose the genius of their shell. And as we've seen on here before, developing and maintaining coreutils is far from a trivial task 3. any other CLI tools that people might use that might not be common might also not support Nushells magic These problems doesn't exist for Murex because it is basically an abstraction on top of POSIX. To be clear though, I'm not making a criticism about Nushell. Murex has it's own problems and trade offs as well. So please take this comment only as a description of where our approaches have differed (I think it is great that there are numerous options these days).
- michaelcampbell 3y ago> `ls` flags will differ depending on your shell This just sounds like a non-starter for me. I'm already irritated by having to deal with both BSD and AT&T flavors. But, to each their own.
- pulkas 3y agoYou are not in here : https://github.com/alebcay/awesome-shell https://github.com/alebcay/awesome-shell
- Cthulhu_ 3y agoDid you submit a PR?
- thunderbong 3y agoShow HN is for sharing your personal work HN FAQ: https://news.ycombinator.com/newsfaq.html https://news.ycombinator.com/newsfaq.html
- hnlmorg 3y agoThis is my personal work
- oaiey 3y agoApart of the .NET/Microsoft/ugly command-lets situation, how do you pitch yourself against PowerShell? The typed pipelines and advanced programming are also there. Not that I am a personal Powershell fan (in-memory commands and ugly commands is the ugly part for me), but "next-gen" shells with typed streams are not exactly the novelty.
- hnlmorg 3y agoMurex is an abstraction on top of POSIX rather than a replacement for POSIX and coreutils et al. Which means Murex works with all your existing CLI tools without you having to worry altering your muscle memory. If people are already using and like Powershell then I'd recommend they stick with Powershell. But if anyone is using Bash, Zsh or Fish (for example) but longed for something a little more intuitive (fewer footguns, smarter handling of structural data, etc) then Murex is a good option. It's also worth noting that I've modelled the interactive shell on IDEs rather than readline. So the UX in Murex is, in my biased opinion, one of the best out there. However I'm always open to feedback on anything that can be improved in that department. Or in fact, anything regarding the shell.
- oaiey 3y agoDid not realize that POSIX after it was obsolete standardized commands ;) anyway. But I get you. PowerShell is intended to harmonize server management and yours is a general purpose shell. Sounds like a very reasonable differentiation. Do you write articles about how you make coreutils output structured? Is that a command specific adapter or how does that work?
- hnlmorg 3y ago> Did not realize that POSIX after it was obsolete standardized commands ;) anyway. POSIX does standardise some commands[0], albeit not many and good few of them are implemented as builtins even in Bash. But it also defines STDOUT (etc) files. The way Powershell passes data is as .NET objects. The way Murex passes data is as POSIX byte streams but with type annotations passed out of band. This creates some extra overhead in serialising data but the advantage is that it works with all of your existing tooling without modification. > Do you write articles about how you make coreutils output structured? Is that a command specific adapter or how does that work? I haven't but that's a good idea. The way it works is just that you add type annotations. The default type is assumed text data, potentially in columns, like you'd see from `ps aux` or `ls -l`. There are also some builtins (eg [1][2]) that are data type aware. So if you just use the most basic features of Murex, you get a few footguns removed (eg by default variables containing spaces don't get split into multiple parameters) and a slightly different syntax to Bash but all the same CLI tools work. However if you want to invest more into Murex then you get greater power from it eg the ability to inline SQL queries[3], write unit tests[4], better error handling[5][6], etc as well as being able to do `jq` like expressions against a multitude of object and table formats. I really do need to get better at publishing it's features though! [0] https://en.wikipedia.org/wiki/File:POSIX_Utilities.pdf https://en.wikipedia.org/wiki/File:POSIX_Utilities.pdf [1] https://murex.rocks/docs/commands/index.html https://murex.rocks/docs/commands/index.html & https://github.com/lmorg/murex/blob/master/examples/table-indexes.mx https://github.com/lmorg/murex/blob/master/examples/table-in... [2] https://murex.rocks/docs/commands/foreach.html https://murex.rocks/docs/commands/foreach.html [3] https://github.com/lmorg/murex/blob/master/examples/inline-sql.mx https://github.com/lmorg/murex/blob/master/examples/inline-s... [4] https://github.com/lmorg/murex/blob/master/config/defaults/profile_all.mx#L344 https://github.com/lmorg/murex/blob/master/config/defaults/p... [5] https://murex.rocks/docs/commands/runmode.html https://murex.rocks/docs/commands/runmode.html [6] https://github.com/lmorg/murex/blob/master/examples/try-catch.mx https://github.com/lmorg/murex/blob/master/examples/try-catc...
- abhibeckert 3y agoWhat is this doing in the first example in the readme? > open https://api.github.com/repos/lmorg/murex/issues https://api.github.com/repos/lmorg/murex/issues As a Mac user, I'd expect that to launch a web browser, but it appears to be downloading and parsing the JSON?
- latexr 3y agoNote how the line ends with a backslash. That is escaping the newline so the command isn’t executing immediately. The next line begins with a pipe which is taking the input. It’s a way of separating multiple piped commands over several lines for readability. In other words, these are equivalent: echo 'Something or other' | sed 's/or/and/' and echo 'Something or other' \ | sed 's/or/and/'
- alexgrover 3y agoI think the point they’re trying to make is that the “open” command does something very different than the Mac builtin
- vram22 3y agoIIRC, in this case, backslashes are not needed. You can just end each partial line of such long commands with a pipe sign and keep writing the rest of the overall command on subsequent lines, except for the last partial line, where you just press Enter to complete and run it.
- hnlmorg 3y agoThere is a Murex builtin with the same name: https://murex.rocks/docs/commands/open.html https://murex.rocks/docs/commands/open.html This naming conflict is actually one of my regrets within Murex. I was a couple of years into development on this shell before I obtained a mac test system. I think most of the Murex users in the early days were also Linux users too. So I wasn't aware of the conflict until there was already too much code written in Murex to be worth the risk renaming the builtin. However can mitigate this by running `exec open ...` -- you can set that as an alias as well, eg alias o=exec open
- kytazo 3y agoThis is outstanding, personally I would immediately switch to it if it was an addon for zsh instead of a standalone new shell. While I'm spending quite some time in my shell and the extend that its a core part of my system is quite considerable and makes switching to another shell altogether a huge time investment. Nonetheless, I'll always keep an eye on promising alternatives and eventually switch over once the functionality missing gets apparent enough on a constant basis as it happened for me when switching from fish to zsh.
- drbaba 3y ago> once the functionality missing gets apparent enough on a constant basis as it happened for me when switching from fish to zsh. As someone that went the other way ~5 years ago, I’m curious what made you switch :). Are you btw on a hand-rolled config or one of the distributions? (For me, it was that I was maintaining a ~400 line zsh config, and then learned that fish did most of the things I had configured “out of the box”. I considered switching back for increased POSIX compatibility since I often write bash scripts at work, but since Fish 3 added POSIX-compatible syntax for most pain points, I haven’t kept up with zsh.)
- e12e 3y agoInteresting project. Is there documentation of the use of backticks as seen in the SQL example? https://github.com/lmorg/murex/blob/master/examples/inline-sql.mx#L5 https://github.com/lmorg/murex/blob/master/examples/inline-s... Doesn't seem to be valid quoting? https://github.com/lmorg/murex/blob/master/docs/tour.md#quoting-strings https://github.com/lmorg/murex/blob/master/docs/tour.md#quot...
- jachee 3y agoSQL itself uses backticks as quotes. That’s my guess at what’s happening in the example.
- nrabulinski 3y agoOn topic of alternative shells: recently I learned about rash[1] and I’ve been absolutely delighted. I really wish it’d gain some traction as the project seems to be moving very slowly (if at all) [1]: https://rash-lang.org https://rash-lang.org
- xiaq 3y agoShameless plug: there's also Elvish (https://elv.sh https://elv.sh) if you're interested in a shell with advanced programming features.
- Night_Thastus 3y agoEvery time I see one of these new shells, I'd like to know - how does it compare against the existing higher-end shells like Fish? What extra features does it have, which are missing, where are the differences? If it offers substantial benefits over Fish, then I'd gladly take a look. As it stands, the description is quite brief and doesn't talk as much about other shells and feature comparison.
- hnlmorg 3y agoI very intentionally kept the README like this because I didn't want to be seen as starting shell flamewars. Plus writing promotional material isn't my strength. Improving this side of things is something that's constantly on my mind though. Plus if anyone else also wanted to contribute then I'd welcome that with open arms.
- sarahdellysse 3y ago> Some individuals, particularly those running Linux, follow a standard called XDG Base Directory Specification. While Murex does not adhere to this standard, instead conforming to the de facto standard defined by the past precedents of previous shells, in order to offer flexibility for those who do prefer the XDG specification Murex does support overriding its own default paths via special environmental variables. no no no you're missing the point: on POSIX systems, go with XDG by default. cmon guys it's 2023 not 2003
- hnlmorg 3y agoMurex doesn't just target POSIX systems and XDG added a lot of edge case problems I wasn't prepared to deal with at the time. Particularly so back when the shell was first created. So I went with the de facto shell standard instead. You can override that behaviour if you want to use XDG but making it the default could break backwards compatibility, result in confusing documentation for non-POSIX users and introduce a lot of additional development and testing just to fix something that already works fine. Like with any open source project, if someone else is willing to commit some time into solving these concerns then I'll gladly merge it. But I need to be pragmatic with how I prioritise my development time.
- two_handfuls 3y agoThis looks great. Say I’m writing a script or Python program, is there a way for it to know that the input has type “json” (and still work if the user didn’t install Murex)?