Live data from Hacker News

Yash: Yet Another Shell

github.com

41–50 of 54 posts

Re: Yash: Yet Another Shell

#41

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…

Box-drawing characters can make output look nice, for sure.

Re: Yash: Yet Another Shell

#42

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…

Tome does exactly that by replacing the history with playbooks

https://github.com/laktak/tome

Re: Yash: Yet Another Shell

#43
post #37

Earlier quoted context omitted.

FYI The fish shell does this by default.

But it's not a POSIX shell

Yes, but it's a shell nevertheless :), and it actually now supports some of the most common bashisms, so simple copy-pasted commands designed for bash now work. For any actual scripting IMO bash (or /bin/sh) is still the better choice, since it's installed everywhere, even though it might not have such great syntax.

Re: Yash: Yet Another Shell

#44

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…

If you are open to using zsh, take a look at https://github.com/larkery/zsh-histdb . It stores your zsh history in a sqlite3 db. The benefit of this is that your history is well-structured and indexed, and that you can use SQL to query it. The working directory, exit status, and more are included, so you can easily implement your own smart history tools.

Re: Yash: Yet Another Shell

#45

Earlier quoted context omitted.

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)?

Eh, yes and no. There's nothing stopping a cohort of programs from adopting some standard and using it among themselves such that the binary values that are traveling across the pipes are interpreted by the recipient as having some type, and then if the reader of your pipe is a tty then you draw a pretty picture for the user, which gets you much of the way there in principle.

But as far as I know there's no portable way to write a program which can uncover enough of the pipeline to print an error message that spans multiple stages. So you get output from potentially many of them and you have to figure out who is complaining.

I'm not intimate with the implementation but it feels like nushell commands are compiled, so there's much less deduction necessary to just tell the user what is wrong in a way that considers the whole command instead of just one stage of the pipeline.

I haven't spent much time with the plugin interface yet, but the idea is that programs can register their input and output types with the shell if they want nushell to treat them like it does it's builtins. Its an extra step up front, but it seems like less of a mess than trying to coordinate types been programs without having a common touch point for them.

Re: Yash: Yet Another Shell

#46
post #16

Earlier quoted context omitted.

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

This looks promising, thanks!

For bash, you may be able to do something like:

  function set_histfile {
    export HISTFILE="$HOME/.bash_history_$(pwd | tr '/' '_')"
  }

  PROMPT_COMMAND="set_histfile; $PROMPT_COMMAND"
There may be other ways, but probably can't do it without PROMPT_COMMAND.

Someone else mentioned "direnv", too.

Re: Yash: Yet Another Shell

#47
post #39
post #21

Earlier quoted context omitted.

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.

my first thought too. on a mac at least it’s a little crusty, but it really does make it convenient to have a project completely and accurately describe its environment.

Re: Yash: Yet Another Shell

#48
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.

looong time ago - ~2005 maybe? - the late Pieter Hintjens told me about such overarching idea including whole project management and all related ping-pongs - code, data, documents, issues, e-mails, chats, everything - think like one laptop for this project and different one for that project - and that they had at the time approached something like that, and got it mostly working, over linux etc. But AFAIK it never went public and has been abandoned.

So the field is ripe for whoever wants to try... though now same accounts to XYZ are being used for hundred things..

[0] https://en.wikipedia.org/wiki/Pieter_Hintjens

Re: Yash: Yet Another Shell

#49

Earlier quoted context omitted.

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…

Box-drawing characters can make output look nice, for sure.

True, but the more interesting bit is that the shell understands the structure of the data. The boxes are just how it communicates that.

Re: Yash: Yet Another Shell

#50
post #20

Earlier quoted context omitted.

nushell does this by default, sort of. it will show you autocompletes that are relevant to the current directory and will fallback to history more generally. i’m a huge nushell fan. if you can stand a non POSIX shell, it’s great for working with any kind of structured data and has a sane mostly FP scripting language

What do you love about it? How would you demonstrate to a friend its value?

well, it’s a few things. a lot of it comes down to reading structured data and scripting. i will often stream logs from k8s or when running a service locally that outputs JSON, and nushell can parse the logs for readability or to find a particular field. i mean, that’s nothing jq couldn’t do. but having an integrated experience based more on readability makes things nice. also when i say scripting i mean actual real functions. you can define a command complete with parsed documented arguments as if you’re using argparse or clap, and it also supports completions. so when i go to sign into the company VPN i have a lil function that grabs my credentials and takes an argument that is one of several providers my company uses, which i can autocomplete with tab because i’ve written a simple completion helper (literally a function that returns a list). it’s documentation as code, and i push all these helpers up to my company git repo so when someone asks me how to do something i have workable readable examples. if you’ve ever wanted a real programming language (like Python) as your shell, i think this is worth a shot.
Post reply on HN