Skip to content

Add support for cmd.exe (experimental) #567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 34 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
252031c
Add support for `cmd.exe` (experimental)
mataha May 10, 2023
1586672
Mark template tests with `cfg` directives
mataha May 11, 2023
5cbf4b6
Update `dunce` to 1.0.4
mataha Jun 5, 2023
faa9172
Normalize path prefix on Windows
mataha Jun 5, 2023
d9af067
Add tests for path prefix normalization
mataha Jun 5, 2023
ee0a322
Make the test run
mataha Jun 5, 2023
a707db0
Fix rustfmt errors
mataha Jun 5, 2023
e87922c
Make percent characters work in all contexts
mataha Jun 6, 2023
d07d03b
Disable delayed expansion in `cmd init`
mataha Jun 6, 2023
a8b7b38
Fix whitespace suppression in `cmd.exe` template
mataha Jun 6, 2023
629faf2
Make sure `OLDPWD` is not set
mataha Jun 7, 2023
d067954
Don't run with Command Extensions disabled
mataha Jun 7, 2023
3ba7f2c
Make the Command Extensions requirement more clear
mataha Jun 11, 2023
35da686
Don't hardcode command names
mataha Jun 11, 2023
4e74256
Fall back to being `cd` if directory exists
mataha Jun 11, 2023
8122bf3
Quote external command macros directly
mataha Jun 11, 2023
53ca692
Sanitize trailing backslash when in root directory
mataha Jun 11, 2023
12ebd3d
Quit if Command Extensions are disabled
mataha Jun 11, 2023
c1a7ccc
Tighten the check for command-line context
mataha Jun 17, 2023
8e0d311
Initialize hook only if it's a `pwd` hook
mataha Jun 17, 2023
bec9717
Add common shorthands as command aliases
mataha Jun 17, 2023
410ca54
WIP
mataha Jun 10, 2024
de8fb59
Be consistent when comparing comptime strings
mataha Jun 10, 2024
94ba939
WIP
mataha Jun 10, 2024
ec460d9
Fix Windows dependencies
mataha Jun 10, 2024
aab7b52
Make clippy and rustfmt happy
mataha Jun 10, 2024
aebab75
Make markdownlint happy
mataha Jun 10, 2024
a99db4a
Update documentation
mataha Jun 10, 2024
2bf0644
Code cleanup
mataha Jun 10, 2024
3793b8f
Fix newlines
mataha Jun 14, 2024
7bc5e2b
Fix stdin end of input
mataha Jun 14, 2024
027320e
Fix formatting
mataha Jun 15, 2024
123d1e7
Consider PATHEXT when searching for fzf binary
mataha Jun 16, 2024
06e6031
Switch to labeled comments
mataha Jul 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make clippy and rustfmt happy
mataha committed Jun 10, 2024
commit aab7b5238b8e7c8aebce3a6f4a0429b23864bd59
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -12,5 +12,5 @@ trim_trailing_whitespace = true
indent_size = unset
trim_trailing_whitespace = false

[*.{nix,ts,yml,zsh}]
[*.{nix,ts,yml}]
indent_size = 2
4 changes: 0 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#![allow(clippy::single_component_path_imports)]

// rstest_reuse must be imported at the top of the crate.
#[cfg(all(test, feature = "nix-dev"))]
use rstest_reuse;

mod cmd;
mod config;
mod db;
4 changes: 2 additions & 2 deletions templates/cmd.txt
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ rem Utility functions for zoxide.
rem

