
Elvish: friendly and expressive shell for Linux, macOS and BSDs - ingve
https://elvish.io/
======
TheAceOfHearts
This looks really neat. There's way too little experimentation happening in
shells. Most shells are a few decades old, and they provide incredibly poor
defaults and tooling.

For example, since I'm prone to making stupid mistakes, I always use a linter.
But as far as I know, there weren't any well known options for linting until
ShellCheck [0].

Personally, I've been using fish for a while now and I'm generally happy with
it. It has great defaults, so I rarely have to tweak anything. Hacking
together small scripts is easy, leaving very little room for error.

If I have to do anything event remotely tricky, I use node with shelljs [1].
Now that async functions are available, it results in some pretty clean
scripts. And although I haven't tried it yet, the pkg [2] tool allows you to
bundle things up into a single binary. That should make certain deployments
incredibly easy.

Circling back to Elvish, one minor detail that immediately stood out to me was
that they create another folder in your home folder. Since I dislike the ever-
growing clutter in my home, I created a GitHub issue asking them to consider
following the XDG base directory spec [3].

[0] [https://www.shellcheck.net](https://www.shellcheck.net)

[1]
[http://documentup.com/shelljs/shelljs](http://documentup.com/shelljs/shelljs)

[2] [https://github.com/zeit/pkg](https://github.com/zeit/pkg)

[3]
[https://github.com/elves/elvish/issues/383](https://github.com/elves/elvish/issues/383)

------
noway421
Their web site is beautiful. Static served over h2 with regional POPs from
cloudflare provides seamless experience between pages, and that's with no
javascript. After first load it caches and literally takes less than a frame
to switch between pages. It feels like an SPA.

~~~
dom0
> It feels like an SPA.

It doesn't feel like any SPA I know.

~~~
mbel
Yeah, it's missing the traditional loading/empty page state just after opening
it.

~~~
dom0
It's also missing the .8 s delay & locking of all inputs after every click as
well as random breakage, broken browser navigation and broken deep linking.

~~~
noway421
It's extra annoying when that .8s lock happens right in the middle of css
animation.

~~~
ddalex
How else can you enjoy the animation uninterrupted?

------
vidarh
I love the structured pipes, but as mentioned in another discussion, replacing
the shell is a big leap for a lot of people. And you can get quite far without
it with tools like "jq". And when I saw this, I just had to tinker a bit to
see what I could do with Ruby, based on the example on the homepage:

    
    
        $ curl -s https://api.github.com/repos/elves/elvish/issues | 
          jr 'each{|issue| puts "#{issue["number"]}: #{issue["title"]}"} ' | head -n 11
    

Or (I expect pitchforks when you see the implementation for this):

    
    
        $ curl -s https://api.github.com/repos/elves/elvish/issues | 
          jr 'puts{"#{$I["number"]}: #{$I["title"]}"}' | head -n 11
    

With "jr" looking like this[1]. Expect this to fall apart in all kinds of ways
- it was just something I threw together. Not convinced the monkey-patched
"puts" is worth it, but it's just an experiment..

[1]
[https://gist.github.com/vidarh/d088d6e342e665f0b6554ec4fbaa5...](https://gist.github.com/vidarh/d088d6e342e665f0b6554ec4fbaa5e53)

~~~
yAnonymous
I use JSON, because it's simple yet powerful. Command line JSON tools seem to
have a very convoluted syntax and that kinda defeats the whole purpose.

~~~
vidarh
I don't think there's a whole lot more we can achieve beyond what you see
there... I mean, I guess you could dynamically assign global variables based
on the keys, and enforce treating them as strings, so you could reduce it to

    
    
        jr 'puts{$number+": "+$title}'
    

E.g by changing the "each" in my example with:

    
    
        def each &block;
          $J.each do |i|
            $I = i;
            i.keys.each {|k| eval("$#{k} = $I[k].to_s")}
            block.call(i)
          end
        end
    

Though this is error prone - e.g. if the key collides with any pre-defined
Ruby globals like $stdin... Would probably be worth using a prefix etc.. This
is the downside to using a general purpose language for stuff like this
instead of a specialised tool like jq which can ignore other syntax concerns..

------
symlinkk
> Pipelines in Elvish can carry structured data, not just text. You can stream
> lists, maps and even functions through the pipeline.

Sounds like Powershell.

~~~
throwanem
Looks a bit like it, too, if only in that regard.

No criticism, though. Powershell is brilliant, and I'm glad to see the Unix
world starting to take cues from it.

~~~
mwj
"Powershell is brilliant"

Wot?

Ugly syntax, cryptic error messages and random idiosyncrasies like misplaced
semicolons turning variables into lists... The language is a nightmare.

~~~
coldtea
> _Ugly syntax, cryptic error messages and random idiosyncrasies_

Yeah, nothing like the elegance, straightforward messages, and "no surprises"
of POSIX shells...

~~~
Kurtz79
It might be me succumbing to stereotypes, but POSIX shell syntax feels
something that grew organically, out of use and necessity, with basic guiding
principles but no set guidelines or rules.

Powershell feels like something designed by committee, it has an internal
consistency and logic, but feels bloated and overcomplicated.

~~~
bluesign
Consistency and logic comes with a price. But i guess both approches have cons
and pros.

~~~
coldtea
The best way I think is: start with either, and prune what has been shown not
to work in a version n+1 every few years iteratively.

Provide a good migration path (e.g. for a language that could be a n to n+1
transpiler), and you're set.

------
shellbackground
My super-quick checklist for new shells consist of only one point: does it
decently support background tasks?

It seems that none of recently emerged shells had that point in their design:

\- elvish: no
([https://github.com/elves/elvish/issues/193](https://github.com/elves/elvish/issues/193)).

\- xonsh: no
([https://github.com/xonsh/xonsh/issues/1959](https://github.com/xonsh/xonsh/issues/1959)).

\- fish: no ([https://github.com/fish-shell/fish-
shell/issues/238](https://github.com/fish-shell/fish-shell/issues/238)).

------
microcolonel
The shell _I 've_ really been looking for is basically fish-but-bash. All the
feedback and usability of fish, with bash compatible syntax. Bash's syntax may
be a lecherous growth upon a lecherous growth, but at least it's a familiar
leech.

~~~
georgyo
Have you tried zsh with oh-my-zsh?

~~~
myhf
Does that have anything like syntax highlighting or dim text typeahead
suggestions and completions?

[https://fishshell.com/assets/img/screenshots/autosuggestion....](https://fishshell.com/assets/img/screenshots/autosuggestion.png)

~~~
linopolus
Sure

~~~
myhf
I see. Apparently those are in zsh-users, not oh-my-zsh.

[https://github.com/zsh-users/zsh-autosuggestions](https://github.com/zsh-
users/zsh-autosuggestions)

[https://github.com/zsh-users/zsh-syntax-highlighting](https://github.com/zsh-
users/zsh-syntax-highlighting)

~~~
floatboth
And history search [https://github.com/zsh-users/zsh-history-substring-
search](https://github.com/zsh-users/zsh-history-substring-search)

oh-my-zsh is an unnecessary "config framework" that includes all the things
already.

~~~
linopolus
Amen. The only thing oh-my-zsh adds is convenience, which is bought with awful
performance. Even without any plugins activated, startup time of the oh-my-zsh
--zsh takes forever. Better use a homegrown .zshrc, with a simple plugin
manager like antibody[1].

[1]: [http://getantibody.github.io/](http://getantibody.github.io/)

------
voltagex_
Is there anything that implements the file browsing for bash or zsh?

Edit: [https://github.com/chadj2/bash-ui](https://github.com/chadj2/bash-ui)

~~~
fdw
You might like [ranger]. Also similar to the history feature are [autojump]
and [fzf]

[ranger]: [http://ranger.nongnu.org/](http://ranger.nongnu.org/) [autojump]:
[https://github.com/wting/autojump](https://github.com/wting/autojump) [fzf]:
[https://github.com/junegunn/fzf](https://github.com/junegunn/fzf)

------
hossbeast
"Elvish has no concept of exit status. Instead, it has exceptions that, when
thrown, interrupt the flow of execution." ... "Non-zero exit status from
external commands are turned into exceptions"

You had me up until this point.

~~~
vortico
But think of how useful this would be in a complex-hierarchy shell system.
Some commands might fail when processing in the tree, and you might want to
just remove that one leaf instead of halt further processing of data in
another part of the tree.

------
xiaq
Author here, happy to answer questions. :)

~~~
lostmsu
Plans for Windows port?

~~~
xiaq
There is no plan yet. However, there is a plan to eliminate cgo dependency,
which can facilitate the possible Windows port. Any contribution is welcome!
:)

------
gravypod
> Pipeline is the main tool for function composition. To make pipelines
> suitable for complex data manipulation, Elvish extends them to be able to
> carry structured data (as opposed to just bytes).

Well that is definitely interesting.... Are there any examples? I was writing
a compiler that worked by pipelining different stages to different parts of
the compiler (tokenizer -> parser -> AST) all using unix pipes. I had to stop
and do something productive once I realized I couldn't pipe complex datatypes
easily without a lot of effort to parse the inputs.

I'd love to see an example of this.

~~~
BoorishBears
Sounds a lot like Powershell

~~~
agumonkey
in a way lisp OSes too, they didn't serialize data at all, it was single space
pointer passing (with all the issues it creates)

------
voltagex_
Looks interesting, but it's got some rough edges:
[https://github.com/elves/elvish/issues/364](https://github.com/elves/elvish/issues/364)

------
carapace
Not to be a nay-sayer, but I would use IPython for almost all of the tasks I
saw mentioned in the Elvish docs.

Python was originally developed as a shell language for the Amoeba distributed
operating system. ( [https://docs.python.org/3/faq/general.html#why-was-
python-cr...](https://docs.python.org/3/faq/general.html#why-was-python-
created-in-the-first-place) )

I find with the addition of the IPython "shell magic" I can easily do anything
that doesn't fit e.g. Bash (for my skill level of course.)

------
guftagu
Nice! That file manager looks awesome!

------
partycoder
[https://stedolan.github.io/jq/](https://stedolan.github.io/jq/) is good for
filtering json in a similar manner.

~~~
mifix
A way to get the same output as the first example, would be:

    
    
       curl -s  https://api.github.com/repos/elves/elvish/issues  | jq -r  '.[] | [(.number|tostring), .title] | join(": ")'

------
RoutinePlayer
Was kind of hoping to see "Why the need for yet another shell" at the very top
of the page.

------
caio1982
Do its arithmetic operations use some sort of polish notation or am I missing
something clever here?

~~~
xiaq
It is lisp-like, and I am going to make the old arguments that it is actually
_superior_ because it supports multiple arguments :)

~> \+ 1 7 6 324 234 ▶ 572

------
RoutinePlayer
Was kind of hoping to see "Why the need for another shell" at the top of the
page.

------
Cryptoboss
Has anyone tried this and Fish? How do they compare?

------
Instructor
The way to search history seems cool.

