Creating a tsexec command

August 21, 2020 typscript, batch

I want to use TypeScript as a scripting language for my machine and so I want to be able just to execute TypeScript files directly. There are npm packages like ts-node that do this already but I wanted to have a crack at implementing it myself. So this is the batch file I've come up with so far.

Read More

Checking for uncommited git changes in a batch program

July 22, 2020 batch, git

Sometimes it's helpful to exit out of a batch script if there are pending changes to a repo. This is done in batch script in a non intuitive way.

PUSHD %~dp0


REM The loop won't be executed if 'git status -s' doesn't produce any output.
FOR /f "tokens=*" %%i IN ('git status -s') DO ( SET __HAS_CHANGES=1 )

REM Check if the loop was executed and goto EXIT if it was.
IF "%__HAS_CHANGES%" NEQ "0" (
    ECHO There are currently uncommitted changes.

REM Do the work you want to do here.


Git Quick Push

March 29, 2018 git, batch

Here's a quick one liner to quickly stage all your changes in the current git repo, commit them and then push the commit to origin master branch.

Read More