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
A clone of the popular online game Wordle

wordle_clone A CLI application for wordle. Description A clone of the popular online game Wordle.

0 Jan 29, 2022
Fylm is a wonderful automated command line app for organizing your film media.

Overview Fylm is a wonderful automated command line app for organizing your film media. You can pronounce it Film or File 'em, whichever you like! It

Brandon Shelley 30 Dec 05, 2022
AWS Interactive CLI - Allows you to execute a complex AWS commands by chaining one or more other AWS CLI dependency

AWS Interactive CLI - Allows you to execute a complex AWS commands by chaining one or more other AWS CLI dependency

Rafael Torres 2 Dec 10, 2021
CmdTube is a Python CLI library for searching, downloading, and watching YouTube tutorials

CmdTube is a Python CLI library for searching, downloading, and watching YouTube tutorials. This library was made with programmers in mind and it's dedicated to every programmer who watches YouTube v

Samuel Ayomide Ogunleke 2 Aug 22, 2022
Tstock - Check stocks from the terminal

tstock - Check stocks from the terminal! 📈 tstock is a tool to easily generate stock charts from the command line. Just type tstock aapl to get a 3 m

Gabe Banks 502 Dec 30, 2022
Professor Wordlist is a free open source command line tool written in python

Professor Wordlist is a free open source command line tool written in python, With the aim of generating custom wordlists with a variety of unique parameters and functions providing many possibilitie

オークO A K Z E H オーク 1 Oct 28, 2021
The Pythone Script will generate a (.)sh file with reverse shell codes then you can execute the script on the target

Pythone Script will generate a (.)sh file with reverse shell codes then you can execute the script on the targetPythone Script will generate a (.)sh file with reverse shell codes then you can execute

Boy From Future 15 Sep 16, 2022
dcargs is a tool for generating portable, reusable, and strongly typed CLI interfaces from dataclass definitions.

dcargs is a tool for generating portable, reusable, and strongly typed CLI interfaces from dataclass definitions.

Brent Yi 119 Jan 09, 2023
Package installer for python

This is a package that adds a JSON file to your project that records all of the packages used in it and allows people to install it with a single command.

Anmol Malik 1 May 23, 2022
A begginer reverse shell tool python.

A begginer tools for hacking. The theme of this repository is to bring some ready-made open-source tools for anyone new to the world of hacking. This

Dio brando 2 Jan 05, 2022
Python wrapper and CLI utility to render LaTeX markup and equations as SVG using dvisvgm and svgo.

latex2svg Python wrapper and CLI utility to render LaTeX markup and equations as SVG using dvisvgm and svgo. Based on the original work by Tino Wagner

Matthias C. Hormann 4 Feb 18, 2022
TermPair lets developers securely share and control terminals in real time🔒

View and control terminals from your browser with end-to-end encryption 🔒

Chad Smith 1.5k Jan 05, 2023
Regis-ltmpt-auto - Program register ltmpt 2022 automatis

LTMPT Register Otomatis 2022 Program register ltmpt 2022 automatis dibuat untuk

1 Jan 13, 2022
CLI tool to develop StarkNet projects written in Cairo

⛵ Nile Navigate your StarkNet projects written in Cairo. Installation pip install cairo-nile Usage Install Cairo Use nile to install a given version o

Martín Triay 305 Dec 30, 2022
f90nml - A Fortran namelist parser, generator, and editor

f90nml - A Fortran namelist parser, generator, and editor A Python module and command line tool for parsing Fortran namelist files Documentation The c

Marshall Ward 110 Dec 14, 2022
WA Terminal is a CLI application that allows us to login and send message with WhatsApp with a single command.

WA Terminal is a CLI application that allows us to login and send message with WhatsApp with a single command.

Aziz Fikri 15 Apr 15, 2022
Spongebob-cli - Watch classic spongebob from the terminal

spongebob-cli Watch classic spongebob from the terminal! Thanks to everyone that

523 Jan 02, 2023
🎈 A Mini CLI-based Operating System simulator

Mini OS Simulator Summary 🎈 A Mini CLI-based Operating System simulator, well, not really. It simulates a file system with songs and movies and stuff

Jaiyank S. 3 Feb 14, 2022