Improve piping & interop syntax
Let's say you work on windows (cmd/powershell), and you want to pipe something to linux, do something there, and pipe something out. For example, copying to clipboard cowsaying all files/folders from C\Windows starting with 's'. (Yes. Very practical example)
Normally, you would use this syntax
C:\Windows>dir | bash -c "grep '\ss'" | bash -c "cowsay" | clip
It would work, but it is rather verbose & it needs to have those quotation marks, which is annoying.
I have used a nice utility ($.exe from https://github.com/neosmart/RunInBash), which makes this look a bit better:
C:\Windows>dir | $ grep '\ss' | $ cowsay | clip
Here commands starting with '$' are executed by Linux and other commands are executed by Windows. However, using a third party tool for such a thing would not be something everyone wants to do. Could this, or a similar solution be baked into Windows?
This could be ever more optimized by utilizing some "magic", where every command starting with '$' are executed in Linux (even without the space between '$' and the command), like:
C:\Windows>dir | $grep '\ss' | $cowsay | clip
Of course, you could implement the oppisite behaviour somehow to the Linux side (calling Windows executables, when certain pattern is found. This could be possible by modifying the parsing settings of the shell.)
What do you think about this?
Niko Pasanen commented
Yet another way to implement this would be to use syntax where '|' would mean to pipe inside Windows (when calling from cmd or powershell) and '|>' (or something else) would mean that piping is intended to go to the "another" OS (e.g.Ubuntu). This would make perhaps even cleaner syntax:
C:\Windows>dir |> grep '\ss' |> cowsay | clip
Or, if you would like to think that '|' must mean that piping happens "in the same OS", and '|>' should mean that piping happens "across OS boundary", then the command would be something like:
C:\Windows>dir |> grep '\ss' | cowsay |> clip