diff --git a/README.md b/README.md index 363b34f..41dc83a 100644 --- a/README.md +++ b/README.md @@ -213,7 +213,8 @@ zoxide can be installed in 4 easy steps:
cmd.exe - > Add this to the **end** of your config file or AutoRun command: + > Add this to the **end** of your config file or AutoRun command + > (usually `HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun`): > > ```batchfile > zoxide init cmd | cmd /d/q/k echo off diff --git a/man/man1/zoxide-init.1 b/man/man1/zoxide-init.1 index afe04db..7050be0 100644 --- a/man/man1/zoxide-init.1 +++ b/man/man1/zoxide-init.1 @@ -14,7 +14,8 @@ Add this to the \fBend\fR of your config file (usually \fB~/.bashrc\fR): .fi .TP .B cmd.exe -Add this to the \fBend\fR of your config file or AutoRun command: +Add this to the \fBend\fR of your config file or AutoRun command (usually +\fBHKEY_CURRENT_USER\\Software\\Microsoft\\Command Processor\\AutoRun\fR): .sp .nf \fBzoxide init cmd | cmd /d/q/k echo off\fR diff --git a/templates/cmd.txt b/templates/cmd.txt index 22e00bb..e1d31da 100644 --- a/templates/cmd.txt +++ b/templates/cmd.txt @@ -1,6 +1,12 @@ {%- let section = "::: ===========================================================================\n:::" -%} {%- let not_configured = "::: -- not configured --" -%} +{%- if hook != InitHook::None -%} +echo zoxide: hooks are not supported on cmd.exe shell. +echo Use '%program% init cmd --hook none' instead. + +{% endif -%} + @if "%=^%=" == "%=%=" (set \p=%%nul"') do @for %\p%c in (%\p%~s) do @%sysdir%chcp.com %\p%~nc ^>nul 2^>^&1 ^&^& %sysdir%chcp.com 65001 ^>nul 2^>^&1 ^&^& @(for %\p%^^^^ in ("") do @for /f "delims=" %\p%i in (^^""$*%\p%~^^"^") do @if "%\p%~i" equ "" (if "%\p%HOMEDRIVE%\p%%\p%HOMEPATH%\p%" equ "" (for /f "delims=" %\p%d in (^^""%\p%USERPROFILE%\p%"^") do @%__zoxide_cd%) else for /f "delims=" %\p%d in (^^""%\p%HOMEDRIVE%\p%%\p%HOMEPATH%\p%"^") do @%__zoxide_cd%) else if "%\p%~i" equ "~" (if "%\p%HOMEDRIVE%\p%%\p%HOMEPATH%\p%" equ "" (for /f "delims=" %\p%d in (^^""%\p%USERPROFILE%\p%"^") do @%__zoxide_cd%) else for /f "delims=" %\p%d in (^^""%\p%HOMEDRIVE%\p%%\p%HOMEPATH%\p%"^") do @%__zoxide_cd%) else if "%\p%~i" equ "-" (if defined OLDPWD (for /f "delims=" %\p%d in (^^""%\p%OLDPWD%\p%"^") do @%__zoxide_cd%) else ^>^&2 (echo(%program%: OLDPWD not set) ^& call) else for /f "delims=" %\p%~ in (^^"%\p%~i^") do @for /f "tokens=1,* delims=d" %\p%a in ("-%\p%~a~") do @if "%\p%b" neq "" (for /f "delims=" %\p%d in (^^""%\p%~f~"^") do @%__zoxide_cd%) else if /i "%\p%CD%\p%" neq "%\p%__CD__%\p%" (for /f "delims=" %\p%q in ('^^"%program% query --exclude "%\p%CD%\p%" -- %\p%~i^"') do @(for /f "delims=" %\p%d in (^^""%\p%~fq"^") do @%__zoxide_cd%)) else (for /f "delims=" %\p%q in ('^^"%program% query --exclude "%\p%__CD__%\p%\" -- %\p%~i^"') do @(for /f "delims=" %\p%d in (^^""%\p%~fq"^") do @%__zoxide_cd%))) ^&^& %sysdir%chcp.com %\p%~nc ^>nul 2^>^&1 ^|^| %sysdir%chcp.com %\p%~nc ^>nul 2^>^&1 ^&^& call @@ -55,7 +47,8 @@ set __zoxide_cd=if /i "%\p%CD%\p%" neq "%\p%~fd" (%builtin_cd% "%\p%~fd" ^^^&^^^ {%- endmatch %} {{ section }} -::: To initialize zoxide, add this to your configuration or AutoRun command: +::: To initialize zoxide, add this to your configuration or AutoRun command +::: (usually HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun): ::: ::: zoxide init cmd | cmd /d/q/k echo off