Skip to content

zed-texpresso for Windows Zed #7

@mathlab08

Description

@mathlab08

Install Arch Linux on WSL2 in Windows.Install TeXpresso on Arch Linux in WSL2 (/home/archlinux/texpresso/build). Install Node.js, SumatraPDF, and Zed on Windows. Create a batch file StartZed.bat to launch Zed, install the TeXpresso v0.0.3 extension., exit Zed. Create settings.json and tasks.json, modify process-manager.js and server.js. Following the README instructions, you can now launch Zed in Windows and invoke TeXpresso.

/Portable_Zed/
├──  Appdata/
│       └── conversations/
│       └── db/
│       └── debug_adapters/
│       └── extensions/
│                └── installed/
│                └── work/
│                    └── texpresso/
│                         └── node_modules/
│                             └── texpresso-lsp/
│                                  └── dist/
│                                       └── process-manager.js
│                                       └── server.js
│                                       └── types.js
│                └── index.json
│       └── external_agents/
│       └── hang_traces/
│       └── languages/
│       └── logs/
│       └── Microsoft/
│       └── node/
│       └── prettier/
│       └── prompts/
│       └── themes/
│       └── threads/
│       └── agent-navigation-history.json
│       └── keymap.json
│       └── settings.json
│       └── tasks.json
│       └── tsconfig.json
│       └── process-manager.tmp
│       └── server.tmp
│       └── settings.tmp
│       └── tasks.tmp
├──  nodejs/
│       └── node_cache/
│       └── node_global/
│       └── node_modules/
│       └── node.exe
├──  example/
│       └── main.tex
│       └── main.pdf
├── SumatraPDF/
│       └── sumatrapdfcache/
│       └── SumatraPDF.exe
│       └── SumatraPDF-settings.txt
├── Zed/
│       └── arm64/
│       └── bin/
│       └── tools/
│       └── updates/
│       └── x64/
│       └── amd_ags_x64.dll
│       └── conpty.dll
│       └── Zed.exe
├── readme.txt
├── StartZed.bat

startZed.bat

@echo off
color 3e

setlocal enabledelayedexpansion
:: Get the directory where the batch file is located
set "BatchDir=%~dp0"
set "BatchDir=%BatchDir:~0,-1%"

:: Extract drive letters (e.g. C:)
set "drive_letter=!BatchDir:~0,2!"

:: Extract the drive letter portion (remove the colon)
set "drive=!drive_letter:~0,1!"
set "lower_drive=!drive!"

:: Convert drive letters to lowercase (via string replacement)
for %%i in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
    if "!drive!"=="%%i" set "lower_drive=%%i"
)
set "lower_drive=!lower_drive:a=a!"
set "lower_drive=!lower_drive:b=b!"
set "lower_drive=!lower_drive:c=c!"
set "lower_drive=!lower_drive:d=d!"
set "lower_drive=!lower_drive:e=e!"
set "lower_drive=!lower_drive:f=f!"
set "lower_drive=!lower_drive:g=g!"
set "lower_drive=!lower_drive:h=h!"
set "lower_drive=!lower_drive:i=i!"
set "lower_drive=!lower_drive:j=j!"
set "lower_drive=!lower_drive:k=k!"
set "lower_drive=!lower_drive:l=l!"
set "lower_drive=!lower_drive:m=m!"
set "lower_drive=!lower_drive:n=n!"
set "lower_drive=!lower_drive:o=o!"
set "lower_drive=!lower_drive:p=p!"
set "lower_drive=!lower_drive:q=q!"
set "lower_drive=!lower_drive:r=r!"
set "lower_drive=!lower_drive:s=s!"
set "lower_drive=!lower_drive:t=t!"
set "lower_drive=!lower_drive:u=u!"
set "lower_drive=!lower_drive:v=v!"
set "lower_drive=!lower_drive:w=w!"
set "lower_drive=!lower_drive:x=x!"
set "lower_drive=!lower_drive:y=y!"
set "lower_drive=!lower_drive:z=z!"

:: Extract the remaining path after removing the drive
set "remaining_path=!BatchDir:~2!"

:: Replace backslashes with forward slashes in the remaining paths
set "remaining_slash=!remaining_path:\=/!"
:: Replace backslashes with double backslashes in the remaining paths
set "remaining_path=!remaining_path:~1!"
set "remaining_double=!remaining_path:\=\\\!"


>nul 2>&1 copy /Y "%~dp0Appdata\settings.tmp" "%~dp0Appdata\settings.json"
>nul 2>&1 copy /Y "%~dp0Appdata\tasks.tmp" "%~dp0Appdata\tasks.json"
>nul 2>&1 copy /Y "%~dp0Appdata\server.tmp" "%~dp0Appdata\extensions\work\texpresso\node_modules\texpresso-lsp\dist\server.js"
>nul 2>&1 copy /Y "%~dp0Appdata\process-manager.tmp" "%~dp0Appdata\extensions\work\texpresso\node_modules\texpresso-lsp\dist\process-manager.js"

