Skip to content

Instantly share code, notes, and snippets.

@mcgwiz
Last active March 31, 2020 17:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mcgwiz/bd6d5c812d2b57b50cef0b909c6926d6 to your computer and use it in GitHub Desktop.
bash-like `cd` behavior in Windows command interpreter
@echo off
:: Adds support for
:: `cd` change to user profile directory
:: `cd -` change to previous directory
doskey cd=^
set PD="%%CD%%" ^& ^
if [$*]==[] ( ^
cd /d %%userprofile%% ^
) else ( if [$*]==[-] ( ^
cd %%PD%% ^
) else ( ^
cd ^"$*^" ^
) ) ^
;
set PD="%CD%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment