Home

Awesome

PathPicker

tests License: MIT

Facebook PathPicker is a simple command line tool that solves the perpetual problem of selecting files out of bash output. PathPicker will:

It is easiest to understand by watching a simple demo:

<a href="https://asciinema.org/a/19519" target="_blank"><img src="https://asciinema.org/a/19519.png" width="597"/></a>

Examples

After installing PathPicker, using it is as easy as piping into fpp. It takes a wide variety of input -- try it with all the options below:

and anything else you can dream up!

Requirements

PathPicker requires Python 3.

Supported Shells

Installing PathPicker

Homebrew

Installing PathPicker is easiest with Homebrew for mac:

Linux

On Debian-based systems, run these steps: fakeroot:

$ git clone https://github.com/facebook/PathPicker.git
$ cd PathPicker/debian
$ ./package.sh
$ ls ../pathpicker_*_all.deb

On Arch Linux, PathPicker can be installed from Arch User Repository (AUR). (The AUR fpp-git package.)

If you are on another system, or prefer manual installation, please follow the instructions given below.

Manual Installation

If you are on a system without Homebrew, it's still quite easy to install PathPicker, since it's essentially just a bash script that calls some Python. These steps more-or-less outline the process:

Here we create a symbolic link from the bash script in the repo to /usr/local/bin/ which is assumed to be in the current $PATH:

Add-ons

For tmux users, you can additionally install tmux-fpp which adds a key combination to run PathPicker on the last received stdout. This makes jumping into file selection mode even easier. (Check it out here!)

Advanced Functionality

As mentioned above, PathPicker allows you to also execute arbitrary commands using the specified files. Here is an example showing a git checkout command executed against the selected files:

<a href="https://asciinema.org/a/19520" target="_blank"><img src="https://asciinema.org/a/19520.png" width="597"/></a>

The selected files are appended to the command prefix to form the final command. If you need the files in the middle of your command, you can use the $F token instead, like:

cat $F | wc -l

Another important note is that PathPicker, by default, only selects files that exist on the filesystem. If you want to skip this (perhaps to selected deleted files in git status), just run PathPicker with the --no-file-checks (or -nfc, for short) flag.

How PathPicker works

PathPicker is a combination of a bash script and some small Python modules. It essentially has three steps:

The downside to this is that files that are single words, with no extension (like test), that are not prepended by a directory will fail to match. This is a known limitation to PathPicker, and means that it will sometimes fail to find valid files in the input.

It's not the most elegant architecture in the world but, in our opinion, it provides a lot of utility.

Documentation & Configuration

For all documentation and configuration options, see the output of fpp --help.

Join the PathPicker community

See the CONTRIBUTING.md file for how to help out.

License

PathPicker is MIT licensed.