I think what would be more use-full would be a new "shell" which is base on a modern context, incorporating lessens learned from years of cmd-line UX design (ok let's be honest many programs didn't learn anything wrt. UX).

But adding jet another POSIX shell which maybe does some parts better but in the end has still not a grate UX because it's a POSIX shell seems kinda pointless IMHO.

This. I want a shell that will contextually spit out plaintext in interactive mode, then a JSON object when scripted or piped.

Pretty sure this is what Powershell does, but the UI just feels so damn unnatural.

Murex does this. eg

Take a plain text table, convert it into an SQL table and run an SQL query:

  » ps aux | select USER, count(*) GROUP BY USER
  USER                   count(*)
  _installcoordinationd  1
  _locationd             4
  _mdnsresponder         1
  _netbios               1
  _networkd              1
  _nsurlsessiond         2
  _reportmemoryexception 1
  _softwareupdate        3
  _spotlight             5
  _timed                 1
  _usbmuxd               1
  _windowserver          2
  lmorg                  349
  root                   134
The builtins usually print human readable output when STDOUT is a TTY, or JSON (or JSONlines) when the TTY is a pipe.

  » fid-list:
    FID   Parent    Scope  State         Run Mode  BG   Out Pipe    Err Pipe    Command     Parameters
    590        0        0  Executing     Normal    no   out         err         fid-list    (subject to change)

  » fid-list: | cat
  ["FID","Parent","Scope","State","RunMode","BG","OutPipe","ErrPipe","Command","Parameters"]
  [615,0,0,"Executing","Normal",false,"out","err",{},"(subject to change) "]
  [616,0,0,"Executing","Normal",false,"out","err",{},"cat"]
and you can reformat to other data types, eg

  » fid-list: | format csv
  FID,Parent,Scope,State,RunMode,BG,OutPipe,ErrPipe,Command,Parameters
  703,0,0,Executing,Normal,false,out,err,map[],(subject to change)
  704,0,0,Executing,Normal,false,out,err,map[],csv
and query data within those data structures using tools that are aware of that structural format. Eg Github's API returns a JSON object and we can filter through it to return just the issue ID's and titles:

  » open https://api.github.com/repos/lmorg/murex/issues | foreach issue { printf "%2s: %s\n" $issue[number] $issue[title] }
  348: Potential regression bug in `fg`
  347: Version 2.2 Release
  342: Install on Fedora 34 fails (issue with `go get` + `bzr`)
  340: `append` and `prepend` should `ReadArrayWithType`
  318: Establish a testing framework that can work against the compiled executable, sending keystrokes to it
  316: struct elements should alter data type to a primitive
  311: No autocompletions for `openagent` currently exist
  310: Supprt for code blocks in not: `! { code }`
  308: `tabulate` leaks a zero length string entry when used against `rsync --help`

Source: https://github.com/lmorg/murex

Website: https://murex.rocks