translate done: 20170925 A Commandline Fuzzy Search Tool For Linux.md

This commit is contained in:
darksun 2018-01-10 14:52:57 +08:00
parent 9b4b4db45c
commit 6c9938014f
2 changed files with 138 additions and 138 deletions

View File

@ -1,138 +0,0 @@
translating by lujun9972
A Commandline Fuzzy Search Tool For Linux
======
![](https://www.ostechnix.com/wp-content/uploads/2017/09/search-720x340.jpg)
Today, we will be discussing about an Interesting commandline utility called **" Pick"**. It allows users to select from a set of choices using an ncurses(3X) interface with fuzzy search functionality. The Pick utility can be helpful in certain situations where you wanted to search for a folder or file that contains a non-English characters in their name. You don't have to learn how to type the non-english characters. Using Pick, you can easily search them, select them and view or cd into them easily. You don't even have to type any characters to search a file or folder. It's good for those working with large pile of directories and files.
### Pick - A Commandline Fuzzy Search Tool For Linux
#### Installing Pick
For **Arch Linux** and its derivatives, Pick is available in [**AUR**][1]. So, the Arch users can install it using AUR helper tools such as [**Pacaur**][2], [**Packer**][3], and [**Yaourt**][4] etc.
```
pacaur -S pick
```
Or,
```
packer -S pick
```
Or,
```
yaourt -S pick
```
The **Debian** , **Ubuntu** , **Linux Mint** users run the following command to install Pick.
```
sudo apt-get install pick
```
For other distributions, download the latest release from [**here**][5] and follow the below instructions to install Pick. As of writing this guide, the latest version was 1.9.0.
```
wget https://github.com/calleerlandsson/pick/releases/download/v1.9.0/pick-1.9.0.tar.gz
tar -zxvf pick-1.9.0.tar.gz
cd pick-1.9.0/
```
Configure it using command:
```
./configure
```
Finally, build and install pick:
```
make
sudo make install
```
#### Usage
By combining it with other commands will make your commandline life much easier. I will show some examples, so you can understand how it works.
Let me create a stack of directories.
```
mkdir -p abcd/efgh/ijkl/mnop/qrst/uvwx/yz/
```
Now, you want to go the directory /ijkl/ directory. You have two choice. You can either use **cd** command like below:
```
cd abcd/efgh/ijkl/
```
Or, create a [**shortcut**][6] or an alias to that directory, so you can switch to the directory in no time.
Alternatively, just use "pick" command to switch a particular directory more easily. Have a look at the below example.
```
cd $(find . -type d | pick)
```
This command will list all directories and its sub-directories in the current working directory, so you can just select any directory you'd like to cd into using Up/Down arrows, and hit ENTER key.
**Sample output:**
[![][7]][8]
Also, it will suggest the directories or files that contains a specific letters as you type them. For example, the following output shows the list of suggestions when I type "or".
[![][7]][9]
It's just an example. You can use "pick" command along with other commands as well.
Here is an another example.
```
find -type f | pick | xargs less
```
This command will allow you to select any file in the current directory to view in less.
[![][7]][10]
Care to learn another example? Here you go. The following command will allow you to select individual files or folders in the current directory you want to move to any destination of your choice, for example **/home/sk/ostechnix**.
```
mv "$(find . -maxdepth 1 |pick)" /home/sk/ostechnix/
```
[![][7]][11]
Choose the file(s) by using Up/Down arrows and hit ENTER to move them to /home/sk/ostechnix/ directory.
[![][7]][12]
As you see in the above output, I have moved the folder called "abcd" to "ostechnix" directory.
The use cases are unlimited. There is also a plugin called [**pick.vim**][13] for Vim editor to make your searches much easier inside Vim editor.
For more details, refer man pages.
```
man pick
```
That's all for now folks. Hope this utility helps. If you find our guides useful, please share them on your social, professional networks and recommended OSTechNix blog to all your contacts.
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/pick-commandline-fuzzy-search-tool-linux/
作者:[SK][a]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.ostechnix.com/author/sk/
[1]:https://aur.archlinux.org/packages/pick/
[2]:https://www.ostechnix.com/install-pacaur-arch-linux/
[3]:https://www.ostechnix.com/install-packer-arch-linux-2/
[4]:https://www.ostechnix.com/install-yaourt-arch-linux/
[5]:https://github.com/calleerlandsson/pick/releases/
[6]:https://www.ostechnix.com/create-shortcuts-frequently-used-directories-shell/
[7]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[8]:http://www.ostechnix.com/wp-content/uploads/2017/09/sk@sk_001-3.png ()
[9]:http://www.ostechnix.com/wp-content/uploads/2017/09/sk@sk_002-1.png ()
[10]:http://www.ostechnix.com/wp-content/uploads/2017/09/sk@sk_004-1.png ()
[11]:http://www.ostechnix.com/wp-content/uploads/2017/09/sk@sk_005.png ()
[12]:http://www.ostechnix.com/wp-content/uploads/2017/09/sk@sk_006-1.png ()
[13]:https://github.com/calleerlandsson/pick.vim/

View File

@ -0,0 +1,138 @@
Pick - 一款 Linux 上的命令行模糊搜索工具
======
![](https//www.ostechnix.com/wp-content/uploads/2017/09/search-720x340.jpg)
今天,我们要讲的是一款有趣的命令行工具,名叫 `Pick`。它允许用户通过 ncurses3X 界面来从一系列选项中进行选择,而且还支持模糊搜索的功能。当你想要选择某个名字中包含非英文字符的目录或文件时,这款工具就很有用了。你根本都无需学习如何输入非英文字符。借助 Pick你可以很方便地进行搜索选择然后浏览该文件或进入该目录。你甚至无需输入任何字符来过滤文件/目录。这很适合那些有大量目录和文件的人来用。
### Pick - 一款 Linux 上的命令行模糊搜索工具
#### 安装 Pick
**Arch Linux** 及其衍生品来说pick 放在 [**AUR**][1] 中。因此 Arch 用户可以使用类似 [**Pacaur**][2][**Packer**][3],以及 [**Yaourt**][4] 等 AUR 辅助工具来安装它。
```
pacaur -S pick
```
或者,
```
packer -S pick
```
或者,
```
yaourt -S pick
```
**Debian****Ubuntu****Linux Mint** 用户则可以通过运行下面命令来安装 Pick。
```
sudo apt-get install pick
```
其他的发行版则可以从[**这里 **][5] 下载最新的安装包,然后按照下面的步骤来安装。在写本指南时,其最新版为 1.9.0。
```
wget https://github.com/calleerlandsson/pick/releases/download/v1.9.0/pick-1.9.0.tar.gz
tar -zxvf pick-1.9.0.tar.gz
cd pick-1.9.0/
```
使用下面命令进行配置:
```
./configure
```
最后,构建并安装 pick
```
make
sudo make install
```
#### 用法
通过将它与其他命令集成能够大幅简化你的工作。我这里会给出一些例子,让你理解它是怎么工作的。
让们先创建一堆目录。
```
mkdir -p abcd/efgh/ijkl/mnop/qrst/uvwx/yz/
```
现在,你想进入目录 `/ijkl/`。你有两种选择。可以使用 **cd** 命令:
```
cd abcd/efgh/ijkl/
```
或者,创建一个[**快捷方式 **][6] 或者说别名指向这个目录,这样你可以迅速进入该目录。
但,使用 "pick" 命令则问题变得简单的多。看下面这个例子。
```
cd $(find . -type d | pick)
```
这个命令会列出当前工作目录下的所有目录及其子目录,你可以用上下箭头选择你想进入的目录,然后按下回车就行了。
**像这样:**
[![][7]][8]
而且,它还会根据你输入的内容过滤目录和文件。比如,当我输入 “or” 时会显示如下结果。
[![][7]][9]
这只是一个例子。你也可以将 “pick” 命令跟其他命令一起混用。
这是另一个例子。
```
find -type f | pick | xargs less
```
该命令让你选择当前目录中的某个文件并用 less 来查看它。
[![][7]][10]
还想看其他例子?还有呢。下面命令让你选择当前目录下的文件或目录,并将之迁移到其他地方去,比如这里我们迁移到 **/home/sk/ostechnix**。
```
mv "$(find . -maxdepth 1 |pick)" /home/sk/ostechnix/
```
[![][7]][11]
通过上下按钮选择要迁移的文件,然后按下回车就会把它迁移到 `/home/sk/ostechnix/` 目录中的。
[![][7]][12]
从上面的结果中可以看到,我把一个名叫 “abcd” 的目录移动到 "ostechnix" 目录中了。
使用案例是无限的。甚至 Vim 编辑器上还有一个叫做 [**pick.vim**][13] 的插件让你在 Vim 中选择更加方便。
要查看详细信息,请参阅它的 man 页。
```
man pick
```
我们的讲解至此就结束了。希望这狂工具能给你们带来帮助。如果你觉得我们的指南有用的话,请将它分享到您的社交网络上,并向大家推荐 OSTechNix 博客。
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/pick-commandline-fuzzy-search-tool-linux/
作者:[SK][a]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.ostechnix.com/author/sk/
[1]:https://aur.archlinux.org/packages/pick/
[2]:https://www.ostechnix.com/install-pacaur-arch-linux/
[3]:https://www.ostechnix.com/install-packer-arch-linux-2/
[4]:https://www.ostechnix.com/install-yaourt-arch-linux/
[5]:https://github.com/calleerlandsson/pick/releases/
[6]:https://www.ostechnix.com/create-shortcuts-frequently-used-directories-shell/
[7]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[8]:http://www.ostechnix.com/wp-content/uploads/2017/09/sk@sk_001-3.png ()
[9]:http://www.ostechnix.com/wp-content/uploads/2017/09/sk@sk_002-1.png ()
[10]:http://www.ostechnix.com/wp-content/uploads/2017/09/sk@sk_004-1.png ()
[11]:http://www.ostechnix.com/wp-content/uploads/2017/09/sk@sk_005.png ()
[12]:http://www.ostechnix.com/wp-content/uploads/2017/09/sk@sk_006-1.png ()
[13]:https://github.com/calleerlandsson/pick.vim/