@echo off setlocal :: Opens a local xterm. Runs XWin first if needed. :: Requires Windows NT/2000/XP or higher. :: If you prefer a desktop-in-a-window mode, run "cygx -onewindow". :: If you want to log in to a remote XDMCP server, also add one of these: :: "-query SERVER" connects to SERVER. :: "-indirect SERVER" asks SERVER for a list of XDMCP servers. :: "-broadcast" connect to the first XDMCP server that answers. set CYGWIN_ROOT= set XINIT=xhost +localhost set DISPLAY_NUM=1 set XMODE=-multiwindow set XSPAWN=run if "%1" == "-onewindow" ( shift& set XMODE=& set DISPLAY_NUM=2& set XSPAWN=start /b ) :: Try to autodetect CYGWIN_ROOT: for %%D in ( %CYGWIN_ROOT% c:\cygwin d:\cygwin e:\cygwin ) do ( if exist %%D\bin\bash.exe ( set CYGWIN_ROOT=%%D goto GOTDIR ) ) echo Cygwin directory not found. Set it manually inside cygx.bat. pause exit /b 1 :GOTDIR :: Check if there is already an X server listening on this port: netstat -p tcp -a -n | %CYGWIN_ROOT%\bin\grep -q -E "^ +TCP +0\.0\.0\.0:600%DISPLAY_NUM% .* LISTENING" if not errorlevel 1 set XMODE=existing set PATH=%CYGWIN_ROOT%\bin;%CYGWIN_ROOT%\usr\X11R6\bin set HOME= set DISPLAY=:%DISPLAY_NUM% if "%XMODE%" == "existing" goto GOTX echo Running X server %XSPAWN% XWin %DISPLAY% -clipboard -dpi 96 -noreset %XMODE% %1 %2 %3 %4 %5 %6 %7 %8 %9 if "%XMODE%" == "" run wmaker %XINIT% :GOTX echo Opening an xterm run xterm -ls -geometry 120x40 -title "Cygwin shell" -sl 2048 -si -sk