rem pwd based on the value of _ZO_RESOLVE_SYMLINKS.
set __zoxide_pwd= {%- if resolve_symlinks -%} (for /f "skip=9 tokens=1,2,*" %\p%j in ('^^^^^^^^""%SystemRoot%\system32\fsutil.exe" reparsepoint query .^"') do @if "%\p%~j" == "Print" if "%\p%~k" == "Name:" if not "%\p%~l" == "" (echo(%%~l)) ^^^^^^^|^^^^^^^| {%~ endif -%} %__builtin_pwd%
set __zoxide_pwd= {%- if resolve_symlinks -%} (for /f "skip=9 tokens=1,2,*" %\p%j in ('^^^^^^^^""%SystemRoot%\system32\fsutil.exe" reparsepoint query .^"') do @if "%\p%~j" equ "Print" if "%\p%~k" equ "Name:" if "%\p%~l" neq "" (echo(%\p%~l)) ^^^^^^^|^^^^^^^| {%~ endif -%} %__builtin_pwd%

rem cd + custom logic based on the value of _ZO_ECHO.
set __zoxide_cd=if /i "%\p%CD%\p%" neq "%\p%~fc" (%__builtin_cd% "%\p%~fc" ^^^&^^^& set "OLDPWD=%\p%CD%\p%" ^^^&^^^& (for /f "delims=" %\p%l in ('"%__builtin_pwd%"') do @if /i "%\p%~fl" neq "%\p%~dpl" (%__program% add -- "%\p%~fl") else (%__program% add -- "%\p%~dpl\")) {%- if echo ~%} ^^^&^^^& %__zoxide_pwd% {%- endif ~%} ^^^&^^^& if defined CDCMD (call %\p%CDCMD%\p%))
@@ -46,7 +46,7 @@ rem
set __zoxide_command={{ cmd }}

rem Jump to a directory using only keywords.
"%SystemRoot%\system32\doskey.exe" %__zoxide_command% = @(for %\p%^^^^ in ("") do @for /f "delims=" %\p%i in (^^""$*%\p%~^^"^") do @if "%\p%~i" == "" (if "%\p%HOMEDRIVE%\p%%\p%HOMEPATH%\p%" == "" (for /f "delims=" %\p%c in (^^""%\p%USERPROFILE%\p%"^") do @%__zoxide_cd%) else for /f "delims=" %\p%c in (^^""%\p%HOMEDRIVE%\p%%\p%HOMEPATH%\p%"^") do @%__zoxide_cd%) else if "%\p%~i" == "~" (if "%\p%HOMEDRIVE%\p%%\p%HOMEPATH%\p%" == "" (for /f "delims=" %\p%c in (^^""%\p%USERPROFILE%\p%"^") do @%__zoxide_cd%) else for /f "delims=" %\p%c in (^^""%\p%HOMEDRIVE%\p%%\p%HOMEPATH%\p%"^") do @%__zoxide_cd%) else if "%\p%~i" == "-" (if defined OLDPWD (for /f "delims=" %\p%c 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 not "%\p%b" == "" (for /f "delims=" %\p%c 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%c 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%c in (^^""%\p%~fq"^") do @%__zoxide_cd%))) ^&^& call ;
"%SystemRoot%\system32\doskey.exe" %__zoxide_command% = @(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%c in (^^""%\p%USERPROFILE%\p%"^") do @%__zoxide_cd%) else for /f "delims=" %\p%c 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%c in (^^""%\p%USERPROFILE%\p%"^") do @%__zoxide_cd%) else for /f "delims=" %\p%c in (^^""%\p%HOMEDRIVE%\p%%\p%HOMEPATH%\p%"^") do @%__zoxide_cd%) else if "%\p%~i" equ "-" (if defined OLDPWD (for /f "delims=" %\p%c 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%c 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%c 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%c in (^^""%\p%~fq"^") do @%__zoxide_cd%))) ^&^& call ;

rem Jump to a directory using interactive search.
"%SystemRoot%\system32\doskey.exe" %__zoxide_command%i = @(for %\p%^^^^ in ("") do @for /f "delims=" %\p%i in (^^""$*%\p%~^^"^") do @for /f "delims=" %\p%p in ('^^"%__program% query --interactive -- %\p%~i^"') do @for /f "delims=" %\p%c in (^^""%\p%~fp"^") do @%__zoxide_cd%) ^&^& call ;
4 changes: 2 additions & 2 deletions zoxide.plugin.zsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if (( $+commands[zoxide] )); then
eval "$(zoxide init zsh)"
eval "$(zoxide init zsh)"
else
echo 'zoxide: command not found, please install it from https://github.com/ajeetdsouza/zoxide'
echo 'zoxide: command not found, please install it from https://github.com/ajeetdsouza/zoxide'
fi