
Facebook PathPicker - ben_hall
http://facebook.github.io/PathPicker/
======
xxbondsxx
Hey everyone, I'm in the main engineer on this project if anyone has
questions.

Facebook has a large codebase, so naturally we have a lot of long filenames
and paths. It's a pain to type these out by hand, so I'd see a lot of (new)
engineers select the text with their mouse before pasting it into the command
line.

This is pretty inefficient and I knew there had to be a better way, so a few
of us started hacking on a set of python regexes and a curses UI. Before long
we had a pretty simple / easy command line utility that sped up everyones'
day.

After a while we realized this would probably be helpful to all, so we open
sourced it today!

~~~
BonoboBoner
Thank you for making the mouse a thing in a keyboard driven world. As someone
who grew up with gaming and learned IT as a result I never was able to fully
give up on the mouse during my daily workflows. I admire people who can use
VIM etc only by keyboard, but my muscle memory just says: mouse.

Thanks for establishing something that embraces this.

~~~
jakejake
I'm only slightly ashamed to admit I like using a mouse. I get that some
people can work faster with all-keyboard controls. I use both. I also like
GUIs for certain things. The only thing I don't like GUIs for is when there is
some repetitive thing that I have to do 50 times a day and would require 3 or
4 clicks or menu selections - for those I'd always rather have a single
command. Sometimes I make those into shell scripts that I can click with my
mouse though!

~~~
doorhammer
Might already be familiar with it, but if you aren't, you should check out
sikuli script [1] for when you have a repetitive GUI task you have to perform
that can't be directly scripted. I've used it to script some really complex
workflows through GUI's

It's also just weird and interesting to program something to move through a
GUI as fast as is possible

