Execute powershell commands from org mode source blocks.
With use-package
just add the declaration
(use-package ob-powershell)
(use-package ob-powershell
:straight t
:commands
(org-babel-execute:powershell
org-babel-expand-body:powershell))
- clone from github
- add to load path
(add-to-list 'load-path "~/.emacs.d/lisp/ob-powershell")
- add to your
.emacs
:
(require 'ob-powershell)
(org-babel-do-load-languages
'org-babel-load-languages
(quote (
;; ...
(powershell . t))))
On different OSs the command for Powershell differs. Configure the shell command according to the installation on you OS.
(customize-set-variable 'org-babel-powershell-os-command "pwsh")
Add a source block with powershell language:
#+name: get-env-path #+begin_src powershell echo $env:path #+end_src
And execute it using org-babel-execute-src-block
.
Another example with a variable:
#+begin_src powershell :var tmp="Hello World!"
:
Write-Host $tmp
:
#+end_src
:
#+RESULTS: : Hello World!