All Projects → kelleyma49 → Psfzf

kelleyma49 / Psfzf

Licence: mit
A PowerShell wrapper around the fuzzy finder fzf

Programming Languages

powershell
5483 projects

Projects that are alternatives of or similar to Psfzf

Dots
Personal *nix configuration files
Stars: ✭ 136 (-27.27%)
Mutual labels:  fzf
Kube Fzf
Shell commands using kubectl and fzf for command-line fuzzy searching of Kubernetes Pods.
Stars: ✭ 153 (-18.18%)
Mutual labels:  fzf
Macos Downloader
Command line tool for downloading macOS installers and beta updates
Stars: ✭ 162 (-13.37%)
Mutual labels:  commandline
Blame Bird
Checks which app uses lots of space in the `Library/Caches/com.apple.bird` folder
Stars: ✭ 142 (-24.06%)
Mutual labels:  commandline
Wifi Password
Quickly fetch your WiFi password and if needed, generate a QR code of your WiFi to allow phones to easily connect
Stars: ✭ 2,325 (+1143.32%)
Mutual labels:  commandline
Comfy Table
🔶 Build beautiful terminal tables with automatic content wrapping
Stars: ✭ 156 (-16.58%)
Mutual labels:  commandline
Hd Wallet Derive
A command-line tool that derives bip32 addresses and private keys.
Stars: ✭ 125 (-33.16%)
Mutual labels:  commandline
Reactopt
A CLI React performance optimization tool that identifies potential unnecessary re-rendering
Stars: ✭ 1,975 (+956.15%)
Mutual labels:  commandline
Gitin
commit/branch/workdir explorer for git
Stars: ✭ 1,815 (+870.59%)
Mutual labels:  commandline
Joincap
Merge multiple pcap files together, gracefully.
Stars: ✭ 159 (-14.97%)
Mutual labels:  commandline
Taskwarrior
Taskwarrior - Command line Task Management
Stars: ✭ 2,239 (+1097.33%)
Mutual labels:  commandline
Ctop
Top-like interface for container metrics
Stars: ✭ 12,188 (+6417.65%)
Mutual labels:  commandline
Fzf Scripts
a collection of scripts that rely on https://github.com/junegunn/fzf
Stars: ✭ 158 (-15.51%)
Mutual labels:  fzf
Brotab
Control your browser's tabs from the command line
Stars: ✭ 137 (-26.74%)
Mutual labels:  commandline
Z.lua
⚡ A new cd command that helps you navigate faster by learning your habits.
Stars: ✭ 2,164 (+1057.22%)
Mutual labels:  fzf
Fzf Tab Completion
Tab completion using fzf
Stars: ✭ 127 (-32.09%)
Mutual labels:  fzf
Licenseplist
A license list generator of all your dependencies for iOS applications
Stars: ✭ 1,996 (+967.38%)
Mutual labels:  commandline
You Dont Need Gui
Stop relying on GUI; CLI **ROCKS**
Stars: ✭ 4,766 (+2448.66%)
Mutual labels:  commandline
Tmux 1password
🔑 Access your 1Password login items within tmux!
Stars: ✭ 167 (-10.7%)
Mutual labels:  fzf
Enhancd
🚀 A next-generation cd command with your interactive filter
Stars: ✭ 2,049 (+995.72%)
Mutual labels:  fzf

PSFzf

PowerShell Gallery Build status MIT licensed

PSFzf is a PowerShell module that wraps fzf, a fuzzy file finder for the command line.

Usage

To change to a user selected directory:

Get-ChildItem . -Recurse -Attributes Directory | Invoke-Fzf | Set-Location

To edit a file:

Get-ChildItem . -Recurse -Attributes !Directory | Invoke-Fzf | % { notepad $_ }

For day-to-day usage, see the helper functions included with this module.

PSReadline Integration

Select Current Provider Path (default chord: Ctrl+t)

Press Ctrl+t to start PSFzf to select provider paths. PSFzf will parse the current token and use that as the starting path to search from. If current token is empty, or the token isn't a valid path, PSFzf will search below the current working directory.

Multiple items can be selected. If more than one is selected by the user, the results are returned as a comma separated list. Results are properly quoted if they contain whitespace.

Reverse Search Through PSReadline History (default chord: Ctrl+r)

Press Ctrl+r to start PSFzf to select a command in the command history saved by PSReadline. PSFzf will insert the command into the current line, but it will not execute the command.

