PathPicker accepts a wide range of input -- output from git commands, grep results, searches -- pretty much anything.After parsing the input, PathPicker presents you with a nice UI to select which files you're interested in. After that you can open them in your favorite editor or execute arbitrary commands.

Overview

PathPicker

Build Status

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

  • Parse all incoming lines for entries that look like files
  • Present the piped input in a convenient selector UI
  • Allow you to either:
    • Edit the selected files in your favorite $EDITOR
    • Execute an arbitrary command with them

It is easiest to understand by watching a simple demo:

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:

  • git status | fpp
  • hg status | fpp
  • git grep "FooBar" | fpp
  • grep -r "FooBar" . | fpp
  • git diff HEAD~1 --stat | fpp
  • find . -iname "*.js" | fpp
  • arc inlines | fpp

and anything else you can dream up!

Requirements

PathPicker requires Python >2.6 or >3.0.

Supported Shells

  • Bash is fully supported and works the best.
  • ZSH is supported as well, but won't have a few features like alias expansion in command line mode.
  • csh/fish/rc are supported in the latest version, but might have quirks or issues in older versions of PathPicker. Note: if your default shell and current shell is not in the same family (bash/zsh... v.s. fish/rc), you need to manually export environment variable $SHELL to your current shell.

Installing PathPicker

Homebrew

Installing PathPicker is easiest with Homebrew for mac:

  • brew update (to pull down the recipe since it is new)
  • brew install fpp

Linux

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

$ git clone https://github.com/facebook/PathPicker.git
$ cd PathPicker/debian
$ ./package.sh 
$ ls ../fpp_0.7.2_noarch.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:

  • cd /usr/local/ # or wherever you install apps
  • git clone https://github.com/facebook/PathPicker.git
  • cd PathPicker/

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:

  • ln -s "$(pwd)/fpp" /usr/local/bin/fpp
  • fpp --help # should work!

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:

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:

  • Firstly, the bash script redirects all standards out into a python module that parses and extracts out filename candidates. These candidates are extracted with a series of regular expressions, since the input to PathPicker can be any stdout from another program. Rather than make specialized parsers for each program, we treat everything as noisy input, and select candidates via regexes. To limit the number of calls to the filesystem (to check existence), we are fairly restrictive on the candidates we extract.

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.

  • Next, a selector UI built with curses is presented to the user. At this point you can select a few files to edit, or input a command to execute.

  • Lastly, the python script outputs a command to a bash file that is later executed by the original bash script.

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.

License: MIT

