Last active
October 15, 2020 06:59
-
-
Save programus/2d2738b2a746140186f7738b678bdcec to your computer and use it in GitHub Desktop.
Revisions
-
programus revised this gist
Jul 24, 2018 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,10 +12,12 @@ rem gist url: rem https://gist.github.com/programus/2d2738b2a746140186f7738b678bdcec rem rem this tool need or create 2 temporary files: rem %BASEDIR%\dir-list.tmp rem %BASEDIR%\dir-prev.tmp rem *********************************************************************** set BASEDIR=%USERPROFILE% if /i [%1]==[/help] goto :printhelp if /i [%1]==[/h] goto :printhelp if [%1]==[/?] goto :printhelp @@ -38,8 +40,8 @@ goto :allover :main setlocal EnableDelayedExpansion set tp=%BASEDIR%\dir-prev.tmp set tf=%BASEDIR%\dir-list.tmp rem extract previous path set /p ppth=<%tp% -
programus revised this gist
Oct 21, 2016 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ This is a batch file could help you change working directory easier especially y cdx <path> - save current path and jump to <path> cdx :<n|name> - jump to the Nth or named path in the saved list cdx : - jump to previous path cdx name <n>:<name> - name the Nth path as <name> cdx rm [:]<n|name> - remove the Nth or named path from the list cdx clear - clear the list cdx /help - print out this help This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ echo %~n0 - display all saved path with leading id and name foll echo %~n0 ^<path^> - save current path and jump to ^<path^> echo %~n0 :^<n^|name^> - jump to the Nth or named path in the saved list echo %~n0 : - jump to previous path echo %~n0 name ^<n^>:^<name^> - name the Nth path as ^<name^> echo %~n0 rm [:]^<n^|name^> - remove the Nth or named path from the list echo %~n0 clear - clear the list echo %~n0 /help - print out this help -
programus revised this gist
Jun 28, 2016 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -62,7 +62,6 @@ if [%1]==[] ( if not "!names[%%i]!"=="" set nm= ^<--^<^<^<^ (!names[%%i]!^) echo [%%i] !list[%%i]!!nm! ) goto :end ) -
programus revised this gist
Jun 28, 2016 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -69,7 +69,8 @@ if [%1]==[] ( rem goto previous directory and store current if [%1]==[:] ( rem get the previous path set pth="%ppth%" set pth=!pth:"=! goto :savecd ) @@ -165,7 +166,7 @@ set j=0 rem save current path as previous path if /i not "%pth%"=="%cd%" ( if defined pth ( call :printcd "%tp%" ) ) :end @@ -178,3 +179,8 @@ if defined __pth ( ) :allover exit /b 0 :printcd echo %cd%>%1 exit /b 0 -
programus renamed this gist
Jun 17, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
programus renamed this gist
Jun 17, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
programus revised this gist
Jun 17, 2016 . 1 changed file with 12 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -82,18 +82,20 @@ if /i [%1]==[clear] ( rem name an item if /i [%1]==[name] ( for /f "tokens=1,2 delims=:" %%a in ("%2") do set no=%%a&set name=%%b if not "!name!"=="" ( set notNumeric= for /f "delims=0123456789" %%x in ("!name!") do set notNumeric=%%x if not defined notNumeric ( echo Error: name cannot be a number. goto :allover ) for /l %%i in (1,1,%len%) do ( set nm=!names[%%i]! if "!nm!"=="!name!" ( echo Error: name has been existed. goto :allover ) ) ) set names[!no!]=!name! goto :write -
programus revised this gist
Jun 14, 2016 . 1 changed file with 12 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,14 @@ # CDX Command - CD eXtension batch file This is a batch file could help you change working directory easier especially you need to change many directories very often like me. ## Features * Save histroy of all navigated directories * No duplicated directories in histroy * Name history directories * Jump into any directory in histroy by index or name * Quich jump into previous directory * Maintain history list ## Help cdx - display all saved path with leading id and name followed if any cdx <path> - save current path and jump to <path> @@ -10,7 +20,7 @@ Help cdx /help - print out this help cdx /? - same as above ## Examples D:\>cdx "C:\Program Files" C:\Program Files>cdx -
programus revised this gist
Jun 14, 2016 . 1 changed file with 53 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,53 @@ Help cdx - display all saved path with leading id and name followed if any cdx <path> - save current path and jump to <path> cdx :<n|name> - jump to the Nth or named path in the saved list cdx : - jump to previous path cdx <n>:<name> - name the Nth path as <name> cdx rm [:]<n|name> - remove the Nth or named path from the list cdx clear - clear the list cdx /help - print out this help cdx /? - same as above Examples D:\>cdx "C:\Program Files" C:\Program Files>cdx [1] D:\ C:\Program Files>cdx d:\tmp d:\tmp>cdx [1] D:\ [2] C:\Program Files d:\tmp>cdx t:\UsrTmp t:\UsrTmp>cdx . t:\UsrTmp>cdx [1] D:\ [2] C:\Program Files [3] d:\tmp [4] t:\UsrTmp t:\UsrTmp>cdx :2 C:\Program Files>cdx [1] D:\ [2] C:\Program Files [3] d:\tmp [4] t:\UsrTmp C:\Program Files>cdx rm 1 C:\Program Files>cdx [1] C:\Program Files [2] d:\tmp [3] t:\UsrTmp C:\Program Files>cdx name 3:tmp C:\Program Files>cdx [1] C:\Program Files [2] d:\tmp [3] t:\UsrTmp <--<<< (tmp) C:\Program Files>cdx :tmp t:\UsrTmp>cdx : C:\Program Files> -
programus revised this gist
Jun 14, 2016 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -162,17 +162,17 @@ set j=0 rem save current path as previous path if /i not "%pth%"=="%cd%" ( if defined pth ( echo %cd%>%tp% ) ) :end endlocal && set __pth=%pth% rem change directory if defined __pth ( cd /d "%__pth%" set __pth= ) :allover -
programus revised this gist
Jun 14, 2016 . 1 changed file with 53 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,14 +23,15 @@ if [%1]==[/?] goto :printhelp goto :main :printhelp echo %~n0 - display all saved path with leading id and name followed if any echo %~n0 ^<path^> - save current path and jump to ^<path^> echo %~n0 :^<n^|name^> - jump to the Nth or named path in the saved list echo %~n0 : - jump to previous path echo %~n0 ^<n^>:^<name^> - name the Nth path as ^<name^> echo %~n0 rm [:]^<n^|name^> - remove the Nth or named path from the list echo %~n0 clear - clear the list echo %~n0 /help - print out this help echo %~n0 /? - same as above goto :allover @@ -47,13 +48,19 @@ rem read list from file set len=0 for /f "tokens=*" %%p in (%tf%) do ( set /a "len+=1" set lines[!len!]=%%p for /f "tokens=1,2 delims=;" %%a in ("%%p") do set pp=%%a&set nn=%%b set list[!len!]=!pp! set list[!nn!]=!pp! set names[!len!]=!nn! ) rem list all history if [%1]==[] ( for /l %%i in (1,1,%len%) do ( set nm= if not "!names[%%i]!"=="" set nm= ^<--^<^<^<^ (!names[%%i]!^) echo [%%i] !list[%%i]!!nm! ) echo. goto :end @@ -72,9 +79,43 @@ if /i [%1]==[clear] ( goto :write ) rem name an item if /i [%1]==[name] ( for /f "tokens=1,2 delims=:" %%a in ("%2") do set no=%%a&set name=%%b set notNumeric= for /f "delims=0123456789" %%x in ("!name!") do set notNumeric=%%x if not defined notNumeric ( echo Error: name cannot be a number. goto :allover ) for /l %%i in (1,1,%len%) do ( set nm=!names[%%i]! if "!nm!"=="!name!" ( echo Error: name has been existed. goto :allover ) ) set names[!no!]=!name! goto :write ) rem mark index should be removed if /i [%1]==[rm] ( set rmno=%2 rem check names which is a non-numeric set notNumeric= for /f "delims=0123456789" %%x in ("%rmno%") do set notNumeric=%%x if not defined notNumeric ( rem parameter is a name, find out the index for /l %%i in (1,1,%len%) do ( set nm=!names[%%i]! if "!nm!"=="!rmno!" ( set rmno=%%i goto :endloopname ) ) ) :endloopname goto :write ) @@ -92,6 +133,7 @@ if [%pth:~0,1%]==[:] ( rem store current path into history set /a "len+=1" set list[!len!]=%cd% set lines[!len!]=%cd% :write rem write back to file @@ -110,7 +152,7 @@ set j=0 ) if not "!included!"=="T" ( rem only write the directory if it is not written already, not included. echo !pt!;!names[%%i]! rem mark the directory as written set /a "j+=1" set written[!j!]=!pt! -
programus revised this gist
Jun 14, 2016 . No changes.There are no files selected for viewing
-
programus revised this gist
Jun 13, 2016 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,9 +16,9 @@ rem %TEMP%\dir-list.tmp rem %TEMP%\dir-prev.tmp rem *********************************************************************** if /i [%1]==[/help] goto :printhelp if /i [%1]==[/h] goto :printhelp if [%1]==[/?] goto :printhelp goto :main -
programus revised this gist
Jun 13, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -88,6 +88,7 @@ if [%pth:~0,1%]==[:] ( rem get the real path set pth=!list[%pth::=%]! ) :savecd rem store current path into history set /a "len+=1" set list[!len!]=%cd% @@ -117,7 +118,6 @@ set j=0 ) )) > %tf% rem save current path as previous path if /i not "%pth%"=="%cd%" ( if not "%pth%"=="" ( -
programus revised this gist
Jun 13, 2016 . 1 changed file with 6 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,11 +23,11 @@ if "%1"=="/?" goto :printhelp goto :main :printhelp echo %~n0 - display all saved path with leading id echo %~n0 ^<path^> - save current path and jump to ^<path^> echo %~n0 :^<n^> - jump to the Nth path in the saved list echo %~n0 : - jump to previous path echo %~n0 rm [:]^<n^> - remove the Nth path from the list echo %~n0 clear - clear the list echo %~n0 /help - print out this help echo %~n0 /? - same as above @@ -40,6 +40,7 @@ setlocal EnableDelayedExpansion set tp=%TEMP%\dir-prev.tmp set tf=%TEMP%\dir-list.tmp rem extract previous path set /p ppth=<%tp% rem read list from file -
programus revised this gist
Jun 13, 2016 . 1 changed file with 36 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,40 @@ @echo off rem *********************************************************************** rem This file is provided under MIT License: rem http://www.opensource.org/licenses/mit-license.phprem rem rem This batch file is a extended cd command. rem This could save the history and also jump in the histories. rem For detail help, type <filename> /? rem rem Author: Programus ([email protected]) rem gist url: rem https://gist.github.com/programus/2d2738b2a746140186f7738b678bdcec rem rem this tool need or create 2 temporary files: rem %TEMP%\dir-list.tmp rem %TEMP%\dir-prev.tmp rem *********************************************************************** if /i "%1"=="/help" goto :printhelp if /i "%1"=="/h" goto :printhelp if "%1"=="/?" goto :printhelp goto :main :printhelp echo %~n0 - display all saved pth with leading id echo %~n0 ^<pth^> - save current pth and jump to ^<pth^> echo %~n0 :^<n^> - jump to the Nth pth in the saved list echo %~n0 : - jump to previous pth echo %~n0 rm [:]^<n^> - remove the Nth pth from the list echo %~n0 clear - clear the list echo %~n0 /help - print out this help echo %~n0 /? - same as above goto :allover :main setlocal EnableDelayedExpansion set tp=%TEMP%\dir-prev.tmp @@ -28,6 +54,7 @@ if [%1]==[] ( for /l %%i in (1,1,%len%) do ( echo [%%i] !list[%%i]! ) echo. goto :end ) @@ -104,3 +131,5 @@ if not "%ph%"=="" ( cd /d "%ph%" set ph= ) :allover -
programus revised this gist
Jun 13, 2016 . No changes.There are no files selected for viewing
-
programus created this gist
Jun 13, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,106 @@ @echo off rem cdx - display all saved pth with leading id rem cdx <pth> - save current pth and jump to <pth> rem cdx :<n> - jump to the Nth pth in the saved list rem cdx : - jump to previous pth rem cdx rm [:]<n> - remove the Nth pth from the list rem cdx clear - clear the list rem rem using a temporary file in %TEMP%\dir-list.tmp setlocal EnableDelayedExpansion set tp=%TEMP%\dir-prev.tmp set tf=%TEMP%\dir-list.tmp set /p ppth=<%tp% rem read list from file set len=0 for /f "tokens=*" %%p in (%tf%) do ( set /a "len+=1" set list[!len!]=%%p ) rem list all history if [%1]==[] ( for /l %%i in (1,1,%len%) do ( echo [%%i] !list[%%i]! ) goto :end ) rem goto previous directory and store current if [%1]==[:] ( rem get the previous path set pth=%ppth% goto :savecd ) rem clear all if /i [%1]==[clear] ( set len=0 goto :write ) rem mark index should be removed if /i [%1]==[rm] ( set rmno=%2 goto :write ) rem other cases rem store the argument as path set pth=%1 rem remove all double-quotation set pth=%pth:"=% if [%pth:~0,1%]==[:] ( rem start with ':', mean jump to a history record rem get the real path set pth=!list[%pth::=%]! ) rem store current path into history set /a "len+=1" set list[!len!]=%cd% :write rem write back to file echo off set j=0 (for /l %%i in (1,1,%len%) do ( rem do not save rm directory if not [%%i]==[%rmno::=%] ( set pt=!list[%%i]! rem find out whether current directory is written already for /l %%k in (0,1,!j!) do ( if /i "!pt!"=="!written[%%k]!" ( rem if it is written already, mark as included set included=T ) ) if not "!included!"=="T" ( rem only write the directory if it is not written already, not included. echo !pt! rem mark the directory as written set /a "j+=1" set written[!j!]=!pt! ) ) )) > %tf% :savecd rem save current path as previous path if /i not "%pth%"=="%cd%" ( if not "%pth%"=="" ( echo %cd%>%tp% ) ) :end endlocal && set ph=%pth% rem change directory if not "%ph%"=="" ( cd /d "%ph%" set ph= )