[#]plan9 #acme allows you to execute selected text by running it with the rc shell and printing the return value in acme.
But did you know you could override the shell it uses by exporting the SHELL and acmeshell variable with another shell ? It works easily with bash or python, but I think the exec command acme does hardcodes a '-c' argument so if you want it to work with other shells you probably need to wrap it in script that handles the '-c'.
But if I can get that working then that means I can turn acme into a language specific interpreter. Ideally I think I'd like to be able to have an rc shell in the tag bar and a language specific shell in the window body, but that would probably require modifying acme's source code.
=> More informations about this toot | More toots from mathuin@bsd.network
Got it to work with node by making SHELL="myscript" where myscript calls exec node -e $2
So now I can execute my javascript code in my editor by highlighting the desired lines and middle clicking them !
(well I'll probably need to work on the script a bit so the node shell loads with whatever the file is importing, but it's a start !)
=> More informations about this toot | More toots from mathuin@bsd.network
The acme winid of the script is available as an env var, so I can totally get the file name, pick the right shell for it and have the shell use that file as context.
It doesnt tell me if the script was run from the tag bar, but I think I can get that information by checking what part of the winId was last focused. I'll have to keep exploring this another day.
=> More informations about this toot | More toots from mathuin@bsd.network
Though there's another simpler solution which is to write a script that I can put in the tag bar called Repl that runs the selected text through the germane shell.
So I can select my code and mouse click 2-1 on the Repl command to get the output.
=> More informations about this toot | More toots from mathuin@bsd.network This content has been proxied by September (3851b).Proxy Information
text/gemini