PSFzf does not override Ctrl+r by default. To confirm that you want to override PSReadline's chord binding, use the Set-PsFzfOption command:

# replace 'Ctrl+t' and 'Ctrl+r' with your preferred bindings:
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r'

Set-Location Based on Selected Directory (default chord: Alt+c)

Press Alt+c to start PSFzf to select a directory. Set-Location will be called with the selected directory.

Search Through Command Line Arguments in PSReadline History (default chord: Alt+a)

Press Alt+a to start PSFzf to select command line arguments used in PSReadline history. The picked argument will be inserted in the current line. The line that would result from the selection is shown in the preview window.

Tab Expansion

PSFzf can replace the standard tab completion:

Set-PSReadLineKeyHandler -Key Tab -ScriptBlock { Invoke-FzfTabCompletion }

To activate continuous completion, press the directory separator character to complete the current selection and start tab completion for the next part of the container path.

PSFzf supports specialized tab expansion with a small set of commands. After typing the default trigger command, which defaults to "**", and press Tab, PsFzf tab expansion will provide selectable list of options.

The following commands are supported:

Command Notes
git Uses posh-git for providing tab completion options. Requires at least version 1.0.0 Beta 4.
Get-Service, Start-Service, Stop-Service Allows the user to select between the installed services.
Get-Process, Start-Process Allows the user to select between running processes.

To override the trigger command, set FZF_COMPLETION_TRIGGER to your preferred trigger sequence.

Use the following command to enable tab expansion:

Set-PsFzfOption -TabExpansion

Using within a Pipeline

Invoke-Fzf works with input from a pipeline. However, if you make your selection before fzf has finished receiving and parsing from standard in, you might see a Stopped pipeline input error. This is because PSFzf must throw an exception to cancel pipeline processing. If you pipe the output of Invoke-Fzf to whatever action you wish to do based on your selection, the action will occur. The following will not work if the pipeline is cancelled:

Set-Location (Get-ChildItem . -Recurse | ? { $_.PSIsContainer } | Invoke-Fzf)

The following will work if the pipeline is cancelled:

Get-ChildItem . -Recurse | ? { $_.PSIsContainer } | Invoke-Fzf | Set-Location

Overriding Behavior

PsFzf supports overriding behavior by setting these fzf environment variables:

  • FZF_DEFAULT_COMMAND - The command specified in this environment variable will override the default command when PSFZF detects that the current location is a file system provider.
  • FZF_CTRL_T_COMMAND - The command specified in this environment variable will be used when Ctrl+t is pressed by the user.
  • FZF_Alt_C_COMMAND - The command specified in this environment variable will be used when Alt+c is pressed by the user.

Helper Functions

In addition to its core function Invoke-Fzf, PSFzf includes a set of useful functions and aliases:

Function Alias Description
Invoke-FuzzyEdit fe Starts an editor for the selected files in the fuzzy finder.
Invoke-FuzzyFasd ff Starts fzf with input from the files saved in fasd (non-Windows) or fasdr (Windows) and sets the current location.
Invoke-FuzzyZLocation fz Starts fzf with input from the history of ZLocation and sets the current location.
Invoke-FuzzyGitStatus fgs Starts fzf with input from output of the git status function.
Invoke-FuzzyHistory fh Rerun a previous command from history based on the user's selection in fzf.
Invoke-FuzzyKillProcess fkill Runs Stop-Process on processes selected by the user in fzf.
Invoke-FuzzySetLocation fd Sets the current location from the user's selection in fzf.
Set-LocationFuzzyEverything cde Sets the current location based on the Everything database.

Prerequisites

Follow the installation instructions for fzf before installing PSFzf. PSFzf will run Get-Command to find fzf in your path.

Windows

The latest version of fzf is available via Chocolatey, or you can download the fzf binary and place it in your path. Run Get-Command fzf*.exe to verify that PowerShell can find the executable.

PSFzf has been tested under PowerShell 5.0 & 6.0.

MacOS

Use Homebrew or download the binary and place it in your path. Run Get-Command fzf* to verify that PowerShell can find the executable.

PSFzf has been tested under PowerShell 6.0.

Linux

PSFzf has been tested under PowerShell 6.0 in the Windows Subsystem for Linux.

Installation

PSFzf is available on the PowerShell Gallery. PSReadline should be imported before PSFzf as PSFzf registers PSReadline key handlers listed in the PSReadline integration section.

Helper Function Requirements

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].