Hacker News new | ask | show | jobs
by xxbondsxx 4058 days ago
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!

15 comments

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])

    [pierce@plo-pro team15]$ time (find . -print0 | xargs -0 stat -f '%N' | wc -l)
        4901
    
    real	0m0.079s
    user	0m0.043s
    sys	0m0.060s
@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?
I think to have usable matching you're going to have to go that way, unless you want to write custom parsing code for each command's output.
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
You could test for a single file (possible with a timeout) and see if it's "fast enough" to check all files.

You could also check in the background and update the display if the heuristic turned out wrong.

Open all silver searcher "Foo" results in Sublime:

subl `ag -l Foo`

I'm not sure you know, but just in case, ag also has a -l flag with which it will just spit out the filenames!
Good work! when I was at FB I rolled my own, called "gitsh":

https://gist.github.com/aristus/2304335

One of the most useful features is range selection syntax, eg, run git rm on items 4-16.

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!

> so I'd see a lot of (new) engineers select the text with their mouse

What did the more experienced engineers do differently?

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 :)
This looks very cool - thank you.

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 ?

[1] https://robots.thoughtbot.com/announcing-pick

Yeah, that seems to be the idea. It has a bunch of regexes for parsing different kinds of outputs, and some fallback ones.
Hey - I was the person who used this tool the most while I was at FB. Thanks a bunch for open sourcing this I've been missing it.
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.
Don't forget about mc (midnight commander). Which is still hella useful

http://en.wikipedia.org/wiki/Midnight_Commander

Sounds like something I should give a try myself in a pull request.
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.

Looks good so far!

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.

[1] https://github.com/cdhunt/WindowsAudioDevice-Powershell-Cmdl...

You're not able to upgrade your gaming PC?
Because of my infinite foresight in installing the Enterprise version, my upgrade path requires a full reinstall.

Everything works fine so it's not a very high priority - I'd rather be Minecrafting - either playing the game or adding to the server.

Just want to echo the dead comment:

ossreality 6 minutes ago [dead]

lol, what are you talking about, this isn't mouse-enabled?

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

1: http://www.sikuli.org/

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
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

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.
That's great, we have an app that can't be tested with Selenium, Sikuli looks promising.
> I'm only slightly ashamed to admit I like using a mouse.

I wish that you weren't even slightly ashamed. Anything can turn into a senseless religion, also supposed productivity.

lol, someone's gonna be disappointed trying fpp for the first time
Look pretty nice. Have you considered integrating fuzzy finding in it? Or making it cooperate with fzf?
How to install it in Linux?
Do you work on developer tools at FB or was this extra-curricular?
This looks very useful. Thanks for sharing it.
Not sure, how much I'm going to use this. But I just hate the name (or command) `fpp`. Why put Facebook in the name?
do we need to open any specific mode in terminal for FPP?
Don't think so itsbits -- we strip out color codes and it works just fine inside tmux, but let us know if you have any issues on GitHub!
sure thanks