~yosh@unix.dog

thoughts on yash

posted

a few months ago, I tried out the yash shell. I gave it an honest go. I want to like it--it does so many things so well for a one man project; but there's just a few, very tiny, almost inconsequential hiccups that make it just out of reach for me to want to continue using it.

this article is going to mostly be comparisons to the "standard" shell on most linuxes: bash--what yash does differently, what it does mostly the same, all the like.

The Good

Sane Completion

the completion mechanism for yash is probably the best one I've seen. it's a bit more verbose than bash-completion, but it's much easier to grasp and is much more robust. here's a simple example showing a completion script for doas:

function completion/doas {
    typeset OPTIONS ARGOPT
    OPTIONS=( #>#
        "C:; specify a config file to parse"
        "L; clear any persisted authentications, then exit"
        "n; non-interactive mode, fail if rule doesn't have nopass"
        "s; execute the shell from \$SHELL or /etc/passwd"
        "u:; specify the user to execute the command as"
    ) #<#

    command -f completion//parseoptions
    case $ARGOPT in
    (-)
        command -f completion//completeoptions
        ;;
    (C)
        complete -f
        ;;
    (u)
        complete -u
        ;;
    (*)
        command -f completion//getoperands
        command -f completion//reexecute
        ;;
    esac
}

beautiful! notice how options have descriptions as well, much like zsh. check it out in action:

it's just so nice compared to bash's lack of knowing what you have selected + lack of descriptions + less robustness for command combinations (try getting only -HL until a . and then having the -name appear after all that in bash first…). yash's could use a little color, but other than that it's really nice.

Sane Defaults

another thing I love about yash is that the defaults are actually sane unlike bash's. a color prompt, completions, the whole 10 yards right from the get-go. it gives you a nice message saying that these defaults are copied from its in-house initialization script that you should copy to ~/.yashrc if you want to change stuff. I was an idiot and made my own bare ~/.yashrc, which caused job control and utf-8 pasting to break. I guess it uses that initialization script for a good "modern" machine default, but has the option to be barebones for older machines and/or compatibility, which is neat.

Command Prediction

I like command prediction. I get that it's kinda the same as searching for the last used command using only the first letters, but I still enjoy the fact that I don't have to switch modes back and forth. I can just start typing the command, press ctrl+e to go to the end of the predicted line, and we're good. guess i should internalize searching for a recently used thing again now

<( )

since I'm a posix shell guy, I rarely find myself using the <( ) syntax, but every now and then I give it use. the thing is, I hate how you have to have the double < like < <(thing). it just doesn't feel intuitive to me, even though I know exactly what it's doing. in yash, however, you just need the <(thing), and it works how you'd expect. mwah. perfect

The Eh

again, I never really had any major gripes with yash, which is why this section isn't titled "the bad". all of these are minor gripes that kinda just drag on each time I worked around them again, culminating in me switching back to bash

Less Input Handling Flexibility

since yash uses its in-house line editing, the benefits (and sometimes drawbacks) of readline or libedit are lost in the shell. most of these are obscure features that don't really mean all too much and/or have in-house alternatives, but a few really got on to me.

the first is the lack of case-insensitive completion. sure, I could rename a bunch of my files to be lowercase, but I rely on caps for categorization purposes--especially prevalent in my music folder--which makes completion really annoying when I type out the first letters, press tab, realize that I didn't make it caps, then fix it before pressing tab to complete again.

the second is the lack of visual indicator for vi-mode. for readline, I set…

set vi-ins-mode-string " "
set vi-cmd-mode-string ":"

this doesn't have an equivalent for yash, which sometimes trips me up when I tab out and back and forget I'm in command mode. again, not too bad, but then I press v and get a vi jumpscare

another thing that threw me off is the inability to rebind keys for vi-search mode, and since there's no default next/back keybind for vi-search, you can only retrieve the first/last thing it finds. for readline, I can use ctrl+n and ctrl+p to go next and back for searching respectively, which I just can't do for yash

History Drawbacks

yash has one singular global history that spans across all sessions. each session queries the history file and writes it sequentially upon a newline. this makes two minor problems pop up:

neither of these I particularly enjoy, which made it frustrating to truly use recent commands that I wanted to reuse

The Same

most of yash's -isms is pretty similar to bash. it actually incorperates quite a lot of bashisms to make scripts relatively compatible--though there are a few breaking differences--which I think is really nice

Conclusion

all in all, for being a mostly one-man project, yash is crazy good. it's a posix-compliant shell with sane defaults and a few modern features. there's just a few very minor hitches that dragged on me as time went on. maybe this blog post will be helpful in maturing it just ever so slightly more to make it a truly great shell

if this blog post interests you, then please do check it out. maybe you'll find those minor hitches something that won't drag on you

back