Skip to content

Latest commit

 

History

History
39 lines (30 loc) · 1.07 KB

Windows.md

File metadata and controls

39 lines (30 loc) · 1.07 KB

Windows Learnings

Custom Commands

  1. Create a new /bin folder in your home folder
  2. Add the /bin to the path
  3. Add file to /bin folder ending in .cmd

Inline Windows Env Var Command

I was having difficulties with some stuff not picking up inline env vars. I could do it in two steps set ENV_VAR=var and then command, but I don't want to do that. Would like one command.

I found this online, and using the above way to create a custom command, created the env command. https://superuser.com/a/1079369

env.cmd:

echo off
setlocal
for %%f in (%*) do (
  echo %%f|find "=" >nul:
  if errorlevel 1 goto DoCmd
  set %%f
  shift
)
:DoCmd
%1 %2 %3 %4 %5 %6 %7 %8 %9
endlocal

Usage

env "EDITOR=vim" command [up to 8 parameters]