1: [http://www.sikuli.org/](http://www.sikuli.org/)

~~~
stinos
Wow. Never heard of it, but this must be the most amazing software idea I've
seen in a while. It's gonna be a playful day :P

~~~
doorhammer
Hahah, awesome.

Yeah, getting the scripts to run and be robust is definitely an art sort of
thing, but I've used it to create what amounts to a CLI's for legacy apps that
you could only interface with through GUI's.

It's also fun to run across stuff like "Oh, the developer of this platform
wasn't expecting me to be able to respond to a window within 20ms of it
popping up on the screen."

Be interested to see what you think, if you have time to leave a comment

~~~
stinos
Didn't have all the time I wanted today but played with 'hello world' samples
and it's a fun new way of scripting for me. I don't have an immediate use for
it but next time I feel something needs automation I'm definitely going to
give it a go.

------
FiloSottile
One of the best little-known features of iTerm2 is Semantic History. Cmd-click
on filenames and they will be opened by the default application (or you can
configure an action to be performed). It's working directory aware and works
great with all output. I connected it to Sublime and it even works with line
numbers.

(Same works for URLs, with the default browser)

~~~
biftek
Unfortunately using tmux breaks that behavior.

~~~
evanw
I believe you can still achieve this with tmux by using Command+Option+Click.

~~~
biftek
Really late, but thanks! It works!

------
TomNomNom
I have a similar workflow already that may be of use to vim users. I pipe file
lists (from grep etc) into vim (using a '-' to tell vim to read from stdin):

    
    
      grep -nri searchterm * | vim - 
    

You can then use 'gF' over a file name to open the file in question (and be
taken to the right line number if specified in the form somefile.txt:42). You
can use '<c-w>gF' to open the file in a new tab, or '<c-w>F' to open the file
in a split instead.

As an added bonus you can re-filter the file list from within vim to, for
example, remove things from a test directory without having to run the
original command again:

    
    
      :%!grep -v ^test

~~~
jstx
This is fantastic. Thanks for sharing.

------
fiatjaf
Dozens of cool utilities like this are created every week and launched at Show
HN, but without "Facebook" in their names you need at least 10 of them to get
the many points this thread has gathered.

~~~
tsiki
Same goes for Google, but you could argue that it's for a reason. FB/Google
have a reputation to uphold and they strive to make sure their name isn't
associated with subpar stuff. Plus, they have a lot of brilliant developers to
work on this stuff. In the end of the day, it's largely about knowing which of
these cool utilities have a better chance of being usable and well thought-
out, as nobody wants to spend time on figuring out a utility which turns out
to be unusable.

~~~
stass
> FB/Google have a reputation to uphold and they strive to make sure their
> name isn't associated with subpar stuff. Plus, they have a lot of brilliant
> developers to work on this stuff.

Why do you think so? My experience was quite the opposite... One can argue
that large companies don't care about their reputation as much as small
companies and individuals do as responsibility gets diluted among the larger
number of people. This was certainly the case with most of the tech companies.

~~~
ameen
Not the parent, but it's mostly because open sourced tools from larger
companies were usually built internally to solve a pain point. Of course they
wouldn't want it to be subpar and affect their efficiency.

> Large companies don't care about their reputation as much as small companies
> and individuals do as responsibility gets diluted among the larger number of
> people. This was certainly the case with most of the tech companies.

I think this speaks more about that particular engineer's ownership of the
project rather than company itself.

------
climaxius
A while back I wrote a similar tool in go to scratch my own itch and use it
every day:
[https://github.com/robbiev/numberwang](https://github.com/robbiev/numberwang)

~~~
alexsop2
🎉 That’s numberwang! 🎉

~~~
feedjoelpie
[http://louhuang.com/2048-numberwang/](http://louhuang.com/2048-numberwang/)

------
michaelmior
I use fzf[0] for similar purposes.

[0] [https://github.com/junegunn/fzf](https://github.com/junegunn/fzf)

~~~
xxbondsxx
Yeah fzf is great -- there are a few differences since PathPicker can execute
any command with the selected file(s) (rather than just write it to stdout)
and runs in tmux with no issues, but fzf has great vim integration and I
believe actually verifies the file matches.

Glad more people are working in the productivity space though!

~~~
qiemem
The fact that it just outputs to stdout means you can run any command with
output from fzf as well. Just

anycommand $(fzf)

~~~
guac
or `xargs` / gnu parallel

~~~
thameera
Except for commands like git add.

------
iopuy
Hey guys, great tool. Just want to point out it doesn't play well with ack (a
better grep) because ack does not prepend a "./" to the file list returned
from "ack -l 'foo'". Any way to make it work with the following:

junk/foo/bar.txt

instead of just

./junk/foo/bar.txt

?

~~~
xxbondsxx
Hey @iopuy can you file an issue on github? For paths that are not absolute or
relative (and thus ambiguous), we:

\-- Try to detect the top-level version control directory \-- Use that if one
is found

But we could possibly pipe the current working directory into the python
context from bash and go from there

~~~
iopuy
Done.
[https://github.com/facebook/PathPicker/issues/63](https://github.com/facebook/PathPicker/issues/63)

------
stass
This is a great tool.

However, he authors/documentation seem to be confused about bash vs shell. In
the documentation these terms seems to be used interchangeably. In the code,
the main script depends on bash directly (and for it to be installed in a very
particular place) but does not seem to use any bash-specific features.
However, the script it launches at the end is launched via "sh" which is not
bash, so if there're bash specific features in it it would fail.

"PathPicker should work with most Bash environments" \-- what does that even
mean?

------
hodgesmr
I see a lot of alternatives to this in the comments. Allow me to offer
another:
[https://github.com/garybernhardt/selecta](https://github.com/garybernhardt/selecta)

~~~
philsnow
Yet another one: [https://github.com/peco/peco](https://github.com/peco/peco)

~~~
skeoh
Oh wow, peco is really impressive. Thanks for the link!

------
staunch
_Some people, when confronted with a command line problem, think "I know, I'll
use my mouse." Now they have two problems._

I'm joking, and this looks neat, but the optimal solution is almost certainly
to keep your hands on the keyboard while in the shell.

~~~
xxbondsxx
Couldn't agree more staunch! I silently weep every time I have to use the
mouse during development

~~~
Retra
Just turn that frown upside down. Use your mouse for all input and get rid of
that pesky keyboard.

------
jlongster
This is awesome. I wonder if any of this was Emacs inspired. A very common UX
in Emacs is to list things in a buffer and directly manipulate the items to
execute commands. For example, in dir-mode, you can select multiple files and
rename them, or mark several files for deletion and execute it.

It really is a fantastic way to bring an interactive interface into a text-
based world. This looks like a cool way to bring it to the terminal.

~~~
reedlaw
Yes, when I saw the git example I immediately thought of magit for Emacs which
can also jump around files and commits from within git results.

------
labianchin
That is great!

But when using the command, it does not work with defined bash/zsh aliases.
Anyone has any idea how to do that?

Say I have "alias g=git", when I use the command "g diff", the following error
happens: .fbPager.sh: line 4: g: command not found

~~~
kentor
same problem here. need to make it aware of my aliases :\

------
ComputerGuru
Is there a way of using this with instructions that take only one parameter,
akin to xargs or parallel?

i.e. Instead of calling `command file1 file2 file3 ...` it would call `command
file1; command file2; command file3; ...`?

------
jbnicolai
I wrote a small snippet to integrate this with tmux. Simply press <Leader-i>
for the current buffer to be run through fpp.

See a small example here:
[http://recordit.co/U2TYvbPC9p](http://recordit.co/U2TYvbPC9p)

And here's the corresponding code:
[https://github.com/jbnicolai/tmux/blob/master/.tmux.conf#L12...](https://github.com/jbnicolai/tmux/blob/master/.tmux.conf#L127)

------
sheldonk
This reminds me of
[https://github.com/mooz/percol](https://github.com/mooz/percol)

~~~
xxbondsxx
Percol was actually a source of inspiration as well, but I got tired of typing
things like:

git checkout $(git branch | percol)

Since I had to almost compose my command beforehand rather than decide once I
saw the output. So we take the opposite approach. Great UI though!

~~~
pimlottc
Does fpp support history for its command prompt? With the percol approach, you
can easily re-run the same command with a different selection.

------
muaddirac
Some of this is reminiscent of xiki: [http://xiki.org/](http://xiki.org/)

------
pierrec
Going though this thread, so far we have fpp, selecta, peco, percol,
numberwang, fzf... Wewh! They are all, how could we call it, command line
selector tools? What I'd love to read is a nice comparative review of these
tools.

Although I kind of enjoy the process of going though each one and studying how
the features fit my own workflow.

~~~
aerique
Like /u/Sbn, I'd like to hear about the experiences you've gathered with these
tools so far. I'm in the process of choosing one of these tools and I cannot
find a good overview of all their features, pros and cons.

------
renata
If you're only using this with git, I use git-number[1] for this purpose.

[1] [https://github.com/holygeek/git-number](https://github.com/holygeek/git-
number)

------
daliwali
Is there a reason why this is named Facebook PathPicker instead of PathPicker?
It seems that the original author is giving up rights of their software to
Facebook (it says copyright Facebook right in the license).

What troubles me is that this tool seems completely unrelated to Facebook's
business so why must they assert ownership of their employee's side project?
On the other hand, it could be the author's intent to give up their rights to
Facebook, which seems dumb, there's nothing the author could gain from that
other than the Facebook brand in front.

~~~
AdamTReineke
They probably wrote it at work or on a company machine or discussed it on
company time, all of which can make it company property. (Read up on
moonlighting.)

------
0x0
Looks nice. Is it better than the built-in "arrow-keys-browseable" menu
completion of zsh? (Random "screenshot" available at
[http://www.masterzen.fr/2009/04/19/in-love-with-zsh-part-
one...](http://www.masterzen.fr/2009/04/19/in-love-with-zsh-part-one/) under
"Menu selection")

I've always been wanting an integrated file picker on unix that was as
efficient as the ones in the venerable 4DOS (and 4NT) shells.

------
namuol
Related: It would be great if your terminal were just clever enough to
identify paths and allow you to click on them to open them. Many do this for
[http://](http://) links, but not fs links.

Bonus: include <line>:<column> in the path since most editors support jumping
in the file with this format, which would make it much easier to navigate to a
specific spot in your code where an error is occurring from the output of the
error.

------
hellbanner
Props for giving back.

------
barun
This tool is awesome. It would be better if you add a search feature in the
selector UI. I know that we could do that in the command itself but it would
if helpful in case we forgot previously or need further filtering

Also, it is failing to select the entire file if there are spaces in it

------
thinkingfish
Would be nice to allow filters- for example, leave out any results that match
patterns in .gitignore.

------
serve_yay
I don't use an editor that runs in the terminal so I only ever want a tool
like this for the command mode. When you use it right it's pretty nice, but
the first time I was unceremoniously dumped into vim. (Yes I know about the
EDITOR variable)

------
scott_karana
And in case anyone didn't know about something that does the same for URLs on-
screen: here's urlview.

[http://linuxcommand.org/man_pages/urlview1.html](http://linuxcommand.org/man_pages/urlview1.html)

:-)

------
jiuren
Impressive. I was very happy with percol. Now I see other possibility. I
really like the "select first, then comes the command" approach.

I hope you can add support of selecting directories, and fuzzily filtering
results(like what percol does).

------
hammerha
There's a nice command line interface git client called `tig`.
[https://github.com/jonas/tig](https://github.com/jonas/tig)

------
ptman
I like using vipe from moreutils (
[https://joeyh.name/code/moreutils/](https://joeyh.name/code/moreutils/) )

find . |vipe | xargs ...

------
milin
Looks like it has issues running with nosetests. It would be awesome, if I
could do nosetests runtests.py | fpp and if any test fails, i could select it
and it would open it up in my editor.

------
trumbitta2
Thanks for giving back!

I'm not sure how this would speed up my workflow more than a combination of
tab completion, CTRL-R, and quick rushes of double-click-to-select-then-third-
button-to-paste, though.

------
blago
I use a combination of grep (to filter), awk (for projection), and xargs (to
execute) to achieve similar result but it probably takes a little longer to
construct.

------
ww520
This looks awesome and very useful.

As an alternative, I usually just run ag to search files inside Emacs, and use
Emacs to navigate the results.

------
liquidise
iTerm2 has historic completion if you hit CMD + ; after typing a couple of
characters. works wonders for path retrieval.

------
Sbn
Tangential question- how does one manage these utils on multiple machines? I
use dotfiles for regular dot files.

------
frou_dh
Seems to trip up as soon as paths have spaces in them.

Nice concept though, makes a good companion for "mdfind" on OS X.

------
amelius
This reminds me of Norton Commander :)

------
mortdeus
The point of piping is that output shouldn't ever be as complicated as this...

------
raman325
cool idea, thanks for sharing! for some reason, everything is working but the
ability to move up and down, regardless of whether i use arrow keys or j/k.
any ideas?

EDIT: should note i am using iTerm on a Mac

------
vikiomega9
The brew install seems broken?

~~~
vecinu
Make sure you run a 'brew update' prior to 'brew install fpp'.

If that is not your issue then yes, I can't seem to symlink fpp properly in
/bin either.

------
Cacti
Reminds me of Helm in Emacs.

------
MetaMonk
This is awesome! Thanks!

------
mscrivo
very nice! Anyone get this working in an msysgit bash shell?

------
govilk
Very useful. Thanks

------
manan19
Why is this at the top of HN? :/

------
andyl
This looks great. Is there a streamlined install for Ubuntu?

~~~
xxbondsxx
@andyl We are working on getting a linuxbrew recipe working. There's shouldn't
be anything blocking this from working on linux systems (assuming Python 2.7
is installed).

In the meantime you can try the manual installation method listed in the
README:
[https://github.com/facebook/pathpicker/](https://github.com/facebook/pathpicker/)

@itsbits Why do you say that? curious if you found anything

~~~
rmc
If it's pure python why not use pip?

~~~
xxbondsxx
@rmc we have a dependency on a bash script as well, since we need to redirect
stdin to tty input and such. So getting the bash file to distribute with PIP
and symlink as well was slightly complicated.

I only recently realized that the entire program could be ported over to
python (the stdin redirection is supported in python as well) but I still
think homebrew is slightly more popular than having pip installed, especially
with all the JS development going on today

~~~
nightpool
pip would probably be a lot better from a cross-platform perspective then
something really obscure like linuxbrew.

~~~
andyl
+1 for pip over linuxbrew

------
numair
Haven't we learned by now, my fellow HN readers? All of Facebook's open source
"gifts" are patent Trojan horses. Go take a look at their PATENTS file before
going anywhere near this stuff.

The fact that Facebook, at such a level of wealth and success, gets away with
this stuff is despicable. It's also an insult to the great legacy of companies
like Sun, which gave freely without strangling its beneficiaries. It says a
lot about the culture and leadership at the company, but that's been well-
documented...

If you're a passionate engineer at Facebook working on an open source project,
please go work on it somewhere else!

~~~
Eduard
What is a patent Trojan horse? I just read the PATENTS file, but cannot think
of a scenario that could affect me negatively. Can you give one?

~~~
mcintyre1994
(IANAL, I did complain here about the old patents file)

An older version of their patents file used language that suggested to some
that the license would be void if you attempted to defend against a patent
suit from Facebook and it could therefore be dangerous to use.

They recently updated the file to clarify some terms, particularly the one the
parent is complaining about, and I haven't heard anybody complaining about the
new language.

~~~
xxbondsxx
Yep, we had a bit of a brouhaha over the original update to our patents file
and clarified the language afterwards, I think it's a bit more straightforward
now!

