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!
Oh wow, thanks! I was just thinking about this today - how I'm always cut-and-pasting file paths from ag (silver surfer) results at the console.
One thing I noticed: FPP gets confused by filenames with multiple dots. If a file is named for example "dev_backup.ldif.gz", FPP thinks that "ldif.gz" is the entire file name.
Yep, this is where our regexes start to fall short. Mind opening a github issue for this? We can likely add another option in our "fallback" regex, but it's a fine line to draw between overmatching and undermatching.
For instance, we currently match on "add/remove" output from git status which is less than fortunate. For performance reasons we don't actually go check if each of those files exists (since sometimes you want to pipe hundreds of results into fpp [EDIT: and are using an expandrive or network mount])
@ploxiln -- edited my comment explaining a lot of devs here use network mounts (in which case checking for existence takes a lot longer). I'd love to explore this though, either behind a config setting or eventually as the default behavior! What do you think?
yeah, if the files are not either local or on an NFS mount with sub-millisecond latency (my test took ~ 1 second over NFS to a VM), it's going to take too long. I hadn't thought of that situation
Ah yes I remember this! I was always bad at typing out the numbers though. We support range selection as well, but it does require a keypress for each (which is less than ideal if you have a ton of entries).
Maybe we'll integrate some kind of line-number-selection-mode one day!
A lot of the more experienced engineers had cooked up their own regexes / bash aliases / crazy combination of vim macros to handle the above, but everyone had their own one-off solution that was either hard to learn or hard to generalize. The demand was definitely there though which was part of what got us motivated to build something anyone could use and learn.
When I was there, I would literally just never close files related to what I was working on. I had editor sessions lasting months so I didn't have to reopen all of my files.
Dude, this is awesome. I've often thought about making a tool that does exactly this, but put it on the back burner of my mind. Really cool to see someone else had the same idea, but went a step further to actually execute it :)
I've been using Pick by Thoughtbot [1] for the same purpose, but if I understand correctly fpp will automatically extract file paths from any command without me needing to chain in awk/grep ?
Very cool tool. Just curious as to why directories are not selectable. I did "ls | fpp" and everything got listed (directories and files) but only the files were selectable.
Yeah, we don't match on directories since the regex would overmatch other results (we would basically have to match anything that is words with a slash). However if we added support for checking for file / directory existence we could definitely add support for that
I think if you added the ability to traverse directories, that would take this tool to the next level. I kind of expected the tool to be similar to NERD Tree or Vim's explorer, which would be incredibly useful.
I have been thinking about a more general tool that allows you to select text in different ways from some input, and either copy the selection into your paste ring or as fpp does.
I am still thinking about different selection modes and how the UI would work. Usually I see a need to either copy several full lines, or columns from a table like structure (rectangle selection) or from a regex.
urxvt supports URL highlighting, so I can just click on URLs in my terminal and they open in my web browser. It's extendable too, so pdf filenames can be made into links that open in your chosen pdf viewer. I see no reason why this couldn't be extended to arbitrary filenames in your chosen text editor.
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.
You sound like a Windows admin living in a Linux/BSD world.
I struggle to do everything with Powershell, but almost everything I do has a mouse input. I use a gaming mouse for system administration - a Razer Naga Epic with the 12 thumb buttons.
They're a 3x4 array; I bind them to:
Row One
1. F5
2. Up arrow
3. F2
Row Two
4. Left arrow
5. Down arrow
6. Right arrow
Row Three
7. Tab
8. Delete
9. Backspace
Row Four
10. Enter
11. Spacebar
12. ESC
I can do the work of 2-3 admins, and I'm faster than poorly-written scripts.
You should use whatever works for you but this strikes me as very bizarre I have to admit. I started out with a mouse as well and I can see this being something I would have attempted if I hadn't just put my head down and forced myself to get used to keeping my hands on the keyboard.
As I said, it would be nice to be able to do everything with Powershell (or even Cygwin), but the every module isn't available for every version of Powershell, and the last 2 versions of Powershell don't work with some older (but still supported) versions of Windows.
Want to control you audio from Powershell? There's a cmdlet[1] for that. But it only works on Powershell 4.0 and higher. And PS 4.0 is only available on Win7, (not Win8) Win8.1, and Server 2008-2012.
So on my gaming PC, where I thought putting Win8 Enterprise from my MSDN would be a good idea, I can only change the volume via mouse, or keyboard volume buttons.
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!
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
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
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.
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.
Wow I just posted about this[1] as some hypothetical "dream feature" but it already exists. I don't use iTerm2 (or OS X, for that matter), but I'm wondering now if other terminals support it in some way or another...
I wish that I could have iTerm2 for windows (where I use conemu) and Linux (guake has similar features, but an alien ui imho)... I tend to really like tabbed console sessions, and usually have a few local and ssh sessions open at a time while working.
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:
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.
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.
> 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.
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.
> FB/Google have a reputation to uphold and they strive to make sure their name isn't associated with subpar stuff.
Have you seen the "google" group/whatever it's called on Github? A lot of the repos that are posted here have large disclaimers, or here in the comments, that the project is not associated with Google itself but rather by the particular employees that are working on it. So Google doesn't mind letting their employees put up repos of their misc "scratch their itch"/side-project/pet projects, it seems.
> Plus, they have a lot of brilliant developers to work on this stuff.
Someone works at Google/Facebook/... -> commence reflex fawning.
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!
I haven't really had issues with fzf in tmux. Personally I just write a couple of my own aliases on top of fzf and it works great. I have ^T bound to open fzf and then edit the file I pick in vim. For me I find that editing files and selecting files to add to my VCS are my two uses cases. The latter I solve with scm_breeze[0].
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:
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?
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.
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.
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.
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.
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.)
In the time it took you to write all that, you could've answered this question for yourself. He wrote it at work, as part of his job, at Facebook. And if he's not "troubled" by it, why are you?
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:// 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.
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
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)
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.
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.
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.
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?
@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).
$ sudo git clone git@github.com:facebook/PathPicker.git
Cloning into 'PathPicker'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Any ideas? Thanks.
EDIT: Nevermind. It's an issue with using sudo to git. I can use my own account, but I can't do it in /usr/local.
@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
> I still think homebrew is slightly more popular than having pip installed
I disagree. On Linux, we have operating system package managers. pip is popular among python programmers, for python packages. Asking to install another random package manager is unlikely to be popular.
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!
>Notwithstanding the foregoing, if Facebook or any of its
subsidiaries or corporate affiliates files a lawsuit alleging patent
infringement against you in the first instance, and you respond by filing a
patent infringement counterclaim in that lawsuit against that party that is
unrelated to the Software, the license granted hereunder will not terminate
under section (i) of this paragraph due to such counterclaim.
Even if this was the case (this was poor wording in the original PATENTS which has since been fixed) you are only subject to these constraints in any code you provide that includes the source code. Since this is a shell tool, that is largely irrelevant. For the same reason, you can compile and release binaries from closed source binaries using gcc even though it is licensed under GPL.
(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.
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!
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!