Skip to content
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

Use powershell for default command on Windows #960

Closed
2 of 15 tasks
janlazo opened this issue Jul 1, 2017 · 4 comments
Closed
2 of 15 tasks

Use powershell for default command on Windows #960

janlazo opened this issue Jul 1, 2017 · 4 comments
Labels

Comments

@janlazo
Copy link
Contributor

janlazo commented Jul 1, 2017

  • Category
    • fzf binary
    • fzf-tmux script
    • Key bindings
    • Completion
    • Vim
    • Neovim
    • Etc.
  • OS
    • Linux
    • Mac OS X
    • Windows
    • Windows Subsystem for Linux
    • Etc.
  • Shell
    • bash
    • zsh
    • fish

dir /s/b does not filter hidden directories/files and its results cannot be piped to another dir command.
I can't get dir /b/a:-d-h | dir /s/b to work in cmd.exe to filter hidden directories before recursing on subfolders.

Powershell does not have these issues because of object piping and output customization.
The following command works in cmd.exe and runs powershell on default settings to recursively get all non-hidden files. This takes up more time but removes files in hidden directories such as .git. Additional parameters are added to the powershell.exe to reduce the startup time.

powershell.exe -NoLogo -NoProfile -Noninteractive -Command "Get-ChildItem -File -Recurse | ForEach-Object {echo $_.FullName}"

Edit:
Get-ChildItem supports -Name for relative path so object piping is not required.

powershell.exe -NoLogo -NoProfile -Noninteractive -Command "Get-ChildItem -File -Recurse -Name"
@janlazo janlazo changed the title User powershell for default command on Windows Use powershell for default command on Windows Jul 2, 2017
@kelleyma49
Copy link
Contributor

Unfortunately PowerShell is really slow. I love PowerShell, but dir is way faster, and that's what I use for my PowerShell wrapper module: https://github.com/kelleyma49/PSFzf/blob/master/PSFzf.psm1#L346.

Another option is to create and compile a small app written in C# or C++ that can do the directory listings.

@janlazo
Copy link
Contributor Author

janlazo commented Jul 5, 2017

It's speed vs accuracy.

a) Get 10000+ results but require non-trivial search syntax to reduce to 10%. Hope that the path is short enough to see the file in the rightmost side of the cmd.exe terminal.
b) Wait 3-5 seconds but the results are down to 100 and you can see what you need. Trival search syntax can reduce number of entries to single digits.

Without STDIN pipe, fzf will use find command to fetch the list of files excluding hidden ones.

The updated powershell command achieves this with similar output to the find command.
The slow startup issue can be minimized by using cmd as the main shell and not piping the command (let fzf run the command directly).

My everyday experience with fzf is run :FZF in Vim, see a lot of files and directories in hidden directories, force an exact match of the file I'm looking for, look at the rightmost side of the cmd.exe terminal for the first few letters of the filename and select it with 50% chance that the file has the right extension I'm looking for.

@janlazo
Copy link
Contributor Author

janlazo commented Jul 6, 2017

powershell has a pipeline issue where the equivalent of kill in Windows is required to stop it after fzf exits. Not stopping it prevents the cmd.exe process from closing so the Vim plugin is affected.

janlazo added a commit to janlazo/fzf that referenced this issue Jul 8, 2017
janlazo added a commit to janlazo/fzf that referenced this issue Jul 9, 2017
janlazo added a commit to janlazo/fzf that referenced this issue Jul 9, 2017
junegunn pushed a commit that referenced this issue Jul 9, 2017
@janlazo
Copy link
Contributor Author

janlazo commented Jul 9, 2017

Running fzf consecutively with powershell as default command slows down low-spec machines even if fzf exits. Same applies to the Windows port of find, ack, and ag.

The issue remains that the directories and hidden files appear in the default command.
I recommend dir /s/b/a:-d-h as default command in the fzf executable to output non-hidden files only.
If the user prefers relative paths, I recommend ripgrep (via chocolatey) or sift (standalone binary inside the downloadable zip from its website). I use sift because ripgrep has more dependencies.

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

No branches or pull requests

3 participants