开源PathPicker - 非死book 出品的 Git 命令行 UI 交互插件

JilLarocca 7年前
   <h2>PathPicker</h2>    <p>非死book PathPicker is a simple command line tool that solves the perpetual problem of selecting files out of bash output. PathPicker will:</p>    <ul>     <li>Parse all incoming lines for entries that look like files</li>     <li>Present the piped input in a convenient selector UI</li>     <li>Allow you to either:      <ul>       <li>Edit the selected files in your favorite $EDITOR</li>       <li>Execute an arbitrary command with them</li>      </ul> </li>    </ul>    <p style="text-align: center;">It is easiest to understand by watching a simple demo: <img src="https://simg.open-open.com/show/f2076d35c7f6f8e4d54a26ee5af7f651.png"></p>    <h2>Examples</h2>    <p>After installing PathPicker, using it is as easy as piping into fpp . It takes a wide variety of input -- try it with all the options below:</p>    <ul>     <li>git status | fpp</li>     <li>hg status | fpp</li>     <li>git grep "FooBar" | fpp</li>     <li>grep -r "FooBar" . | fpp</li>     <li>git diff HEAD~1 --stat | fpp</li>     <li>find . -iname "*.js" | fpp</li>     <li>arc inlines | fpp</li>    </ul>    <p>and anything else you can dream up!</p>    <h2>Requirements</h2>    <p>PathPicker requires Python >2.6 or >3.0.</p>    <h3>Supported Shells:</h3>    <ul>     <li>Bash is fully supported and works the best.</li>     <li>ZSH is supported as well but won't have a few features like alias expansion in command line mode.</li>     <li>csh/fish/rc are supported in the latest version, but might have quirks or issues in older versions of PathPicker. Note however if your default shell and current shell is not in the same family (bash/zsh... v.s. fish/rc), you need to manually export environment variable $SHELL to your current shell.</li>    </ul>    <h2>Installing PathPicker</h2>    <h3>Homebrew</h3>    <p>Installing PathPicker is easiest with <a href="/misc/goto?guid=4958824006634651729" rel="nofollow,noindex">Homebrew for mac</a> :</p>    <ul>     <li>brew update (to pull down the recipe since it is new)</li>     <li>brew install fpp</li>    </ul>    <h3>Linux</h3>    <p>On debian systems, installation can be done by installing the debian package from <a href="/misc/goto?guid=4959739864267105951" rel="nofollow,noindex">here</a></p>    <p>On Arch Linux, PathPicker can be installed from Arch User Repository (AUR). <a href="/misc/goto?guid=4959739864355754178" rel="nofollow,noindex">the AUR fpp-git package</a> .</p>    <p>If you are on another system, or prefer manual installation, please follow the instructions given below.</p>    <h3>Manual Installation</h3>    <p>However if you're on a system without Homebrew, it's still quite easy to install PathPicker since it's essentially just a bash script that calls some Python. These steps more-or-less outline the process:</p>    <ul>     <li>cd /usr/local/ # or wherever you install apps</li>     <li>git clone https://github.com/非死book/PathPicker.git</li>     <li>cd PathPicker/</li>    </ul>    <p>Here we make a symbolic link from the bash script in the repo to /usr/local/bin/ which is assumed to be in the current $PATH</p>    <ul>     <li>ln -s "$(pwd)/fpp" /usr/local/bin/fpp</li>     <li>fpp --help # should work!</li>    </ul>    <h3>Add-ons</h3>    <p>For tmux users, you can additionally install tmux-fpp which adds a key combination to run PathPicker on the last received stdout . It makes jumping into file selection mode even easier -- <a href="/misc/goto?guid=4959739864439579153" rel="nofollow,noindex">check it out here</a> .</p>    <h2>Advanced Functionality</h2>    <p style="text-align: center;">As mentioned above, PathPicker allows you to also execute arbitrary commands with the specified files. Here is an example showing a git checkout command executed against the selected files: <img src="https://simg.open-open.com/show/45376696cb80a045e575feb6d67f02ae.png"></p>    <p>The selected files are appended to the command prefix to form the final command. If you need the files in the middle of your command, you can use the $F token instead, like:</p>    <p>cat $F | wc -l</p>    <p>Another important note is that PathPicker by default only selects files that exist on the filesystem. If you want to skip this (perhaps to selected deleted files in git status ), just run PathPicker with the --no-file-checks flag.</p>    <h2>How PathPicker works</h2>    <p>PathPicker is a combination of a bash script and some small Python modules. It essentially has three steps:</p>    <ul>     <li>First in the bash script, it redirects all standard out in to a python module that parses and extracts out filename candidates. Each candidate is then checked against the actual filesystem to ensure it exists; after that, we save the data in a temporary file and the python script exits.</li>     <li>Next, the bash script switches to terminal input mode and another python module reads out the saved entries and presents them in a selector UI built with curses . The user either selects a few files to edit or inputs a command to execute.</li>     <li>Lastly, the python script outputs a command to a bash file that is later executed by the original bash script.</li>    </ul>    <p>It's not the most elegant architecture in the world but (in our opinion) provides a lot of utility.</p>    <h2>Documentation & Configuration</h2>    <p>For all documentation and configuration options, see the output of fpp --help .</p>    <h2>Join the PathPicker community</h2>    <p>See the CONTRIBUTING file for how to help out.</p>    <h2>License</h2>    <p>PathPicker is BSD-licensed. We also provide an additional patent grant.</p>    <p> </p>    <p>来自:https://github.com/非死book/PathPicker</p>    <p> </p>