diff --git a/.editorconfig b/.editorconfig index b4d1b33..b18438d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,7 +8,7 @@ indent_style = space insert_final_newline = true trim_trailing_whitespace = true -[*.(md,rst,txt}] +[*.{md,rst,txt}] indent_size = unset trim_trailing_whitespace = false diff --git a/README.md b/README.md index c30c802..445248a 100644 --- a/README.md +++ b/README.md @@ -216,7 +216,7 @@ zoxide can be installed in 4 easy steps: > Add this to the **end** of your config file or AutoRun command: > > ```batchfile - > zoxide init cmd --hook none | cmd /d/q/k >nul + > zoxide init cmd | cmd /d/q/k echo off > ``` diff --git a/man/man1/zoxide-init.1 b/man/man1/zoxide-init.1 index 6a2e706..afe04db 100644 --- a/man/man1/zoxide-init.1 +++ b/man/man1/zoxide-init.1 @@ -17,7 +17,7 @@ Add this to the \fBend\fR of your config file (usually \fB~/.bashrc\fR): Add this to the \fBend\fR of your config file or AutoRun command: .sp .nf - \fBzoxide init cmd --hook none | cmd /d/q/k >nul\fR + \fBzoxide init cmd | cmd /d/q/k echo off\fR .fi .TP .B elvish diff --git a/src/shell.rs b/src/shell.rs index 5ab873c..d4c2fd1 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -105,15 +105,15 @@ mod tests { let source = Cmd(&opts).render().unwrap(); let assert = Command::new(which::which("cmd.exe").unwrap()) - .args(["/d", "/x", "/k"]) + .args(["/x", "/d", "/q", "/k", "echo off"]) + .env("PROMPT", "") .write_stdin(source) .assert() - .success(); + .success() + .stderr(""); - if opts.hook != InitHook::None { - assert.stderr("zoxide: hooks are not supported on cmd.exe shell.\r\n"); - } else { - assert.stderr(""); + if opts.hook == InitHook::None { + assert.stdout(""); } } @@ -124,15 +124,15 @@ mod tests { let source = Cmd(&opts).render().unwrap(); let assert = Command::new(which::which("cmd.exe").unwrap()) - .args(["/d", "/y", "/k"]) + .args(["/y", "/d", "/q", "/k", "echo off"]) + .env("PROMPT", "") .write_stdin(source) .assert() - .success(); + .success() + .stderr(""); - if opts.hook != InitHook::None { - assert.stderr("zoxide: hooks are not supported on cmd.exe shell.\r\n"); - } else { - assert.stderr(""); + if opts.hook == InitHook::None { + assert.stdout(""); } } diff --git a/templates/cmd.txt b/templates/cmd.txt index eae30ec..802b16c 100644 --- a/templates/cmd.txt +++ b/templates/cmd.txt @@ -3,11 +3,7 @@ rem Code generated by zoxide. DO NOT EDIT. -@if "%=^%=" == "%=%=" ( - set \p=%%&2 echo %__program%: hooks are not supported on cmd.exe shell. +echo %__program%: hooks are not supported on cmd.exe shell. +echo Use '%__program% init cmd --hook none' instead. {%- else -%} {{ not_configured }} @@ -60,4 +57,9 @@ rem Jump to a directory using interactive search. {{ section }} rem To initialize zoxide, add this to your configuration or AutoRun command: rem -rem zoxide init cmd --hook none | cmd /d/q/k >nul +rem zoxide init cmd | cmd /d/q/k echo off + +{#~ + Content piped to `cmd.exe` needs to end with an empty line to indicate end of + input. Removing this will cause extra "More? " to be written to stdout. +#}