Skip to content

Instantly share code, notes, and snippets.

@okurka12
Last active August 23, 2023 15:34
Show Gist options
  • Save okurka12/3a1b348e6ac5a2f9be529bb19772f48e to your computer and use it in GitHub Desktop.
Save okurka12/3a1b348e6ac5a2f9be529bb19772f48e to your computer and use it in GitHub Desktop.
a windows batch script that opens various shells and a text editor in the specified directory
:: Author: Vit Pavlik (okurka12)
:: Date: 2023-08-23
:: this is a script `enviro.bat` to be located in %userprofile%. it's purpose
:: is to run all necessary tools/editors/shells needed for various projects
:: why %userprofile%?
:: %userprofile% where the windows run dialog's "current directory" is.
:: what I mean is programs can be run from %userprofile% with the windows
:: run dialog window, even though %usrprofile% is not in path.
:: also, when cmd or powershell is run, it's started there, so the script is
:: accessible right on from both shells
:: this way, one can hit `Win + R`, type "enviro projectname" and everything
:: is good to go, like you never left the computer
@echo off
:: 2d-rasterizer
:: 1. open WSL shell in the project's directory
:: 2. open MSVC developer command prompt in the project's directory
:: 3. open VSCode in the project's directory
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set RASTERIZER_PATH=C:\skola\ne_skola\2d-rasterizer
set MSVC_BATCH_PATH="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
if "%1" equ "rasterizer" (
start "" powershell -command "cd %RASTERIZER_PATH%; wsl"
start "" %comspec% /k "%MSVC_BATCH_PATH% && cd %RASTERIZER_PATH%"
cmd /c "code %RASTERIZER_PATH%"
)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: help
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if "%1" equ "help" goto :help
if "%1" equ "" goto :help
goto :end
:help
echo Available projects:
echo enviro rasterizer - 2d-rasterizer (WSL shell, MSVC shell, VSCode)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment