Org for powershell core! I wrote it!
Based on xchrishawk
's ob-racket
plugin
Fair warning - this is super raw
(org-entry-get nil "version" t)
0.1
Get-Location | foreach { "A path: " + $_.Path }
A path: /Users/gmauer/code/ob-powershell
For this next bit, I'd want to use echo
. But I want to avoid bashisms for the purpose of this demo. I know it's an alias in powershell, so let's look that up
get-alias echo
CommandType Name Version S
o
u
r
c
e
----------- ---- ------- -
Alias echo -> Write-Output
Pretty cool huh? Now we can use Write-Output
in the future.
Yup, variables. Here's a value:
987
And we can reference it by name in this code block
Write-Output "A foo value, larries and gentlemen: $foo"
A foo value, larries and gentlemen: 987
return $numerator / 7
And now I can use the results of that function in this python code block with the :var division_result=divide-it(numerator=213)
header arg
print(f'{division_result} + {another_num} is {division_result + another_num}')
30.4285714285714
+ 987
is 30.4285714285714
987
Add to load path so tha we can require this
(add-to-list 'load-path "/Users/gmauer/code/ob-powershell/src/")
And load it
(load-file 'ob-pwsh)
And now its loaded, you can go run the above.
The default powershell command run is
org-babel-pwsh-command
If you installed this correctly the above should display something like "pwsh"
.
You should make sure its installed in a location visible to the default shell, or you can set it to another value.
It thinks that there is something called pwsh-mode
but there isn't, it's powershell-mode
This will require digging into how eg ob-python works
TODO Ok, this is dumb but my html exports is broken. Some error that might have to do with parinfer?
Rather than outputting strings, convert powershell objects returned as value
to elisp structures to take advantage of the fact tha we have a runtime