Live data from Hacker News

Yash: Yet Another Shell

github.com

31–40 of 54 posts

Re: Yash: Yet Another Shell

#31
post #16

I kind of wish there was a shell that had the option for histories localized to a directory. So I can go into a directory and then look at what I was doing when I was last in that directory. Some complicated compilation command line to compile and link a source file and a bunch of libraries that was run when I was last in that directory, for example. There'd still be the 'history' command for everything and then mayb…

You can do this with a zsh plugin: https://github.com/jimhester/per-directory-history

This looks promising, thanks!

Re: Yash: Yet Another Shell

#32

Earlier quoted context omitted.

When I first switched to nushell as my daily driver, I spent a lot of time integrating fzf in various creative ways, which was a fine learning exercise I guess. But once I realized that the auto complete was sensitive to my cwd, I've since been using my fzf bindings less and less. I'm very happy I made the switch, for this and many other reasons.

What’s it give you that is significant?

I bet yash is great, sorry for distracting from the topic, but since you asked...

It's not one killer feature, but it's a lot of small things that add up to this feeling that POSIX shells are stuck in a rut and that a better world is possible.

I'm going to use docker output as an example. I know that you can ask docker for json and then use jq, but let's pretend that what you're working with isn't so friendly as docker. Here's the output of "docker ps", a string:

    CONTAINER ID   IMAGE            COMMAND                  CREATED       STATUS       PORTS                   
    786fc8348b7a   postgres:12.6    "docker-entrypoint.s…"   9 hours ago   Up 9 hours   127.0.0.1:5432->5432/tcp
I'm not proud of it, but I used to write bash scripts which looked like this:

    line=$(docker ps | grep postgres)
    echo $line | awk '{print $2}'
    echo $line | awk -F 'ago' '{print $2}' | sed 's/hours.*/hours/'
to get output like this

    postgres:12.6
    Up 9 hours
In nushell, that's this (notice that it gets the whitespace right, which is more than I can say for awk).

     $ docker ps | detect columns --guess | where ($it.IMAGE =~ postgres) | select IMAGE STATUS

    ╭───┬───────────────┬────────────╮
    │ # │     IMAGE     │   STATUS   │
    ├───┼───────────────┼────────────┤
    │ 0 │ postgres:12.6 │ Up 9 hours │
    ╰───┴───────────────┴────────────╯
This the part where somebody says "powershell does that too", but check out this stackoverflow post on just how that might be done: https://stackoverflow.com/questions/47335781/extract-columns... It's not exactly wow material.

Powershell feels to me like it's made by people who want all data to be structured, and who expect the app to do the work of structuring it for them. nushell feels like it's made by people who understand that text is king, and who are willing to attempt taming that beast as-is.

Plus there are a lot of batteries-included things that just feel nicer. Like if you want to make an http post request, the command is "http post". Of course you can still use curl, but I feel like this is so much more readable:

      $ let token = "REDACTED"
      ( http post
          -H {Circle-Token : $token}
          --content-type application/json
          "https://circleci.com/api/v2/project/gh/job/myproject/pipeline"
          {  branch: "main",  parameters:  { action: "dothething" }}
      )
