anki-code / xontrib-sh

Paste and run commands from bash, zsh, fish, tcsh in xonsh shell.
MIT License
54 stars 5 forks source link

Using subprocess macros #1

Closed jnoortheen closed 3 years ago

jnoortheen commented 3 years ago

I just stumbled across this package. I don't know if this is possible. But here is an idea of using subprocess macros to identify the shell language.

So something like

bash! export var=12
zsh! export var=12

would become possible.

anki-code commented 3 years ago

Hi @jnoortheen! Yes you can do bash -c! ls to run the another shell command.

But there are two issues around this approach:

  1. You can't paste the multiline piece of script:
    bash -c! for i in 1 2 3
    do
    echo $i
    done
    # Syntax error

    But in xontrib-sh:

    
    ! for i in 1 2 3
    do
    echo $i
    done

1

2

3



2. You should write `bash -c!` command that has more keystrokes than just `! ` :)

Meanwhile I think it's a good potential feature for xontrib-sh: to allow run the script with certain shell i.e. `zsh! ls`. 
PRs are welcome!

> I just stumbled across this package

Look at [xontrib-ergopack](https://github.com/anki-code/xontrib-ergopack) also ;)
jnoortheen commented 3 years ago

Yes thanks, I got here after checking out the ergopack. I currently don't have use for shell specific snippets, so a PR wouldn't be possible. Just wanted to see how this can be handled.