diff --git a/README.md b/README.md index d4d1838..5435b78 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,27 @@ + +> [!NOTE] +> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。 +> [English](./README.en.md) · [原始项目](https://github.com/junegunn/fzf) · [上游 README](https://github.com/junegunn/fzf/blob/HEAD/README.md) +> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。 +
---
+
-Whether you're selecting files, browsing command history, previewing data,
-navigating complex datasets with fuzzy matching, or creating custom menus and
-workflows, fzf provides the building blocks to turn shell scripts into rich
-terminal applications.
+无论你是选择文件、浏览命令历史、预览数据、
+通过模糊匹配浏览复杂数据集,还是创建自定义菜单和
+工作流,fzf 都提供了将 shell 脚本转变为丰富
+终端应用所需的构建模块。
-Highlights
+亮点
----------
-- **Portable** // Distributed as a single binary for easy installation
-- **Fast** // Optimized to process millions of items in milliseconds
-- **Programmable** // Event-driven architecture for building custom terminal interfaces and workflows
-- **Batteries-included** // Comes with integrations for Bash, Zsh, Fish, Nushell, Vim, and Neovim
+- **便携** // 以单一二进制文件分发,便于安装
+- **快速** // 经过优化,可在毫秒内处理数百万条目
+- **可编程** // 事件驱动架构,用于构建自定义终端界面和工作流
+- **开箱即用** // 内置与 Bash、Zsh、Fish、Nushell、Vim 和 Neovim 的集成
-Table of Contents
+目录
-----------------
-* [Installation](#installation)
- * [Using Homebrew](#using-homebrew)
- * [Using Mise](#using-mise)
- * [Linux packages](#linux-packages)
- * [Windows packages](#windows-packages)
- * [Using git](#using-git)
- * [Binary releases](#binary-releases)
- * [Setting up shell integration](#setting-up-shell-integration)
- * [Vim/Neovim plugin](#vimneovim-plugin)
-* [Upgrading fzf](#upgrading-fzf)
-* [Building fzf](#building-fzf)
-* [Usage](#usage)
- * [Using the finder](#using-the-finder)
- * [Display modes](#display-modes)
- * [`--height` mode](#--height-mode)
- * [`--popup` mode](#--popup-mode)
- * [Search syntax](#search-syntax)
- * [Environment variables](#environment-variables)
- * [Customizing the look](#customizing-the-look)
- * [Options](#options)
- * [Demo](#demo)
-* [Examples](#examples)
-* [Key bindings for command-line](#key-bindings-for-command-line)
-* [Fuzzy completion](#fuzzy-completion)
- * [Files and directories](#files-and-directories)
- * [Process IDs](#process-ids)
- * [Host names](#host-names)
- * [Environment variables / Aliases](#environment-variables--aliases)
- * [Customizing fuzzy completion for bash and zsh](#customizing-fuzzy-completion-for-bash-and-zsh)
- * [Customizing fzf options for completion](#customizing-fzf-options-for-completion)
- * [Customizing completion source for paths and directories](#customizing-completion-source-for-paths-and-directories)
- * [Supported commands (bash)](#supported-commands-bash)
- * [Custom fuzzy completion](#custom-fuzzy-completion)
- * [Fuzzy completion for fish](#fuzzy-completion-for-fish)
- * [Fuzzy completion for Nushell](#fuzzy-completion-for-nushell)
-* [Vim plugin](#vim-plugin)
-* [Advanced topics](#advanced-topics)
- * [Customizing for different types of input](#customizing-for-different-types-of-input)
- * [Performance](#performance)
- * [Executing external programs](#executing-external-programs)
- * [Turning into a different process](#turning-into-a-different-process)
- * [Reloading the candidate list](#reloading-the-candidate-list)
- * [1. Update the list of processes by pressing CTRL-R](#1-update-the-list-of-processes-by-pressing-ctrl-r)
- * [2. Switch between sources by pressing CTRL-D or CTRL-F](#2-switch-between-sources-by-pressing-ctrl-d-or-ctrl-f)
- * [3. Interactive ripgrep integration](#3-interactive-ripgrep-integration)
- * [Preview window](#preview-window)
- * [Previewing an image](#previewing-an-image)
-* [Tips](#tips)
- * [Respecting `.gitignore`](#respecting-gitignore)
+* [安装](#installation)
+ * [使用 Homebrew](#using-homebrew)
+ * [使用 Mise](#using-mise)
+ * [Linux 软件包](#linux-packages)
+ * [Windows 软件包](#windows-packages)
+ * [使用 git](#using-git)
+ * [二进制发行版](#binary-releases)
+ * [配置 shell 集成](#setting-up-shell-integration)
+ * [Vim/Neovim 插件](#vimneovim-plugin)
+* [升级 fzf](#upgrading-fzf)
+* [构建 fzf](#building-fzf)
+* [用法](#usage)
+ * [使用查找器](#using-the-finder)
+ * [显示模式](#display-modes)
+ * [`--height` 模式](#--height-mode)
+ * [`--popup` 模式](#--popup-mode)
+ * [搜索语法](#search-syntax)
+ * [环境变量](#environment-variables)
+ * [自定义外观](#customizing-the-look)
+ * [选项](#options)
+ * [演示](#demo)
+* [示例](#examples)
+* [命令行快捷键](#key-bindings-for-command-line)
+* [模糊补全](#fuzzy-completion)
+ * [文件和目录](#files-and-directories)
+ * [进程 ID](#process-ids)
+ * [主机名](#host-names)
+ * [环境变量 / 别名](#environment-variables--aliases)
+ * [为 bash 和 zsh 自定义模糊补全](#customizing-fuzzy-completion-for-bash-and-zsh)
+ * [自定义 fzf 补全选项](#customizing-fzf-options-for-completion)
+ * [自定义路径和目录的补全来源](#customizing-completion-source-for-paths-and-directories)
+ * [支持的命令(bash)](#supported-commands-bash)
+ * [自定义模糊补全](#custom-fuzzy-completion)
+ * [Fish 的模糊补全](#fuzzy-completion-for-fish)
+ * [Nushell 的模糊补全](#fuzzy-completion-for-nushell)
+* [Vim 插件](#vim-plugin)
+* [高级主题](#advanced-topics)
+ * [针对不同输入类型的自定义](#customizing-for-different-types-of-input)
+ * [性能](#performance)
+ * [执行外部程序](#executing-external-programs)
+ * [切换为不同进程](#turning-into-a-different-process)
+ * [重新加载候选列表](#reloading-the-candidate-list)
+ * [1. 按 CTRL-R 更新进程列表](#1-update-the-list-of-processes-by-pressing-ctrl-r)
+ * [2. 按 CTRL-D 或 CTRL-F 在来源之间切换](#2-switch-between-sources-by-pressing-ctrl-d-or-ctrl-f)
+ * [3. 交互式 ripgrep 集成](#3-interactive-ripgrep-integration)
+ * [预览窗口](#preview-window)
+ * [预览图片](#previewing-an-image)
+* [技巧](#tips)
+ * [遵循 `.gitignore`](#respecting-gitignore)
* [Fish shell](#fish-shell)
- * [fzf Theme Playground](#fzf-theme-playground)
-* [Related projects](#related-projects)
-* [License](#license)
-* [Goods](#goods)
-* [Sponsors :heart:](#sponsors-heart)
+ * [fzf 主题游乐场](#fzf-theme-playground)
+* [相关项目](#related-projects)
+* [许可证](#license)
+* [周边商品](#goods)
+* [赞助者 :heart:](#sponsors-heart)
-Installation
+安装
------------
-### Using Homebrew
+### 使用 Homebrew
-You can use [Homebrew](https://brew.sh/) (on macOS or Linux) to install fzf.
+你可以使用 [Homebrew](https://brew.sh/)(在 macOS 或 Linux 上)安装 fzf。
```sh
brew install fzf
```
> [!IMPORTANT]
-> To set up shell integration (key bindings and fuzzy completion),
-> see [the instructions below](#setting-up-shell-integration).
+> 要配置 shell 集成(快捷键和模糊补全),
+> 请参阅[下方说明](#setting-up-shell-integration)。
-fzf is also available [via MacPorts][portfile]: `sudo port install fzf`
+fzf 也可通过 [MacPorts][portfile] 获取:`sudo port install fzf`
[portfile]: https://github.com/macports/macports-ports/blob/master/sysutils/fzf/Portfile
-### Using Mise
+### 使用 Mise
-You can use [mise](https://github.com/jdx/mise) to install fzf.
+你可以使用 [mise](https://github.com/jdx/mise) 安装 fzf。
```sh
mise use -g fzf@latest
```
-### Linux packages
+### Linux 软件包
-| Package Manager | Linux Distribution | Command |
+| 软件包管理器 | Linux 发行版 | 命令 |
| --------------- | ----------------------- | ---------------------------------- |
| APK | Alpine Linux | `sudo apk add fzf` |
| APT | Debian 9+/Ubuntu 19.10+ | `sudo apt install fzf` |
@@ -151,17 +157,17 @@ mise use -g fzf@latest
| Zypper | openSUSE | `sudo zypper install fzf` |
> [!IMPORTANT]
-> To set up shell integration (key bindings and fuzzy completion),
-> see [the instructions below](#setting-up-shell-integration).
+> 要配置 shell 集成(快捷键和模糊补全),
+> 请参阅[下方说明](#setting-up-shell-integration)。
[](https://repology.org/project/fzf/versions)
-### Windows packages
+### Windows 软件包
-On Windows, fzf is available via [Chocolatey][choco], [Scoop][scoop],
-[Winget][winget], and [MSYS2][msys2]:
+在 Windows 上,可通过 [Chocolatey][choco]、[Scoop][scoop]、
+[Winget][winget] 和 [MSYS2][msys2] 安装 fzf:
-| Package manager | Command |
+| 软件包管理器 | 命令 |
| --------------- | ------------------------------------- |
| Chocolatey | `choco install fzf` |
| Scoop | `scoop install fzf` |
@@ -173,180 +179,173 @@ On Windows, fzf is available via [Chocolatey][choco], [Scoop][scoop],
[winget]: https://github.com/microsoft/winget-pkgs/tree/master/manifests/j/junegunn/fzf
[msys2]: https://packages.msys2.org/base/mingw-w64-fzf
-### Using git
+### 使用 git
-Alternatively, you can "git clone" this repository to any directory and run
-[install](https://github.com/junegunn/fzf/blob/master/install) script.
+或者,你可以将此仓库 "git clone" 到任意目录,然后运行
+[安装](https://github.com/junegunn/fzf/blob/master/install) 脚本。
```sh
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
```
-The install script will add lines to your shell configuration file to modify
-`$PATH` and set up shell integration.
+安装脚本会向你的 shell 配置文件中添加行,以修改
+`$PATH` 并设置 shell 集成。
-### Binary releases
+### 二进制发布版
-You can download the official fzf binaries from the releases page.
+你可以从发布页面下载官方的 fzf 二进制文件。
* https://github.com/junegunn/fzf/releases
-### Setting up shell integration
+### 设置 shell 集成
-Add the following line to your shell configuration file.
+将以下行添加到你的 shell 配置文件中。
* bash
```sh
- # Set up fzf key bindings and fuzzy completion
+ # 设置 fzf 快捷键和模糊补全
eval "$(fzf --bash)"
```
* zsh
```sh
- # Set up fzf key bindings and fuzzy completion
+ # 设置 fzf 快捷键和模糊补全
source <(fzf --zsh)
```
* fish
```fish
- # Set up fzf key bindings
+ # 设置 fzf 快捷键
fzf --fish | source
```
-* Nushell -- Nushell does not support piping into `source`, so the install
- script generates a file in the autoload directory. If you didn't use the
- install script, you can manually set it up:
+* Nushell——Nushell 不支持将内容管道到 `source`,因此安装
+ 脚本会在自动加载目录中生成一个文件。如果你没有使用安装脚本,可以手动设置:
```nu
- # Generate the integration script
+ # 生成集成脚本
mkdir ($nu.default-config-dir | path join "autoload")
fzf --nushell | save -f ($nu.default-config-dir | path join "autoload" "_fzf_integration.nu")
```
> [!NOTE]
-> `--bash`, `--zsh`, `--fish`, and `--nushell` options are only available in
-> recent versions of fzf. If you have an older version of fzf, or want finer control, you can
-> source individual script files in the [/shell](/shell) directory. The
-> location of the files may vary depending on the package manager you use.
-> Please refer to the package documentation for more information.
-> (e.g. `apt show fzf`)
+> `--bash`、`--zsh`、`--fish` 和 `--nushell` 选项仅适用于
+> 较新版本的 fzf。如果你使用较旧版本的 fzf,或希望进行更精细的控制,可以
+> 引用 [/shell](/shell) 目录中的各个脚本文件。这些
+> 文件的位置可能因你所用的包管理器而异。
+> 请参阅包文档以获取更多信息。
+> (例如 `apt show fzf`)
> [!TIP]
-> You can disable CTRL-T, CTRL-R, or ALT-C bindings by setting the
-> corresponding `*_COMMAND` variable to an empty string when sourcing the
-> script. For example, to disable CTRL-R and ALT-C:
+> 你可以通过在引用脚本时,将对应的 `*_COMMAND` 变量设为空字符串来禁用
+> CTRL-T、CTRL-R 或 ALT-C 快捷键。例如,禁用 CTRL-R 和 ALT-C:
>
-> * bash: `FZF_CTRL_R_COMMAND= FZF_ALT_C_COMMAND= eval "$(fzf --bash)"`
-> * zsh: `FZF_CTRL_R_COMMAND= FZF_ALT_C_COMMAND= source <(fzf --zsh)`
-> * fish: `fzf --fish | FZF_CTRL_R_COMMAND= FZF_ALT_C_COMMAND= source`
-> * nushell: add to your `env.nu`:
+> * bash:`FZF_CTRL_R_COMMAND= FZF_ALT_C_COMMAND= eval "$(fzf --bash)"`
+> * zsh:`FZF_CTRL_R_COMMAND= FZF_ALT_C_COMMAND= source <(fzf --zsh)`
+> * fish:`fzf --fish | FZF_CTRL_R_COMMAND= FZF_ALT_C_COMMAND= source`
+> * nushell:在你的 `env.nu` 中添加:
> `$env.FZF_CTRL_R_COMMAND = ""; $env.FZF_ALT_C_COMMAND = ""`
>
-> Setting the variables after sourcing the script will have no effect.
+> 在引用脚本之后设置变量将不会生效。
-### Vim/Neovim plugin
+### Vim/Neovim 插件
-If you use [vim-plug](https://github.com/junegunn/vim-plug), add this to
-your Vim configuration file:
+如果你使用 [vim-plug](https://github.com/junegunn/vim-plug),),请将以下内容添加到
+你的 Vim 配置文件中:
```vim
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
```
-* `junegunn/fzf` provides the basic library functions
- * `fzf#install()` makes sure that you have the latest binary
-* `junegunn/fzf.vim` is [a separate project](https://github.com/junegunn/fzf.vim)
- that provides a variety of useful commands
+* `junegunn/fzf` 提供基础库函数
+ * `fzf#install()` 确保你拥有最新二进制文件
+* `junegunn/fzf.vim` 是[一个独立项目](https://github.com/junegunn/fzf.vim)),
+ 提供各种有用的命令
-To learn more about the Vim integration, see [README-VIM.md](README-VIM.md).
+要了解更多关于 Vim 集成的信息,请参阅 [README-VIM.md](README-VIM.md)。
> [!TIP]
-> If you use Neovim and prefer Lua-based plugins, check out
-> [fzf-lua](https://github.com/ibhagwan/fzf-lua).
+> 如果你使用 Neovim 并偏好基于 Lua 的插件,请查看
+> [fzf-lua](https://github.com/ibhagwan/fzf-lua).)
-Upgrading fzf
+升级 fzf
-------------
-fzf is being actively developed, and you might want to upgrade it once in a
-while. Please follow the instruction below depending on the installation
-method used.
+fzf 正在积极开发中,你可能需要时不时地升级它。请根据你使用的安装方式
+按照以下说明操作。
-- git: `cd ~/.fzf && git pull && ./install`
-- brew: `brew update; brew upgrade fzf`
-- macports: `sudo port upgrade fzf`
-- chocolatey: `choco upgrade fzf`
-- vim-plug: `:PlugUpdate fzf`
+- git:`cd ~/.fzf && git pull && ./install`
+- brew:`brew update; brew upgrade fzf`
+- macports:`sudo port upgrade fzf`
+- chocolatey:`choco upgrade fzf`
+- vim-plug:`:PlugUpdate fzf`
-Building fzf
+构建 fzf
------------
-See [BUILD.md](BUILD.md).
+请参阅 [BUILD.md](BUILD.md)。
-Usage
+用法
-----
-fzf will launch interactive finder, read the list from STDIN, and write the
-selected item to STDOUT.
+fzf 会启动交互式查找器,从 STDIN 读取列表,并将选中的项目写入 STDOUT。
```sh
find * -type f | fzf > selected
```
-Without STDIN pipe, fzf will traverse the file system under the current
-directory to get the list of files.
+没有 STDIN 管道时,fzf 会遍历当前目录下的文件系统来获取文件列表。
```sh
vim $(fzf)
```
> [!NOTE]
-> You can override the default behavior
-> * Either by setting `$FZF_DEFAULT_COMMAND` to a command that generates the desired list
-> * Or by setting `--walker`, `--walker-root`, and `--walker-skip` options in `$FZF_DEFAULT_OPTS`
+> 你可以覆盖默认行为
+> * 要么将 `$FZF_DEFAULT_COMMAND` 设置为一个生成所需列表的命令
+> * 要么在 `$FZF_DEFAULT_OPTS` 中设置 `--walker`、`--walker-root` 和 `--walker-skip` 选项
> [!WARNING]
-> A more robust solution would be to use `xargs` but we've presented
-> the above as it's easier to grasp
+> 更稳健的解决方案是使用 `xargs`,但我们展示
+> 了上述方案,因为它更容易理解
> ```sh
> fzf --print0 | xargs -0 -o vim
> ```
> [!TIP]
-> fzf also has the ability to turn itself into a different process.
+> fzf 还能够将自身转换为另一个进程。
>
> ```sh
> fzf --bind 'enter:become(vim {})'
> ```
>
-> *See [Turning into a different process](#turning-into-a-different-process)
-> for more information.*
+> *有关更多信息,请参阅[转换为另一个进程](#turning-into-a-different-process)。*
-### Using the finder
+### 使用查找器
-- `CTRL-K` / `CTRL-J` (or `CTRL-P` / `CTRL-N`) to move cursor up and down
-- `Enter` key to select the item, `CTRL-C` / `CTRL-G` / `ESC` to exit
-- On multi-select mode (`-m`), `TAB` and `Shift-TAB` to mark multiple items
-- Emacs style key bindings
-- Mouse: scroll, click, double-click; shift-click and shift-scroll on
- multi-select mode
+- `CTRL-K` / `CTRL-J`(或 `CTRL-P` / `CTRL-N`)上下移动光标
+- `Enter` 键选择项目,`CTRL-C` / `CTRL-G` / `ESC` 退出
+- 多选模式(`-m`)下,使用 `TAB` 和 `Shift-TAB` 标记多个项目
+- Emacs 风格快捷键
+- 鼠标:滚动、单击、双击;多选模式下 shift+单击 和 shift+滚动
-### Display modes
+### 显示模式
-fzf by default runs in fullscreen mode, but there are other display modes.
+fzf 默认以全屏模式运行,但也有其他显示模式。
-#### `--height` mode
+#### `--height` 模式
-With `--height HEIGHT[%]`, fzf will start below the cursor with the given height.
+使用 `--height HEIGHT[%]`,fzf 将在光标下方以指定高度启动。
```sh
fzf --height 40%
```
-`reverse` layout and `--border` goes well with this option.
+`reverse` 布局和 `--border` 与此选项搭配效果良好。
```sh
fzf --height 40% --layout reverse --border
```
-By prepending `~` to the height, you're setting the maximum height.
+在高度前加上 `~`,可以设置最大高度。
```sh
# Will take as few lines as possible to display the list
@@ -354,17 +353,17 @@ seq 3 | fzf --height ~100%
seq 3000 | fzf --height ~100%
```
-Height value can be a negative number.
+高度值可以是负数。
```sh
# Screen height - 3
fzf --height -3
```
-#### `--popup` mode
+#### `--popup` 模式
-With `--popup` option, fzf will start in a popup window
-(requires tmux 3.3+ or Zellij 0.44+).
+使用 `--popup` 选项,fzf 将在弹出窗口中启动
+(需要 tmux 3.3+ 或 Zellij 0.44+)。
```sh
# --popup [center|top|bottom|left|right][,SIZE[%]][,SIZE[%][,border-native]]
@@ -378,93 +377,88 @@ fzf --popup top,40% # Top, 40% height
fzf --popup bottom,80%,40% # Bottom, 80% width, 40% height
```
-`--popup` is silently ignored when you're not on tmux or Zellij.
+当你不处于 tmux 或 Zellij 环境中时,`--popup` 会被静默忽略。
> [!NOTE]
-> If you're stuck with an old version of tmux that doesn't support popup,
-> or if you want to open fzf in a regular tmux pane, check out
-> [fzf-tmux](bin/fzf-tmux) script.
+> 如果你使用的是不支持弹出窗口的旧版 tmux,
+> 或者你想在常规 tmux 窗格中打开 fzf,请查看
+> [fzf-tmux](bin/fzf-tmux) 脚本。
> [!TIP]
-> You can add these options to `$FZF_DEFAULT_OPTS` so that they're applied by
-> default. For example,
+> 你可以将这些选项添加到 `$FZF_DEFAULT_OPTS` 中,以便默认应用它们。
+> 例如,
>
> ```sh
-> # Open in a popup if on tmux or Zellij, otherwise use --height mode
+> # 如果在 tmux 或 Zellij 中则在弹出窗口中打开,否则使用 --height 模式
> export FZF_DEFAULT_OPTS='--height 40% --popup bottom,40% --layout reverse --border top'
> ```
-### Search syntax
+### 搜索语法
-Unless otherwise specified, fzf starts in "extended-search mode" where you can
-type in multiple search terms delimited by spaces. e.g. `^music .mp3$ sbtrkt
+除非另有指定,fzf 以"扩展搜索模式"启动,你可以输入多个以空格分隔的搜索词。例如 `^music .mp3$ sbtrkt
!fire`
-| Token | Match type | Description |
-| --------- | -------------------------------------- | ------------------------------------------ |
-| `sbtrkt` | fuzzy-match | Items that match `sbtrkt` |
-| `'wild` | exact-match (quoted) | Items that include `wild` |
-| `'wild'` | exact-boundary-match (quoted both ends) | Items that include `wild` at word boundaries |
-| `^music` | prefix-exact-match | Items that start with `music` |
-| `.mp3$` | suffix-exact-match | Items that end with `.mp3` |
-| `!fire` | inverse-exact-match | Items that do not include `fire` |
-| `!^music` | inverse-prefix-exact-match | Items that do not start with `music` |
-| `!.mp3$` | inverse-suffix-exact-match | Items that do not end with `.mp3` |
+| 标记 | 匹配类型 | 描述 |
+| --------- | -------------------------------------- | ------------------------------------------ |
+| `sbtrkt` | 模糊匹配 | 匹配 `sbtrkt` 的项目 |
+| `'wild` | 精确匹配(带引号) | 包含 `wild` 的项目 |
+| `'wild'` | 精确边界匹配(两端均带引号) | 在单词边界处包含 `wild` 的项目 |
+| `^music` | 前缀精确匹配 | 以 `music` 开头的项目 |
+| `.mp3$` | 后缀精确匹配 | 以 `.mp3` 结尾的项目 |
+| `!fire` | 反向精确匹配 | 不包含 `fire` 的项目 |
+| `!^music` | 反向前缀精确匹配 | 不以 `music` 开头的项目 |
+| `!.mp3$` | 反向后缀精确匹配 | 不以 `.mp3` 结尾的项目 |
-If you don't prefer fuzzy matching and do not wish to "quote" every word,
-start fzf with `-e` or `--exact` option. Note that when `--exact` is set,
-`'`-prefix "unquotes" the term.
+如果你不喜欢模糊匹配且不希望给每个词加引号,
+请使用 `-e` 或 `--exact` 选项启动 fzf。注意,当设置了
+`--exact` 时,`'` 前缀会"取消引号"该词条。
-A single bar character term acts as an OR operator. For example, the following
-query matches entries that start with `core` and end with either `go`, `rb`,
-or `py`.
+单个竖线字符词条充当 OR 运算符。例如,以下查询匹配以 `core` 开头
+且以 `go`、`rb` 或 `py` 结尾的条目。
```
^core go$ | rb$ | py$
```
-### Environment variables
+### 环境变量
- `FZF_DEFAULT_COMMAND`
- - Default command to use when input is tty
- - e.g. `export FZF_DEFAULT_COMMAND='fd --type f'`
+ - 当输入为 tty 时使用的默认命令
+ - 例如 `export FZF_DEFAULT_COMMAND='fd --type f'`
- `FZF_DEFAULT_OPTS`
- - Default options
- - e.g. `export FZF_DEFAULT_OPTS="--layout=reverse --inline-info"`
+ - 默认选项
+ - 例如 `export FZF_DEFAULT_OPTS="--layout=reverse --inline-info"`
- `FZF_DEFAULT_OPTS_FILE`
- - If you prefer to manage default options in a file, set this variable to
- point to the location of the file
- - e.g. `export FZF_DEFAULT_OPTS_FILE=~/.fzfrc`
+ - 如果你更倾向于在文件中管理默认选项,请将此变量设置为
+ 指向该文件的位置
+ - 例如 `export FZF_DEFAULT_OPTS_FILE=~/.fzfrc`
> [!WARNING]
-> `FZF_DEFAULT_COMMAND` is not used by shell integration due to the
-> slight difference in requirements.
+> `FZF_DEFAULT_COMMAND` 未被 shell 集成使用,因为需求略有差异。
>
-> * `CTRL-T` runs `$FZF_CTRL_T_COMMAND` to get a list of files and directories
-> * `ALT-C` runs `$FZF_ALT_C_COMMAND` to get a list of directories
-> * `vim ~/**
|
| `full` |
|
| `minimal` |
|
-Here's an example based on the `full` preset:
+以下是一个基于 `full` 预设的示例:
@@ -494,104 +488,94 @@ git ls-files | fzf --style full \
-### Options
+### 选项
-See the man page (`fzf --man` or `man fzf`) for the full list of options.
+请查阅手册(`fzf --man` 或 `man fzf`)获取完整选项列表。
-### Demo
-If you learn by watching videos, check out this screencast by [@samoshkin](https://github.com/samoshkin) to explore `fzf` features.
+### 演示
+如果你喜欢通过视频学习,可以观看 [@samoshkin](https://github.com/samoshkin)) 制作的这个录屏,探索 `fzf` 的各项功能。
-
+
-Examples
+示例
--------
-* [Wiki page of examples](https://github.com/junegunn/fzf/wiki/examples)
- * *Disclaimer: The examples on this page are maintained by the community
- and are not thoroughly tested*
-* [Advanced fzf examples](https://github.com/junegunn/fzf/blob/master/ADVANCED.md)
+* [示例 Wiki 页面](https://github.com/junegunn/fzf/wiki/examples))
+ * *免责声明:该页面上的示例由社区维护,未经全面测试*
+* [高级 fzf 示例](https://github.com/junegunn/fzf/blob/master/ADVANCED.md))
-Key bindings for command-line
+命令行按键绑定
-----------------------------
-By [setting up shell integration](#setting-up-shell-integration), you can use
-the following key bindings in bash, zsh, fish, and Nushell.
+通过[设置 shell 集成](#setting-up-shell-integration),你可以在 bash、zsh、fish 和 Nushell 中使用以下按键绑定。
-- `CTRL-T` - Paste the selected files and directories onto the command-line
- - The list is generated using `--walker file,dir,follow,hidden` option
- - You can override the behavior by setting `FZF_CTRL_T_COMMAND` to a custom command that generates the desired list
- - Or you can set `--walker*` options in `FZF_CTRL_T_OPTS`
- - Set `FZF_CTRL_T_OPTS` to pass additional options to fzf
+- `CTRL-T` - 将选中的文件和目录粘贴到命令行中
+ - 列表通过 `--walker file,dir,follow,hidden` 选项生成
+ - 你可以通过设置 `FZF_CTRL_T_COMMAND` 为自定义命令来覆盖默认行为
+ - 或者你可以在 `FZF_CTRL_T_OPTS` 中设置 `--walker*` 选项
+ - 设置 `FZF_CTRL_T_OPTS` 以向 fzf 传递额外选项
```sh
- # Preview file content using bat (https://github.com/sharkdp/bat)
+ # 使用 bat 预览文件内容(https://github.com/sharkdp/bat))
export FZF_CTRL_T_OPTS="
--walker-skip .git,node_modules,target
--preview 'bat -n --color=always {}'
--bind 'ctrl-/:change-preview-window(down|hidden|)'"
```
- - Can be disabled by setting `FZF_CTRL_T_COMMAND` to an empty string when
- sourcing the script
-- `CTRL-R` - Paste the selected command from history onto the command-line.
- - Select multiple commands with `TAB`.
- - If you want to see the commands in chronological order, press `CTRL-R`
- again which toggles sorting by relevance
- - Press `ALT-R` to toggle "raw" mode where you can see the surrounding items
- of a match. In this mode, you can press `CTRL-N` and `CTRL-P` to move
- between the matching items only.
- - Press `CTRL-/` or `ALT-/` to toggle line wrapping
- - Press `SHIFT-DELETE` to delete the selected commands (bash and fish)
- - Fish shell only:
- - Press `ALT-ENTER` to reformat and insert the selected commands
- - Press `ALT-T` to cycle through command prefix (timestamp, date/time, none)
- - Set `FZF_CTRL_R_OPTS` to pass additional options to fzf
+ - 可以通过在加载脚本时将 `FZF_CTRL_T_COMMAND` 设为空字符串来禁用
+- `CTRL-R` - 将选中的历史命令粘贴到命令行中。
+ - 使用 `TAB` 选择多条命令。
+ - 如果想按时间顺序查看命令,再次按下 `CTRL-R` 可切换为按相关性排序
+ - 按下 `ALT-R` 切换"原始"模式,可查看匹配项周围的上下文。在该模式下,按下 `CTRL-N` 和 `CTRL-P` 仅在匹配项之间移动。
+ - 按下 `CTRL-/` 或 `ALT-/` 切换自动换行
+ - 按下 `SHIFT-DELETE` 删除选中的命令(bash 和 fish)
+ - 仅限 Fish shell:
+ - 按下 `ALT-ENTER` 重新格式化并插入选中的命令
+ - 按下 `ALT-T` 循环切换命令前缀(时间戳、日期/时间、无)
+ - 设置 `FZF_CTRL_R_OPTS` 以向 fzf 传递额外选项
```sh
- # CTRL-Y to copy the command into clipboard using pbcopy
+ # CTRL-Y 使用 pbcopy 将命令复制到剪贴板
export FZF_CTRL_R_OPTS="
--bind 'ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'
--color header:italic
--header 'Press CTRL-Y to copy command into clipboard'"
```
```fish
- # Fish shell: Set date/time as default prefix
+ # Fish shell:设置日期/时间为默认前缀
set -gx FZF_CTRL_R_OPTS "--with-nth 1,3.. --bind 'alt-t:change-with-nth(2..|3..|1,3..)'"
- # Or display no prefix by default
+ # 或默认不显示前缀
set -gx FZF_CTRL_R_OPTS "--with-nth 3.. --bind 'alt-t:change-with-nth(2..|1,3..|3..)'"
```
- - Can be disabled by setting `FZF_CTRL_R_COMMAND` to an empty string when
- sourcing the script
- - Custom override via a non-empty `FZF_CTRL_R_COMMAND` is not yet supported and will emit a warning
-- `ALT-C` - cd into the selected directory
- - The list is generated using `--walker dir,follow,hidden` option
- - Set `FZF_ALT_C_COMMAND` to override the default command
- - Or you can set `--walker-*` options in `FZF_ALT_C_OPTS`
- - Set `FZF_ALT_C_OPTS` to pass additional options to fzf
+ - 可以通过在加载脚本时将 `FZF_CTRL_R_COMMAND` 设为空字符串来禁用
+ - 通过非空的 `FZF_CTRL_R_COMMAND` 进行自定义覆盖暂不支持,会发出警告
+- `ALT-C` - 进入选中的目录
+ - 列表通过 `--walker dir,follow,hidden` 选项生成
+ - 设置 `FZF_ALT_C_COMMAND` 以覆盖默认命令
+ - 或者你可以在 `FZF_ALT_C_OPTS` 中设置 `--walker-*` 选项
+ - 设置 `FZF_ALT_C_OPTS` 以向 fzf 传递额外选项
```sh
- # Print tree structure in the preview window
+ # 在预览窗口中打印树形结构
export FZF_ALT_C_OPTS="
--walker-skip .git,node_modules,target
--preview 'tree -C {}'"
```
- - Can be disabled by setting `FZF_ALT_C_COMMAND` to an empty string when
- sourcing the script
+ - 可以通过在加载脚本时将 `FZF_ALT_C_COMMAND` 设为空字符串来禁用
-Display modes for these bindings can be separately configured via
-`FZF_{CTRL_T,CTRL_R,ALT_C}_OPTS` or globally via `FZF_DEFAULT_OPTS`.
-(e.g. `FZF_CTRL_R_OPTS='--popup bottom,60% --height 60% --border top'`)
+这些绑定的显示模式可通过 `FZF_{CTRL_T,CTRL_R,ALT_C}_OPTS` 单独配置,或通过 `FZF_DEFAULT_OPTS` 全局配置。
+(例如:`FZF_CTRL_R_OPTS='--popup bottom,60% --height 60% --border top'`)
-More tips can be found on [the wiki page](https://github.com/junegunn/fzf/wiki/Configuring-shell-key-bindings).
+更多技巧请参见 [Wiki 页面](https://github.com/junegunn/fzf/wiki/Configuring-shell-key-bindings).)
-Fuzzy completion
+模糊补全
----------------
-Shell integration also provides fuzzy completion for bash, zsh, fish, and Nushell.
+Shell 集成还为 bash、zsh、fish 和 Nushell 提供了模糊补全功能。
-### Files and directories
+### 文件和目录
-Fuzzy completion for files and directories can be triggered if the word before
-the cursor ends with the trigger sequence, which is by default `**`.
+如果光标前的单词以触发序列结尾(默认为 `**`),则可触发文件和目录的模糊补全。
- `COMMAND [DIRECTORY/][FUZZY_PATTERN]**