Comments
  • Created a script for automatic creation of .deb packages from source Resolve #43

    Created a script for automatic creation of .deb packages from source Resolve #43

    As mentioned by @pcottle , I have made the necessary additions to makeDist.py and created all necessary files in debian directory which would facilitate the creation of the debian package. Please review.

    I have already accepted Facebook's Contributor License Agreement (CLA).

    CLA Signed 
    opened by pallavagarwal07 30
  • Linux packages

    Linux packages

    It would be good to have Linux packages available, at least .deb and .rpm versions. I don't know anyone that uses Linuxbrew, it doesn't seem ideal on Linux when better solutions exist.

    The HHVM team distribute Linux packages, you could probably see how they do it.

    help wanted 
    opened by Daniel15 29
  • Doesn't work when login shell is csh

    Doesn't work when login shell is csh

    Darwin wkoszek-macbook.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64

    My login shell is CSH. To rule out CSH, I've run Bash in iTerm2 window and tested too. Same problem. I tested in Vagrant with ubuntu/trusty64. Stuff works OK there, so what I describe below seems to be MacOSX specific.

    I did:

    brew update brew install fpp.

    cd /tmp mkdir sample cd sample cal 2010 > 2010 cal 2011 > 2011 cal 2012 > 2012

    /bin/ls -1 ./* | fpp

    I select 2010, press f, select 2011, press f, press c, type 'cat', . Nothing happens. I'm dropped to fpp subshell. I'd expect to see output from cat'ed files.

    ---------------- cat ~/.fpp/.fpp.sh ---------------------- if type shopt > /dev/null; then shopt -s expand_aliases fi

    echo "executing command:" echo "cat './2010' './2011'"

    cat './2010' './2011'

    So selection part works OK. Execution is doing something wrong.

    I started to add some debugging code: https://github.com/wkoszek/PathPicker/

    opened by wkoszek 25
  • ANSI color support

    ANSI color support

    ~~This is a shitty first pass at colors that I hacked together because I couldn't sleep.~~ Now better!

    Turns out ncurses doesn't really support (AFAIK, someone please correct me...) setting foreground/background color combinations directly, so I cache and create color_pair as I go along. Most terms have at least 32 and mine on OSX seems to have 256.

    I'm also totally not a python developer, so the code here is probably quite not idomatic.

    Screencap because I don't know how to do that cool video thing: the command was git diff --color | fpp screen shot 2015-05-08 at 3 30 50 am

    Things to improve on

    • Make the chrome use colors instead of hardcoding color_pair(0).
    CLA Signed 
    opened by lastquestion 16
  • Allow specifying command as an argument to fpp

    Allow specifying command as an argument to fpp

    Would this be possible? Something like:

    git status | fpp -c 'git add'

    So that the default action is overridden and I can just hit 'enter' after selecting files to run git add on them.

    enhancement pcottle-ASAP 
    opened by xatnys 15
  • Allow preconfigured commands through custom key bindings

    Allow preconfigured commands through custom key bindings

    For use cases where PP is used frequently with the same command, it's quite annoying to have to always type the same command (eg. rspec for Ruby testing).

    This PR allows the user to associate custom commands that can be executed through specified keys (eg. r for rspec), speeding up the PP workflow for repetitive command executions.

    Custom bindings/commands are stored in the <FPP_DIR>/.fpp.keys (in the [bindings] group) as standard text configuration file. The existing clean FPP internal interface allows such configuration functionality to be trivially extended, for example, in case FPP will implement a static configuration.

    This implementation is the simplest possible; notably, it doesn't support keys already bound (which would significantly complicate the feature).

    Due to the test framework, it's not easy to write an end-to-end test - in fact, the existing functionality for executing command hasn't this type of tests; therefore, the test have been updated to inspect the visualization of the custom keys/commands.

    CLA Signed 
    opened by 64kramsystem 14
  • PathPicker pollutes user home directory

    PathPicker pollutes user home directory

    PathPicker creates multiple files in the user home directory:

    $ ls .fb*
    .fbPager.log  .fbPager.pickle  .fbPager.selection.pickle  .fbPager.sh
    

    Normally such files are stored under $HOME/.local/share or $HOME/.config directory on Linux. Please see XDG Base Directory Specification for details.

    opened by vitaut 14
  • ImportError: No module named builtins

    ImportError: No module named builtins

    I just installed fpp using brew install fpp. When I try to run it, this is the output:

    Traceback (most recent call last):
      File "/usr/local/Cellar/fpp/0.8.2/libexec/src/processInput.py", line 12, in <module>
        import format
      File "/usr/local/Cellar/fpp/0.8.2/libexec/src/format.py", line 13, in <module>
        from formattedText import FormattedText
      File "/usr/local/Cellar/fpp/0.8.2/libexec/src/formattedText.py", line 9, in <module>
        from colorPrinter import ColorPrinter
      File "/usr/local/Cellar/fpp/0.8.2/libexec/src/colorPrinter.py", line 7, in <module>
        import output
      File "/usr/local/Cellar/fpp/0.8.2/libexec/src/output.py", line 8, in <module>
        from builtins import str
    ImportError: No module named builtins
    

    Am I missing anything?

    opened by friederbluemle 12
  • added test case for describe file feature

    added test case for describe file feature

    is there a better way to add a change to a PR that was already merged and closed?

    anyways, here's a passing test case, let me know if that's not what you were looking for πŸ˜„

    CLA Signed awaiting-reply 
    opened by rjdean123 12
  • Add executed command to shell history

    Add executed command to shell history

    It would be helpful if the executed command would be [optionally] added to the shell history.

    If one needs to repeat the command executed by PP, the workflow is very slow compared to just typing Up arrow and Enter, especially when a custom command is used.

    opened by 64kramsystem 12
  • Breaks when not in toplevel Git directory

    Breaks when not in toplevel Git directory

    git status | fpp, selecting files, and applying them to git add works fine when I'm at the top level of a Git repo, but not if I enter a subdirectory. It appears to append the selected file to the git repo path, not pwd.

    awaiting-reply 
    opened by hobzcalvin 12
  • feature request: open files in vim tab pages

    feature request: open files in vim tab pages

    Right now I achieve this using something like

    ls | fpp -c "vim -p"
    

    Could you give a environment variable other than FPP_DISABLE_SPLIT that uses vim -p instead of vim -O? Thank you so much!

    opened by kkew3 0
  • Release 0.9.5 but fpp --version says 0.9.2

    Release 0.9.5 but fpp --version says 0.9.2

    FYI, it looks like a version bump was forgotten for the 0.9.5 release, e.g.

    $ fpp --version
    fpp version 0.9.2
    

    This is because:

    https://github.com/facebook/PathPicker/blob/3670d02dbcb9ff232b1c8cbeb5468657dd582cf5/src/version.py#L6

    opened by HenrikBengtsson 1
  • Infinite loop when selecting entry with certain width relative to window width

    Infinite loop when selecting entry with certain width relative to window width

    Entries which end close to window border PathPicker cause infinite loop after trying to select them with either f or F.

    Following for loop is affected: https://github.com/facebook/PathPicker/blob/cc032b2b2fa2fa8ab2fedc93766b2bf2303781d2/src/pathpicker/screen_control.py#L668-L673

    Seemingly due to reaching this code path: https://github.com/facebook/PathPicker/blob/cc032b2b2fa2fa8ab2fedc93766b2bf2303781d2/src/pathpicker/line_format.py#L300-L306

    Which apparently keeps adding dirty indexes forever: https://github.com/facebook/PathPicker/blob/cc032b2b2fa2fa8ab2fedc93766b2bf2303781d2/src/pathpicker/line_format.py#L237-L238

    opened by jpalus 1
  • Standalone Executable File

    Standalone Executable File

    Please support bundling PathPicker into a single bundled executable file, so that distribution of the command/program does not need to include raw source directories.

    opened by ampersandy 0
  • Support for git diffs

    Support for git diffs

    In git diffs, there are sometimes lines that look like this:

    index f80b65d..c8f438a 100644
    --- a/tests/test_signature_parsing.py
    +++ b/tests/test_signature_parsing.py
    @@ -317,7 +317,7 @@ def expects_int(x: int) -> int:
    

    fpp picks up on the path a/tests/test_signature_parsing.py, but that path has a prefix a/ that is not desired (i.e. tests/test_signature_parsing.py would be prefered).

    I wonder: what is the best way for me (as a user) to handle this use-case? I.e. I would like to perform some processing of the selected path(s), e.g. using sed, before passing the paths to a command or opening with an editor.

    opened by Jasha10 0
Releases(0.9.5)
  • 0.9.5(Feb 14, 2022)

  • 0.9.2(Aug 30, 2019)

  • 0.8.2(Aug 8, 2019)

  • 0.7.2(Jan 3, 2017)

    Highlights from git log 0.7.1..HEAD

    • Finally support for vim splitting with the correct line numbers from @brwong
    • Add support for disabling the slash in front of filenames with home (a vestigial hack from internal Facebook infra)
    • Some nice font fixes for better readability
    • Better support for csh, fish, and rc shells from @weakish

    Thanks everyone for the support

    Source code(tar.gz)
    Source code(zip)
    fpp.0.7.2.tar.gz(26.72 KB)
  • 0.7.1(Apr 16, 2016)

    Highlights from git log 0.7.0..HEAD

    • Support for the Home, End, Page Up, and Page Down keys from @robertbachmann (PR #228 #229)
    • Fix command mode for the fish shell (PR #227)
    • Matches even .DS_STORE (PR #223)
    • Some small edits like removing unused imports, cleaning up Debian package, and a bug that would sometimes hang the UI.

    As always, big thanks to the community for their support and contributions!

    Source code(tar.gz)
    Source code(zip)
    fpp.0.7.1.tar.gz(147.00 KB)
  • 0.7.0(Nov 27, 2015)

    Another awesome community release!

    • @gsheld added an "all input" mode in #210 which allows you to use fpp to work with non-file inputs like git branches or mercurial bookmarks. Helpful for when you just want to use the selector UI and don't have another fuzzy selector installed.
    • Improves zsh and csh support. Special thanks to @benmccormick
    • Adds support for filenames with commas and spaces and parens (in any combinatino)
    • emacsclient line jump support
    Source code(tar.gz)
    Source code(zip)
    fpp.0.7.0.tar.gz(144.00 KB)
  • 0.6.2(Sep 29, 2015)

    This is mostly a community release actually! Fixed a new issues and bugs, notably:

    • @slackorama Fixed the bash exiting error for zsh in #191
    • @slackorama also fixed #192 which was an out-of-range index error
    • @alecjacobson fixed #187 which passed the -i flag only if we are not in the vim shell (so you can use FP from within vim!)
    • Few minor fixes like #182, #181
    • Expanded line support from @pallavagarwal07 in #178
    • @Shenil fixed makefile detection in #173
    • and a number of other great fixes!
    Source code(tar.gz)
    Source code(zip)
    fpp.0.6.2.tar.gz(141.00 KB)
  • 0.6.1(Jun 8, 2015)

    Fixed a number of small but important issues and introduced a few new features:

    -- #145 #149 Expand the types of files we can parse now that we have filesystem validation -- including hyphens, spaces, etc -- #137 X mode! Select files with letters rather than UI, thanks @xavierbeynon -- #143 Jump to line in sublime text, thanks @dufferzafar -- #138 Use interactive shell to run script, which should fix zsh sourcing issues, thanks @hlian

    Source code(tar.gz)
    Source code(zip)
    fpp.0.6.1.tar.gz(139.50 KB)
    fpp.deb(33.98 KB)
  • 0.6.0(May 22, 2015)

    Huge list of updates, the biggest though being filesystem validation which enables us to expand our regexes and match on many more files. Full list:

    • #135 / #118 -- long file truncation if it doesnt fit in the screen
    • #132 allow +'s in filenames for objective c
    • #128 and #127 fix some line printing bugs
    • #117 Debian packages!
    • #114 filesystem validation
    • FPP is now version aware (prints out its own version)
    Source code(tar.gz)
    Source code(zip)
    fpp.0.6.0.tar.gz(132.50 KB)
    fpp.deb(62.65 KB)
  • 0.5.7(May 15, 2015)

    • Added Travis CI integration, so master is much more stable
    • Added command line option --clean which removes the state files for script workflows #103
    • Added command line option --version which prints out the version
    • Better help command which shows all command line options
    • Adds the much-requested --command option to preset the passed-in command #99
    • Exit code updates #102
    • Color support!! #53
    • Falls back to relative dirs #47
    Source code(tar.gz)
    Source code(zip)
    fpp.0.5.7.tar.gz(124.50 KB)
    fpp.deb(60.47 KB)
  • 0.5.6(May 11, 2015)

  • 0.5.5(May 8, 2015)

  • 0.5.4(May 4, 2015)

Owner
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
Facebook
CLI Utility to encode and recursively recreate directories with ffmpeg.

FFenmass CLI Utility to encode and recursively recreate directories with ffmpeg. Report Bug Β· Request Feature Table of Contents Getting Started Prereq

George Av. 8 May 06, 2022
A lightweight terminal-based password manager coded with Python using SQLCipher for SQLite database encryption.

password-manager A lightweight terminal-based password manager coded with Python using SQLCipher for SQLite database encryption. Screenshot Pre-requis

Leonardo de Araujo 15 Oct 15, 2022
Example of a CLI with python - know the extension of your files.

extensionCLI Example of a CLI with python - know the extension of your files. Usage: Install the CLI: pip3 install -e . Run the command with "ext" + t

ItanuRomero 5 Dec 29, 2022
dbt-subdocs is a python CLI you can used to generate a dbt-docs for a subset of your dbt project

dbt-subdocs dbt-subdocs is a python CLI you can used to generate a dbt-docs for a subset of your dbt project πŸ€” Description This project is useful if

Jambe 6 Jan 03, 2023
CLI translator based on Google translate API

Translate-CLI CLI ΠΏΠ΅Ρ€Π΅Π²ΠΎΠ΄Ρ‡ΠΈΠΊ основанный Π½Π° Google translate API ΠΊΠ°ΠΊ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒΡΡ ? Π·Π°ΠΏΡƒΡΡ‚ΠΈΡ‚ΡŒ Π² консоли скомпилированный скрипт (exe - windows, bin - l

7 Aug 13, 2022
Dart Version Manager CLI implemented with Python and Typer.

Dart Version Manager Dart Version Manager CLI implemented with Python and Typer Usage: $ dvm [OPTIONS] COMMAND [ARGS]... Options: --install-completion

EducUp 6 Jun 26, 2022
Display Images in your terminal with python

Term-Img Display Images in your terminal with python NOTE: This project is a work in progress and not everything on here has actually been implemented

My avatar ;D 118 Jan 05, 2023
Wordle-textual - Play Wordle from the CLI, using Textual

Wordle, playable from the CLI This project seeks to emulate Wordle in your shell

PhenoM4n4n 3 Mar 29, 2022
Themes for the kitty terminal emulator

Themes for the kitty terminal This is a collection of themes for the kitty terminal emulator. The themes were initially imported from dexpota/kitty-th

Kovid Goyal 190 Jan 05, 2023
A Telegram Bot Written In Python To Upload Medias To telegra.ph

Telegraph-Uploader A Telegram Bot Written In Python To Upload Medias To telegra.ph DEPLOY YOU CAN SIMPLY DEPLOY ON HEROKU BY CLICKING THE BUTTON BELOW

Rithunand 31 Dec 03, 2022
Pymongo based CLI client, to run operation on existing databases and collections

Mongodb-Operations-Console Pymongo based CLI client, to run operation on existing databases and collections Program developed by Gustavo Wydler Azuaga

Gus 1 Dec 01, 2021
Aurornis - The Command Line Program Test Helper

Aurornis - The Command Line Program Test Helper Aurornis is a small, yet powerful library designed to help testing command line programs. The name is

JΓ©rΓ΄me Deuchnord 1 Mar 08, 2022
A dashboard for your Terminal written in the Python 3 language,

termDash is a handy little program, written in the Python 3 language, and is a small little dashboard for your terminal, designed to be a utility to help people, as well as helping new users get used

Rebecca White 2 Dec 03, 2021
Albert launcher extension for converting units of length, mass, speed, temperature, time, current, luminosity, printing measurements, molecular substance, and more

unit-converter-albert-ext Extension for converting units of length, mass, speed, temperature, time, current, luminosity, printing measurements, molecu

Jonah Lawrence 2 Jan 13, 2022
A simple web-based SSH client.

Kommander A simple web-based SSH client. It supports: entering SSH login details (including private key and custom ports) and connecting user authenti

KingWaffleIII 2 Jan 01, 2022
A minimal todo list for your terminal.

todo A minimal todo list for your terminal. Installation Run the following command. pip install git+https://github.com/piero-vic/todo.git Usage todo

Piero Lescano 7 Aug 08, 2022
πŸ•° The command line tool for scheduling Python scripts

hickory is a simple command line tool for scheduling Python scripts.

Max Humber 146 Dec 07, 2022
Collection of useful command line utilities and snippets to help you organise your workspace and improve workflow.

Collection of useful command line utilities and snippets to help you organise your workspace and improve workflow.

Dominik Tarnowski 3 Dec 26, 2021
commandline version of wordle game and my auto solver.

Wordle Machine (and Wordle Game) (in commandline) My implementation of the Wordle game (inspired by https://www.powerlanguage.co.uk/wordle/) and my in

Kevin Xu 11 Jan 03, 2023
A dilligent command line tool to publish ads on ebay-kleinanzeigen.de

kleinanzeigen-bot Feedback and high-quality pull requests are highly welcome! About Installation Usage Development Notes License About kleinanzeigen-b

83 Dec 26, 2022