The built in help is excellent (try "help http post"), and the error messages are very pleasant:

    $ 5 + "5"

    Error: nu::parser::unsupported_operation
    × addition is not supported between int and string.
       ╭─[entry #208:1:1]
     1 │ 5 + "5"
       · ┬ ┬ ─┬─
       · │ │  ╰── string
       · │ ╰── doesn't support these values
       · ╰── int
       ╰────
I dunno, it's just nice. I'd be much happier teaching a bunch of scientists to use nushell than I am when teaching them to use bash. When I try to do the latter I feel like I just stepped out of a time warp from the 60's and they think I'm here to punish them.

Re: Yash: Yet Another Shell

#33
post #21

I kind of wish there was a shell that had the option for histories localized to a directory. So I can go into a directory and then look at what I was doing when I was last in that directory. Some complicated compilation command line to compile and link a source file and a bunch of libraries that was run when I was last in that directory, for example. There'd still be the 'history' command for everything and then mayb…

I kind of wish there was a project-oriented complete desktop environment, where you could enter a project and everything was context-sensitive to it. editor, files, directories, shell, browser, whatever. sort of a way to work on projects, then put them on old. and maybe meta-projects to choose, track, arrange, manage some or all projects. maybe by area of responsibility.

KDE Plasma had Activities that came close to this i think:

https://www.howtogeek.com/be-more-productive-in-linux-with-k...

Initially it seemed useful but it quickly felt like more of a chore. At work it's mostly just the same one IDE and one browser. For personal stuff I either used a different user account/different laptop and there was little benefit of activities for me after that.

Re: Yash: Yet Another Shell

#34
post #21

I kind of wish there was a shell that had the option for histories localized to a directory. So I can go into a directory and then look at what I was doing when I was last in that directory. Some complicated compilation command line to compile and link a source file and a bunch of libraries that was run when I was last in that directory, for example. There'd still be the 'history' command for everything and then mayb…

I kind of wish there was a project-oriented complete desktop environment, where you could enter a project and everything was context-sensitive to it. editor, files, directories, shell, browser, whatever. sort of a way to work on projects, then put them on old. and maybe meta-projects to choose, track, arrange, manage some or all projects. maybe by area of responsibility.

I'm not a fan of Docker, but Docker could do this.

If that's not enough, there's always whole VMs.

Re: Yash: Yet Another Shell

#35

I kind of wish there was a shell that had the option for histories localized to a directory. So I can go into a directory and then look at what I was doing when I was last in that directory. Some complicated compilation command line to compile and link a source file and a bunch of libraries that was run when I was last in that directory, for example. There'd still be the 'history' command for everything and then mayb…

This is a great idea. Just better history management in general would be such a boon. If I have multiple console windows open, I still don't know what will wind up in .bash_history, and what (which?) history will be there when I start a new one.

Re: Yash: Yet Another Shell

#36

Earlier quoted context omitted.

What’s it give you that is significant?

I bet yash is great, sorry for distracting from the topic, but since you asked... It's not one killer feature, but it's a lot of small things that add up to this feeling that POSIX shells are stuck in a rut and that a better world is possible. I'm going to use docker output as an example. I know that you can ask docker for json and then use jq, but let's pretend that what you're working with isn't so friendly as dock…

That "detect columns" piping stuff looks very nice, though it looks like this is something that could be implemented extrashellularly (as discrete "detect" and "where" binaries)?

Re: Yash: Yet Another Shell

#37

I kind of wish there was a shell that had the option for histories localized to a directory. So I can go into a directory and then look at what I was doing when I was last in that directory. Some complicated compilation command line to compile and link a source file and a bunch of libraries that was run when I was last in that directory, for example. There'd still be the 'history' command for everything and then mayb…

FYI The fish shell does this by default.

Re: Yash: Yet Another Shell

#38
post #37

I kind of wish there was a shell that had the option for histories localized to a directory. So I can go into a directory and then look at what I was doing when I was last in that directory. Some complicated compilation command line to compile and link a source file and a bunch of libraries that was run when I was last in that directory, for example. There'd still be the 'history' command for everything and then mayb…

FYI The fish shell does this by default.

But it's not a POSIX shell

Re: Yash: Yet Another Shell

#39
post #21

I kind of wish there was a shell that had the option for histories localized to a directory. So I can go into a directory and then look at what I was doing when I was last in that directory. Some complicated compilation command line to compile and link a source file and a bunch of libraries that was run when I was last in that directory, for example. There'd still be the 'history' command for everything and then mayb…

I kind of wish there was a project-oriented complete desktop environment, where you could enter a project and everything was context-sensitive to it. editor, files, directories, shell, browser, whatever. sort of a way to work on projects, then put them on old. and maybe meta-projects to choose, track, arrange, manage some or all projects. maybe by area of responsibility.

nix and direnv might be worth a look.

Re: Yash: Yet Another Shell

#40

I kind of wish there was a shell that had the option for histories localized to a directory. So I can go into a directory and then look at what I was doing when I was last in that directory. Some complicated compilation command line to compile and link a source file and a bunch of libraries that was run when I was last in that directory, for example. There'd still be the 'history' command for everything and then mayb…

It is possible to implement, however.
Post reply on HN