Code Monkey home page Code Monkey logo

path-extractor's Introduction

PathExtractor (pe)

demo

PathExtractor is a command line tool that extracts a list of files/paths from stdin.

Advantages over fpp:

  • It does only one thing : more unixy
  • You can use it with any fuzzy finder, such as fzf,peco,percol,pick,selecta
  • It doesn't wait for stdin to be finished to output the paths
  • It is faster
  • It is much smaller (easily understandable)
  • You can also use it without a fuzzy finder for programmatic usage

For example, you could write:

git status | pe

to get a list of the files that were added/changed, without all the formating

One of the most common usage is to create an alias that will automatically run :

pe + a command line fuzzy finder such as fzf + an action such as opening that file in your favorite editor.

For example, using zsh , I have as an alias:

alias -g P='| pe | fzf | read filename; [ ! -z $filename ] && vim $filename'

With bash:

bind '"PP": "| pe | uniq | fzf | while read filename; do [ ! -z $filename ] && </dev/tty vim $filename; done\n'

So that If I run

git status P

or

git status PP

to quickly open one of the changed files in vim

Other usage ideas:

With zsh:

# Copy selected path to clipboard
alias -g C='| pe | fzf | read filename; [ ! -z $filename ] && echo -n $filename | xclip -selection c'

With bash:

bind '"CC": "| pe | fzf | read filename; [ ! -z $filename ] && echo -n $filename | xclip -selection c\n"'

Installation

go install github.com/edi9999/path-extractor@latest
# sudo mv "$(which path-extractor)" /usr/bin/pe

You will have the path-extractor in your $GOPATH/bin directory which you can rename or alias to pe

path-extractor's People

Contributors

alphan avatar edi9999 avatar infokiller avatar netei avatar soulou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

path-extractor's Issues

Is it expected that it doesn't recognize paths without / or .?

I'm guessing this is expected, otherwise every word would be seen as a file, but I just noticed the output of ls | pe wasn't what I would have expected :) Presumably one could alter the output to prefix such paths with ./ to force them to be seen as paths, i.e. ls -l ./* or so? Is that the recommended way to handle such cases?

Possible to handle paths with spaces?

I realize it may be difficult to recognize what's path-like if spaces can be included, particularly since the tool doesn't check for existence on disk, but it may be useful to attempt it, possibly with an optional command-line argument.
I.e. in my git st in my dotfiles at the moment:

?? sublime-text-3/Package Control.ca-bundle
?? sublime-text-3/Package Control.ca-list

Installation fails on Go 1.18

Starting in Go 1.18 the go get command no longer supports installing packages (deprecation notice), and instead now requires using go install. However, trying to install path-extractor using go install fails:

  • Specifying the repo:
    $ go install github.com/edi9999/path-extractor@latest
    package github.com/edi9999/path-extractor is not a main package
  • Attempting to point to the path-extractor directory, since pe.go is a main package:
    $ go install github.com/edi9999/path-extractor/tree/master/path-extractor@latest
    go: github.com/edi9999/path-extractor/tree/master/path-extractor@latest: module github.com/edi9999/path-extractor@latest found (v0.2.0), but does not contain package github.com/edi9999/path-extractor/tree/master/path-extractor

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.