Skip to content

Conversation

janlazo
Copy link
Contributor

@janlazo janlazo commented Jul 9, 2017

Modified the default command in Windows to match the description in the README

Without STDIN pipe, fzf will use find command to fetch the list of files excluding hidden ones. (You can override the default command with FZF_DEFAULT_COMMAND)

@janlazo
Copy link
Contributor Author

janlazo commented Jul 9, 2017

The following command removes the current directory of the path to display relative paths

cmd.exe /q/V:ON/c "for /f %A in ('dir /s/b/a:-d-h 2^> nul') DO set RELPATH=%A & echo !RELPATH:%cd%\=!"

/q is for @echo off
/v:ON is to enable variable expansion in runtime

If there are no files, an error appears so redirection to nul is required.

janlazo added a commit to janlazo/fzf.vim that referenced this pull request Jul 15, 2017
- use dir for file/path completion (see junegunn/fzf#971)
- double-quote shell args via 'set noshellslash' for cmd.exe
@janlazo
Copy link
Contributor Author

janlazo commented Aug 17, 2017

#971 (comment) is necessary to omit network drive for the preview. /a:-d-h is optional.

@janlazo janlazo changed the title Default command lists non-hidden files in Windows Default command outputs relative filepath for preview to work in Windows Aug 17, 2017
@janlazo janlazo force-pushed the bin/default_command branch from 4270263 to 1a9d09a Compare August 18, 2017 01:02
@janlazo
Copy link
Contributor Author

janlazo commented Aug 18, 2017

@junegunn Can you test if it works for you? I compiled using mingw32-make.exe from http://tdm-gcc.tdragon.net/download and preview works for me because the network drive is removed.

You can test it out in fzf.vim after forcing forward slashes (or escaping the backslash) on the filepath of the preview script
Reference: janlazo/fzf.vim@3657fc6#diff-7274b7c6c87526542ef9087f2e997dfaR38

Edit:
I mixed it up with FZF_DEFAULT_COMMAND.

@janlazo
Copy link
Contributor Author

janlazo commented Aug 19, 2017

I give on this.
For loop begins after dir is done so it is slow in large projects.
There's no native windows solution I can think of that has comparable speed to dir, can be configured and piped, and won't slow down the system.

@janlazo janlazo closed this Aug 19, 2017
@janlazo janlazo deleted the bin/default_command branch August 19, 2017 00:05
@junegunn
Copy link
Owner

I see, thanks for looking into it.

There's no native windows solution

Many users of fzf on *nix use ag or rg instead of find as the default command, if there are equivalent solutions on Windows, we can suggest those to the users.

@janlazo
Copy link
Contributor Author

janlazo commented Aug 19, 2017

From my previous note about powershell for relative paths, I recommend rg because of UTF-16 support and sift because only the prebuilt binary is required.

@junegunn
Copy link
Owner

It would be great if you could mention your findings here: https://github.com/junegunn/fzf/wiki/Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants