8 ms·
Facebook PathPicker
- xxbondsxx 11y agoHey 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!
- Splendor 11y agoThis looks very useful. Thanks for sharing it.
- aristus 11y agoGood work! when I was at FB I rolled my own, called "gitsh": https://gist.github.com/aristus/2304335 https://gist.github.com/aristus/2304335 One of the most useful features is range selection syntax, eg, run git rm on items 4-16.
- xxbondsxx 11y agoAh 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!
- staz 11y agoLook pretty nice. Have you considered integrating fuzzy finding in it? Or making it cooperate with fzf?
- itsbits 11y agodo we need to open any specific mode in terminal for FPP?
- JohnBooty 11y agoOh 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.
- xxbondsxx 11y agoYep, 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 11y ago[pierce@plo-pro team15]$ time (find . -print0 | xargs -0 stat -f '%N' | wc -l) 4901 real 0m0.079s user 0m0.043s sys 0m0.060s
- xxbondsxx 11y ago@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?
- sandyarmstrong 11y agoI 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.
- ploxiln 11y ago
- umanwizard 11y agoDude, 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 :)
- deleted 11y ago[deleted]
- BonoboBoner 11y agoThank 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.
- ossreality 11y agolol, what are you talking about, this isn't mouse-enabled?
- Kiro 11y agoJust want to echo the dead comment: ossreality 6 minutes ago [dead] lol, what are you talking about, this isn't mouse-enabled?
- gilini 11y agolol, someone's gonna be disappointed trying fpp for the first time
- stephengillie 11y agoYou 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.
- brazzledazzle 11y agoYou 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.
- kbd 11y ago> so I'd see a lot of (new) engineers select the text with their mouse What did the more experienced engineers do differently?
- xxbondsxx 11y agoA 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.
- CGamesPlay 11y agoWhen 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.
- UUMMUU 11y agoVery 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.
- xxbondsxx 11y agoYeah, 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
- atarian 11y agoI 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.
- ugh123 11y agoDon't forget about mc (midnight commander). Which is still hella useful http://en.wikipedia.org/wiki/Midnight_Commander http://en.wikipedia.org/wiki/Midnight_Commander
- UUMMUU 11y agoSounds like something I should give a try myself in a pull request.
- Zolomon 11y agoI 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!
- fragmede 11y agourxvt 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.
- fredkelly 11y agoThis 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 https://robots.thoughtbot.com/announcing-pick
- nightpool 11y agoYeah, that seems to be the idea. It has a bunch of regexes for parsing different kinds of outputs, and some fallback ones.
- encoderer 11y agoDo you work on developer tools at FB or was this extra-curricular?
- akshayaurora 11y agoNot sure, how much I'm going to use this. But I just hate the name (or command) `fpp`. Why put Facebook in the name?
- goatslacker 11y agoHey - 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.
- GutenYe 11y agoHow to install it in Linux?
- pliny 11y agohttps://github.com/facebook/PathPicker/blob/master/README.md#installing-pathpicker https://github.com/facebook/PathPicker/blob/master/README.md...
- sheldonk 11y agoThis reminds me of https://github.com/mooz/percol https://github.com/mooz/percol
- xxbondsxx 11y agoPercol 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 11y agoDoes fpp support history for its command prompt? With the percol approach, you can easily re-run the same command with a different selection.
- michaelmior 11y agoI use fzf[0] for similar purposes. [0] https://github.com/junegunn/fzf https://github.com/junegunn/fzf
- xxbondsxx 11y agoYeah 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!
- michaelmior 11y agoI 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]. [0] https://github.com/ndbroadbent/scm_breeze https://github.com/ndbroadbent/scm_breeze
- qiemem 11y agoThe fact that it just outputs to stdout means you can run any command with output from fzf as well. Just anycommand $(fzf)
- 0x0 11y agoLooks 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.
- andyl 11y agoThis looks great. Is there a streamlined install for Ubuntu?
- itsbits 11y agojust went through their code. Currently not possible
- xxbondsxx 11y ago@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
- function_seven 11y agoI just tried to git clone it with $ 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.
- motoboi 11y agoJust try using git over https. You probably have your own key to github.com and the server will access deny it when accessing someone else's repo.
- rmc 11y agoIf it's pure python why not use pip?
- xxbondsxx 11y ago
- hellbanner 11y agoProps for giving back.
- FiloSottile 11y agoOne 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)
- vcarl 11y agoHoly crap, that's amazing. I had no idea, thanks for spreading the word.
- kashifzaidi1 11y agoKudos, never knew that!
- biftek 11y agoUnfortunately using tmux breaks that behavior.
- tracker1 11y agoI 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.
- staunch 11y agoSome 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 11y agoCouldn't agree more staunch! I silently weep every time I have to use the mouse during development
- Retra 11y agoJust turn that frown upside down. Use your mouse for all input and get rid of that pesky keyboard.
- asmosoinio 11y agoAnd with this tool you do exactly that? Instead of selecting the filenames with your mouse, you keep hands on keyboard and select with arrow keys.
- serve_yay 11y agoYou're silly.
- vikiomega9 11y agoThe brew install seems broken?
- jlongster 11y agoThis 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.
- hodgesmr 11y agoI 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
- mscrivo 11y agovery nice! Anyone get this working in an msysgit bash shell?
- climaxius 11y agoA 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
- 616c 11y agoSurprisingly, I rarely see reference to that show the programming/IT world. That made my day, thanks.
- alexsop2 11y ago🎉 That’s numberwang! 🎉
- feedjoelpie 11y agohttp://louhuang.com/2048-numberwang/ http://louhuang.com/2048-numberwang/
- ramses0 11y agoMe, similarly: https://github.com/ramses0/bash-dialog https://github.com/ramses0/bash-dialog ...depends on dialog command being installed, or you could use bash's built-in "select" command.
- nathan_f77 11y agoHeh, me too: https://github.com/ndbroadbent/scm_breeze https://github.com/ndbroadbent/scm_breeze
- frou_dh 11y agoSeems to trip up as soon as paths have spaces in them. Nice concept though, makes a good companion for "mdfind" on OS X.
- deleted 11y ago[deleted]
- ComputerGuru 11y agoIs 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; ...`?
- raman325 11y agocool 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
- pierrec 11y agoGoing 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.
- Sbn 11y agoWell if you've gone through each then you're the best person to write a review! :-)
- aerique 11y agoLike /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.
- iopuy 11y agoHey 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 ?
- slajax 11y agoPlease, this!
- xxbondsxx 11y agoHey @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 11y agoDone. https://github.com/facebook/PathPicker/issues/63 https://github.com/facebook/PathPicker/issues/63
- serve_yay 11y agoI 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 11y agoAnd 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 :-)
- amelius 11y agoThis reminds me of Norton Commander :)
- fiatjaf 11y agoDozens 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 11y agoSame 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.
- fiatjaf 11y agoYou are right. Thank you.
- stass 11y ago> 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 11y agoNot 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.
- numair 11y agoHaven'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!
- superuser2 11y agoFalse. They fixed it about a month ago. >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. Source: https://github.com/facebook/PathPicker/blob/master/PATENTS https://github.com/facebook/PathPicker/blob/master/PATENTS See also the announcement of the change: https://news.ycombinator.com/item?id=9356508 https://news.ycombinator.com/item?id=9356508
- Eduard 11y agoWhat 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 11y ago(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.
- TomNomNom 11y agoI 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 11y agoThis is fantastic. Thanks for sharing.
- liquidise 11y agoiTerm2 has historic completion if you hit CMD + ; after typing a couple of characters. works wonders for path retrieval.
- MetaMonk 11y agoThis is awesome! Thanks!
- labianchin 11y agoThat 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 11y agosame problem here. need to make it aware of my aliases :\
- ww520 11y agoThis 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.
- stass 11y agoThis 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?
- muaddirac 11y agoSome of this is reminiscent of xiki: http://xiki.org/ http://xiki.org/
- namuol 11y agoRelated: 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.
- renata 11y agoIf 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
- mortdeus 11y agoThe point of piping is that output shouldn't ever be as complicated as this...
- manan19 11y agoWhy is this at the top of HN? :/
- Cacti 11y agoReminds me of Helm in Emacs.
- blawa 11y agoslightly tangential question- I have dotfiles, but what solution do people use for managing these utils across machines?
- Sbn 11y agoTangential question- how does one manage these utils on multiple machines? I use dotfiles for regular dot files.
- thinkingfish 11y agoWould be nice to allow filters- for example, leave out any results that match patterns in .gitignore.
- daliwali 11y agoIs 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 11y agoThey 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.)
- encoderer 11y agoIn 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?
- blago 11y agoI 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.
- ptman 11y agoI like using vipe from moreutils ( https://joeyh.name/code/moreutils/ https://joeyh.name/code/moreutils/ ) find . |vipe | xargs ...
- jbnicolai 11y agoI 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#L127 https://github.com/jbnicolai/tmux/blob/master/.tmux.conf#L12...
- trumbitta2 11y agoThanks 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.
- govilk 11y agoVery useful. Thanks
- jiuren 11y agoImpressive. 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).
- milin 11y agoLooks 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.
- barun 11y agoThis 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
- hammerha 11y agoThere's a nice command line interface git client called `tig`. https://github.com/jonas/tig https://github.com/jonas/tig