Emacs: Format PowerShell Code 🚀
put this in your Emacs Init File:
(defvar xah-powershell-path "pwsh" "PowerShell path or name. A string. It can be just a program name such as powershell or pwsh, or full path to one of them. Used by many commands that need to launch program via Powershell.") (defun xah-pwsh-format-code () "Format PowerShell code of current buffer file. Buffer must be a file buffer. It is saved first. Requires xah-format-PowerShell-script at URL `http://xahlee.info/powershell/powershell_format_script.html' URL `http://xahlee.info/emacs/emacs/emacs_format_powershell_code.html' Created: 2021-09-13 Version: 2023-08-12" (interactive) (if buffer-file-name (let ((xcmdstr (format "%s -Command xah-format-PowerShell-script %s" xah-powershell-path buffer-file-name))) (save-buffer) (shell-command xcmdstr) (revert-buffer t t t)) (user-error "%s: current buffer must be a file %s" real-this-command (buffer-name))))
need PowerShell: Pretty Format PowerShell Code 🚀
part of Emacs: Xah PowerShell Mode 📦