set "target_file1=%~dp0Appdata\settings.json"
set "target_file2=%~dp0Appdata\tasks.json"
set "target_file3=%~dp0Appdata\\extensions\work\texpresso\node_modules\texpresso-lsp\dist\server.js"
set "target_file4=%~dp0Appdata\\extensions\work\texpresso\node_modules\texpresso-lsp\dist\process-manager.js"

set "searchA=ZedDirA\\"
set "replaceA=!lower_drive!:\\!remaining_double!\"
set "searchB=ZedDirB/"
set "replaceB=!lower_drive!!remaining_slash!/"

powershell -Command "(Get-Content '%target_file1%') -replace '%searchA%', '%replaceA%' | Set-Content '%target_file1%'"  >nul 2>nul
powershell -Command "(Get-Content '%target_file1%') -replace '%searchB%', '%replaceB%' | Set-Content '%target_file1%'"  >nul 2>nul
powershell -Command "(Get-Content '%target_file2%') -replace '%searchA%', '%replaceA%' | Set-Content '%target_file2%'"  >nul 2>nul
powershell -Command "(Get-Content '%target_file2%') -replace '%searchB%', '%replaceB%' | Set-Content '%target_file2%'"  >nul 2>nul
powershell -Command "(Get-Content '%target_file3%') -replace '%searchA%', '%replaceA%' | Set-Content '%target_file3%'"  >nul 2>nul
powershell -Command "(Get-Content '%target_file3%') -replace '%searchB%', '%replaceB%' | Set-Content '%target_file3%'"  >nul 2>nul
powershell -Command "(Get-Content '%target_file4%') -replace '%searchA%', '%replaceA%' | Set-Content '%target_file4%'"  >nul 2>nul
powershell -Command "(Get-Content '%target_file4%') -replace '%searchB%', '%replaceB%' | Set-Content '%target_file4%'"  >nul 2>nul

pause

:: Set Zed related paths
set "OriginalLocalDir=%LOCALAPPDATA%\Zed"
set "OriginalRoamingDir=%APPDATA%\Zed"
set "TargetLocalDir=%BatchDir%\Appdata"
set "TargetRoamingDir=%BatchDir%\Appdata"

echo Configuring Zed directory redirection...

:: Check and create target directories
if not exist "%TargetLocalDir%" (
    mkdir "%TargetLocalDir%"
    echo Local directory created: %TargetLocalDir%
)

if not exist "%TargetRoamingDir%" (
    mkdir "%TargetRoamingDir%"
    echo Roaming directory created: %TargetRoamingDir%
)

:: Close the Zed editor (if running)
taskkill /f /im zed.exe >nul 2>&1
timeout /t 2 /nobreak >nul

:: Handling Local Directories
echo Processing the Local directory...
set "localLinked="
for /f "tokens=3" %%a in ('dir /al "%OriginalLocalDir%" 2^>nul ^| find "<JUNCTION>"') do set "localLinked=%%a"

if not "!localLinked!"=="%TargetLocalDir%" (
    if exist "%OriginalLocalDir%" (
        echo Delete the original Local directory...
        rmdir /s /q "%OriginalLocalDir%" 2>nul
    )
    
    echo Create a symbolic link to a local directory...
    mklink /j "%OriginalLocalDir%" "%TargetLocalDir%" >nul 2>&1
    if errorlevel 1 (
        echo ERROR: You need to run this script with administrator privileges
        pause
        exit /b 1
    )
    echo Local directory has been redirected
)

:: Handling Roaming Directories
echo Processing the Roaming directory...
set "roamingLinked="
for /f "tokens=3" %%a in ('dir /al "%OriginalRoamingDir%" 2^>nul ^| find "<JUNCTION>"') do set "roamingLinked=%%a"

if not "!roamingLinked!"=="%TargetRoamingDir%" (
    if exist "%OriginalRoamingDir%" (
        echo Delete the original Roaming directory...
        rmdir /s /q "%OriginalRoamingDir%" 2>nul
    )
    
    echo Create a symbolic link to the Roaming directory...
    mklink /j "%OriginalRoamingDir%" "%TargetRoamingDir%" >nul 2>&1
    if errorlevel 1 (
        echo ERROR: You need to run this script with administrator privileges
        pause
        exit /b 1
    )
    echo Roaming directory has been redirected
)

set "WSL=C:\Program Files\WSL\"
set TECTONIC_CACHE_DIR=%~dp0TectonicProject\Tectonic
set PATH=%~dp0Zed;%WSL%;%~dp0Appdata\extensions\work\latex\texlab-v5.25.1;%~dp0nodejs;%~dp0SumatraPDF;%PATH%

start "" "%~dp0Zed\Zed.exe"
endlocal

readme.txt

1. Extract Portable_Zed.7z to a directory, such as c:\Portable_Zed;
2. Launch StartZed.bat, select File->Open Folder, navigate to c:\Portable_Zed\example, and select main.tex;
3. Wait briefly while Zed invokes TeXpresso's browser window;
4. Enter or edit main.tex; changes will be synchronized in the Mupdf window;
5. Optionally select Run->Spawn Task->texpresso-compile to compile main.tex into a PDF file;
6. Optionally select Run->Spawn Task->SumatraPDF to preview the final main.pdf file.

Attachment.zip

(process-manager.tmp, server.tmp, settings.tmp, tasks.tmp)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions