feat(cli): add doom.ps1 for Windows users
c9acdb7
removes doom.cmd because it was broken in most cases. This adds doom.ps1; an alternative script for Windows+Powershell users, which properly initializes the state it needs. Naturally, it requires Powershell 3+ be installed on your systems, but it can be invoked from either cmd.exe or PowerShell.exe. This is the first powershell script I've ever written, so I expect edge cases (for one, shell commands passed to `exit!` will need to be guarded against the environment). This also requires emacs.exe be your $PATH, however, unless you set $EMACS to its path first. E.g. $env:EMACS = "C:\Program Files\Emacs\emacs-29.4\bin\emacs.exe" That said, if you use WSL2, you're still far better off using the bash script (bin/doom). Ref:c9acdb72a4
This commit is contained in:
parent
9753bfb775
commit
8d2cf32fef
3 changed files with 80 additions and 20 deletions
38
bin/doom.ps1
Normal file
38
bin/doom.ps1
Normal file
|
@ -0,0 +1,38 @@
|
|||
# bin/doom.ps1
|
||||
|
||||
if (!(Get-Command -Erroraction silentlycontinue emacs.exe)) {
|
||||
echo "Couldn't find emacs.exe in your $PATH."
|
||||
exit 1
|
||||
}
|
||||
|
||||
$doom = "$PSScriptRoot/doom"
|
||||
$emacs = if ($env:EMACS) { $env:EMACS } else { (Get-Command emacs.exe).Path }
|
||||
$emacsargs = "-q", "--no-site-file", "--batch"
|
||||
$oldemacsdir = $env:EMACSDIR
|
||||
|
||||
try {
|
||||
$env:EMACSDIR = if (-not $env:EMACSDIR) { (get-item $PSScriptRoot).parent.FullName } else { $env:EMACSDIR }
|
||||
$env:__DOOMSH = if (-not $env:__DOOMSH) { "ps1" } else { $env:__DOOMSH }
|
||||
$env:__DOOMPID = if (-not $env:__DOOMPID) { $PID } else { $env:__DOOMPID }
|
||||
$env:__DOOMSTEP = if (-not $env:__DOOMSTEP) { 0 } else { $env:__DOOMSTEP }
|
||||
$cols = (Get-Host).UI.RawUI.WindowSize.Width
|
||||
$lines = (Get-Host).UI.RawUI.WindowSize.Height
|
||||
$env:__DOOMGEOM = if (-not $env:__DOOMGEOM) { "$cols`x$lines" } else { $env:__DOOMGEOM }
|
||||
# $env:__DOOMGPIPE = if (-not $env:__DOOMGPIPE) { $env:__DOOMPIPE } else { $env:__DOOMGPIPE }
|
||||
# $env:__DOOMPIPE = ""
|
||||
|
||||
& $emacs $emacsargs --load "$doom" -- --no-color $args
|
||||
$exit = $LASTEXITCODE
|
||||
} finally {
|
||||
$env:EMACSDIR = $oldemacsdir
|
||||
Remove-Item Env:\__DOOMSH
|
||||
Remove-Item Env:\__DOOMPID
|
||||
Remove-Item Env:\__DOOMSTEP
|
||||
Remove-Item Env:\__DOOMGEOM
|
||||
}
|
||||
|
||||
if ($exit -eq 254) {
|
||||
& pwsh "$env:TMPDIR\doom.$($env:__DOOMPID).$($env:__DOOMSTEP).ps1" $PSCommandPath $args
|
||||
$exit = $LASTEXITCODE
|
||||
}
|
||||
exit $exit
|
|
@ -57,6 +57,7 @@ if [ ! -f "$EMACSDIR/early-init.el" ]; then
|
|||
fi >&2
|
||||
# Some state that Doom's CLI framework needs to know about the terminal. Read
|
||||
# the comments at the top of bin/doom for explanations.
|
||||
export __DOOMSH="${__DOOMSH:-sh}"
|
||||
export __DOOMPID="${__DOOMPID:-$$}"
|
||||
export __DOOMSTEP="${__DOOMSTEP:-0}"
|
||||
export __DOOMGEOM="${__DOOMGEOM:-$(tput cols 2>/dev/null)x$(tput lines 2>/dev/null)}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue