8 ms·
Elvish – Scripting language and interactive shell
- baobun 1y agoAnyone here using elvish on the regular? Anecdotes please!
- sidkshatriya 1y agoI don't use Elvish daily (I use fish) but writing scripts in Elvish is a great experience. The elvish executable can serve as an LSP server and that makes writing Elvish scripts a bit easier. I don't care much for the Elvish shell experience, rather I like the Elvish scripting language. The documentation is top notch and the language evolves slowly and feels stable.
- einpoklum 1y ago> I don't care much for the Elvish shell experience, rather I like the Elvish scripting language. It's a shell, aren't those two things supposed to be the same basically? Or - do you mean the interaction with the terminal/command-line?
- sidkshatriya 1y agoThe shell prompt is also a small interface. How your shell responds to tab autocomplete, provides suggestions etc. can be quite helpful. Here I just like the way fish suggests filenames, provides an underline for filenames that exist and so on. The language is what you write in an $EDITOR. Here Elvish scripts can be nice, succinct and powerful. I like how I don't have to worry about strange "bashisms" like argument quoting etc. Everything feels consistent.
- deleted 1y ago[deleted]
- IshKebab 1y agoLooks nice. Obviously way better than Bash, but there are a few options that are way better than Bash, so I feel like it should spend some time convincing me why I should use this over e.g. Nushell. Anyone have any experience of both?
- sidkshatriya 1y agonushell vs Elvish The Nushell and Elvish scripting languages are similar in many ways. I personally find the "shell" experience better in Nushell than Elvish. Nushell - Bigger community and more contributors - Bigger feature set than Elvish - Built in Rust (Yay :-)! ) Elvish - Mostly developed by one person - Built in golang - Amazing documentation and general attention to detail - Less features than Nushell - Feels more stable, polished, complete than Nushell. Your script written today more likely to work unaltered in Elvish a year down the line. However this is an impression. Nushell must have settled down since I last looked at it. For "one off" scripts I prefer Elvish. I would recommend both projects. They are excellent. Elvish feels less ambitious which is precisely why I like it to write scripts. It does fewer things and I think does them better. Nushell feels like what a future scripting language and shell might be. It feels more futuristic than Elvish. But as mentioned earlier both languages have a lot of similarities.
- graemep 1y ago> Built in Rust > Built in golang Does that matter? If you intend to be a contributor, of course the chosen language matters, but only a very small proportion of users will be contributors.
- dijit 1y agoThere are quirks specific to languages. Rust tends to be marginally faster and compile to smaller binaries. Go projects tend to hit maturity faster and develop quicker. Its a relevant factor to quickly stereotype certain characteristics of development, but its not anywhere close to important.
- IshKebab 1y ago
- atiq-ca 1y agoLooks interesting! Does it have OOP features kinda like how powershell has that?
- photonthug 1y agoWhile removing weird stuff from daily bash annoyances is interesting, I'm not necessarily looking to replace that with brand new but also pretty random weird stuff. Adding new rules isn't the same as adding structure. The documentation is also frequently strange in a way that makes it hard to digest. From https://elv.sh/learn/first-commands.html#external-commands https://elv.sh/learn/first-commands.html#external-commands > While Elvish provides a lot of useful functionalities as builtin commands, it can’t do everything. This is where external commands come in, which are separate programs installed on your machine. Many useful programs come in the form of external commands, and there is no limit on what they can do. Here are just a few examples: Git provides the git command to manage code repositories At first I thought, wait, is this a shell or not, do I have to write code or something to get access to normal external commands? But no, this is more like going to a car dealership and having the salesman say "Hey thanks for coming by, a car is a mechanical device consisting of metal parts and rubber parts for the purpose of taking you where you need to go! Now that we're on the same page about that, money is a thing made of paper for the purposes of .." Docs are hard, once or twice is fine, but lots of parts are like this and I gave up reading. Not sure if it's AI generated, but if the project is doing that then it should stop, and if it's not doing that it should consider starting to
- nneonneo 1y agoI mean, you are literally reading the first chapter of the tutorial for beginners (“Beginner's Guide to Elvish is for you if you haven’t used shells a lot or want to brush up on the basics”). They have a separate set of docs for people who do have some experience with other shells (https://elv.sh/learn/ https://elv.sh/learn/); you may find the quick tour more suitable for your speed: https://elv.sh/learn/tour.html https://elv.sh/learn/tour.html
- photonthug 1y agoI did browse around, that's the page I got the first part of my comment from. Modules are one example of something that sounds probably good (https://elv.sh/ref/language.html#modules https://elv.sh/ref/language.html#modules ). Good stuff is really weakened though by the many random changes that seem to go from arbitrary to.. also arbitrary, while destroying any chance of readability, backwards compatibility, or interoperability. Why? > Line continuation in Elvish uses ^ instead of \ > Bash: echo .[ch] vs Elvish: echo .?[set:ch] One more example, guess what this does: `echo &sep=',' foo bar`. Is it bash, elvish? Some combination of the two with markdown? Legal in all three? Elvish certainly cleans up conditionals and stuff, but you probably shouldn't introduce new things with exactly the same name unless you've created a genuine superset/dialect where the older version still works without rewrite. Namespace it as elvish.echo or use your module system. Shadows aren't friendly, this is equivalent to the guy that monkey-patches sys.stderr=sys.stdout to work around their one-off problem
- rendaw 1y agoI went down this route based on HN recommendations, with some people calling it stable well documented. There's TODOs all over the documentation! There's no background task tools for scripting, and in interactive use background tasks are barely supported - an issue about background tasks has people going roughly "nobody needs to do tasks in parallel, that was only important when people were working on mainframes". The shell hooks have (undocumented) weird restrictions. Lazy iteration of lists is only supported by using functions with callbacks. Stable = development appears stopped. This is half baked and dead. For my new computer I really really wanted a lightweight new shell with orthogonal syntax thought out from the ground up and not glued together over 4 decades, and this seemed like the closest option! But this isn't it.
- nerdponx 1y agoThe big one for me is no string interpolation, as a deliberate design choice.
- em-bee 1y agowhat can string interpolation do that i can't also do by sandwiching a variable between strings: 'string1'$var'string2'? string interpolation is useful where concatenating strings requires an operator, but i don't see the benefit otherwise. for more complex examples i can use printf, or someone could write a function that does string interpolation. since there is no need to fork, that should not be that expensive
- layer8 1y agoI mostly agree, but in Bash for example "string1${var}string2" guarantees to be a single argument, which 'string1'$var'string2' doesn‘t (when $var contains whitespace). So it entails certain other language design choices.
- em-bee 1y agoin bash yes, so that makes sense. thanks for pointing that out. in elvish $var is guaranteed to remain one string, and so 'string1'$var'string2' is always going to remain one argument too.
- account-5 1y agoEver since I 'discovered' Nushell I've noticed a lot of new shells appearing on HN. The thing I like about Nushell is it does away with some of the things that I found hard with bash, and made data formats a first class citizen (something I enjoyed about powershell). I think if you like Lisp elvish would be ideal but for me the lack (seeming, I've not done a deep dive on the docs) of built-in data parsing is a no.
- srott 1y agoElvish was a bit slow to me, nush is nice but I found out I can do most of the tasks using yq and jc more intuitively.
- linsomniac 1y agoI've been eyeing a "better shell" for a while, but I've just decided that a couple zsh plugins and I'm probably happiest. As the meme says "Change my mind". I've been using fish for the last year or more, and I like some of the "batteries included", particularly the predicting of the command you want to run. But fish is too much like bash in syntax, meaning that I just think of it like bash until I have to type "(foo)" instead of "$(foo)", or "end" instead of "fi". The zsh plugins for doing command predicting and fancy prompt seems to get me all the fish benefits with none of the rough spots. And, frankly, the changes fish does doesn't seem to have any benefit (what is the benefit of "end" over "fi"). Even xonsh (I'm a huge Python fan) doesn't really have enough pull for me to stick in it. Oils, nu, elvish, they all have some benefits for scripting, but I can't see myself switching to them for interactive use. It's kind of feeling like zsh is "good enough" with no real downsides. Maybe this is mostly that I've been using sh/ksh/bash/zsh for 40 years, some of these other shells might be easier to switch to if you lack the muscle memory?
- 3PS 1y ago> But fish is too much like bash in syntax, meaning that I just think of it like bash until I have to type "(foo)" instead of "$(foo)", or "end" instead of "fi" Note that fish does also support bash's "$(foo)" syntax and has for a few years now.
- linsomniac 1y agoOoh, good to know!
- em-bee 1y agosupporting more and more bashisms is what makes fish less attractive for me. i used fish for years. $(foo) in bash forks a subshell. in fish it doesn't. i am not a fan of supporting different syntaxes to do the same thing. if they had implemented $() to fork a subshell, that might have made some sense, but otherwise it is just redundant. learning to use () instead of $() or `` really isn't hard. so why?
- 1y ago
- Arcuru 1y agoI've been using fish for many years now though I keep trying all these new shells. Ultimately I've found that for my interactive shell I just want something widely supported and with easy syntax for `if` and `for` loops for short multi-line commands. For anything longer than that I just reach for real Python using either the `sh` or `plumbum` package. I don't need the extra features very often, so I just run things in full Python where I'm already comfortable. I've tried oils/ysh, elvish, xonsh, nushell, and while they are _fine_ I don't want to learn a different language that's not quite Python and not quite shell.
- xk3 1y agoI'm also a fish fan and largely agree--but if you are forced to use Windows and you don't care for WSL, nushell is likely your best option. It's pretty good! Almost feels like Unix but you're in Windows. I don't think fish shell will be ported over to Windows anytime soon...
- dang 1y agoRelated. Others? Elvish, expressive programming language and a versatile interactive shell - https://news.ycombinator.com/item?id=40316010 https://news.ycombinator.com/item?id=40316010 - May 2024 (114 comments) Elvish Scripting Case Studies - https://news.ycombinator.com/item?id=39549902 https://news.ycombinator.com/item?id=39549902 - Feb 2024 (1 comment) Elvish is a friendly interactive shell and an expressive programming language - https://news.ycombinator.com/item?id=24422491 https://news.ycombinator.com/item?id=24422491 - Sept 2020 (49 comments) Elvish: a shell with some unique semantics - https://news.ycombinator.com/item?id=17987258 https://news.ycombinator.com/item?id=17987258 - Sept 2018 (1 comment) Elvish 0.11 released - https://news.ycombinator.com/item?id=16174559 https://news.ycombinator.com/item?id=16174559 - Jan 2018 (1 comment) Elvish: friendly and expressive shell for Linux, macOS and BSDs - https://news.ycombinator.com/item?id=14698187 https://news.ycombinator.com/item?id=14698187 - July 2017 (86 comments) Elvish – An experimental Unix shell in Go - https://news.ycombinator.com/item?id=8090534 https://news.ycombinator.com/item?id=8090534 - July 2014 (75 comments)
- gatane 1y agoI just use rc shell from Plan9 (ported to Linux[1]) nowadays, it is more simple than bash and whatever other shell there is out there. You want functions? For loops? Lists? They got them. [1] https://github.com/rakitzis/rc https://github.com/rakitzis/rc
- xiaq 1y agoElvish author here, seems like I missed the annual posting of Elvish to HN this time :)
- TrnsltLife 1y agoHere I was hoping for a scripting language in Sindarin or Quenya. So disappointed.
- gxonatano 1y agoAfter getting frustrated with how unusual and convoluted BASH syntax tends to be, especially with involved scripts, I've tried almost all of the alternative shells: Elvish, Fish, Oil, Xonsh (Python!), Emacs's eshell, and even the Haskell-based shell repls like Turtle and Shelly. The only one I really stuck with was Nushell. It's friendly, pretty, intuitive, easy to read, heavy on pipes, and super powerful for data analysis. Plus it's modern replacement for a lot of tools, like `ls`, `jq`, `curl`, and so on. Writing a little command-line program is a joy in Nushell.