Rust 中的模糊查找器!
Life is short, skim!
We spend so much of our time navigating through files, lines, and commands. That's where Skim comes in!
It's a powerful fuzzy finder designed to make your workflow faster and more efficient.
Skim provides a single executable called sk. Think of it as a smarter alternative to tools like
grep - once you try it, you'll wonder how you ever lived without it!
skim
The skim project contains several components:
sk executable - the core programsk inside Vim/Nvim. Check skim.vim for Vim support.| OS | Package Manager | Command |
|---|---|---|
| macOS | Homebrew | brew install sk |
| macOS | MacPorts | sudo port install skim |
| Alpine | apk | apk add skim |
| Arch | pacman | pacman -S skim |
| Fedora | COPR | see below |
| Gentoo | Portage | emerge --ask app-misc/skim |
| Guix | guix | guix install skim |
| Void | XBPS | xbps-install -S skim |
| Windows | winget | winget install skim |
| Windows | Scoop | scoop install skim |
| Debian/Ubuntu | apt | see below |
| Fedora/RHEL | dnf | see below |
A custom APT repository is available and updated automatically during each release:
With wget:
sudo mkdir -p /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/skim.asc https://skim-rs.github.io/skim/apt/skim-archive-keyring.ascOr with cURL:
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://skim-rs.github.io/skim/apt/skim-archive-keyring.asc | sudo tee /etc/apt/keyrings/skim.asc > /dev/nullecho 'deb [signed-by=/etc/apt/keyrings/skim.asc] https://skim-rs.github.io/skim/apt ./' | sudo tee /etc/apt/sources.list.d/skim.list
sudo apt-get updatesudo apt-get install skimAlternatively, .deb packages are attached directly to every release.
Download the one matching your architecture and run sudo dpkg -i skim_*_amd64.deb
Up-to-date Fedora/RHEL packages are provided via an unofficial community-maintained COPR repository.
sudo dnf copr enable sisyphus1813/skim
sudo dnf install skimAlternatively, .rpm packages are attached directly to every release.
Download it and run sudo rpm -i skim-*.x86_64.rpm
Any of the following applies:
# Always check the content of the script before running it !
$ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/skim-rs/skim/releases/latest/download/skim-installer.sh | shcargo install skim$ git clone --depth 1 [email protected]:skim-rs/skim.git ~/.skim
$ cd ~/.skim
$ cargo build --release
$ # Add the resulting `target/release/sk` executable to your PATHYou will then have access to:
man --local-file <(sk --man)source <(sk --shell \<shell> \[--shell-bindings]), see below for detailsSkim can be used either as a general filter (similar to grep) or as an interactive
interface for running commands.
Via vim-plug (recommended):
Install skim, then :
Plug 'skim-rs/skim'Here are some examples to get you started:
# directly invoke skim
sk
# Or pipe some input to it (press TAB key to select multiple items when -m is enabled)
vim $(find . -name "*.rs" | sk -m)This last command lets you select files with the ".rs" extension and opens your selections in Vim - a great time-saver for developers!
skim can invoke other commands dynamically. Normally you would want to
integrate it with grep,
ack,
ag, or
rg for searching contents in a
project directory:
# works with grep
sk --ansi -i -c 'grep -rI --color=always --line-number {q} .'
# works with ack
sk --ansi -i -c 'ack --color {q}'
# works with ag
sk --ansi -i -c 'ag --color {q}'
# works with rg
sk --ansi -i -c 'rg --color=always --line-number {q}'Note: In these examples,
{q}will be literally expanded to the current input query (wrapped in single quotes). This means these examples will search for the exact query string, not fuzzily. For fuzzy searching, pipe the command output intoskwithout using interactive mode.
Bindings for Fish, Bash and Zsh are available in the shell directory:
completion.{shell} contains the completion scripts for sk cli usagekey-bindings.{shell} contains key-binds and shell integrations:ctrl-t to select a file through skctrl-r to select an history entry through skalt-c to cd into a directory selected through skfish) ** to complete file paths, for example ls **<tab> will show a sk widget to select a folderTo enable these features, source the key-bindings.{shell} file and set up completions according to your shell's documentation or see below.
You can generate shell completions for your preferred shell using the --shell flag with one of the supported shells: bash, zsh, fish, powershell, or elvish:
# For bash
source <(sk --shell bash)
# For zsh
source <(sk --shell zsh)
# For fish
sk --shell fish | source# For bash, add to ~/.bashrc
echo 'source <(sk --shell bash)' >> ~/.bashrc # Or save to ~/.bash_completion
# For zsh, add to ~/.zshrc
sk --shell zsh > ~/.zfunc/_sk # Create ~/.zfunc directory and add to fpath in ~/.zshrc
# For fish, add to ~/.config/fish/completions/
sk --shell fish > ~/.config/fish/completions/sk.fishSome commonly used key bindings:
| Key | Action |
|---|---|
| Enter | Accept (select current one and quit) |
| ESC/Ctrl-G | Abort |
| Ctrl-P/Up | Move cursor up |
| Ctrl-N/Down | Move cursor Down |
| TAB | Toggle selection and move down (with -m) |
| Shift-TAB | Toggle selection and move up (with -m) |
For a complete list of key bindings, refer to the man
page (man sk).
skim borrows fzf's syntax for matching items:
| Token | Match type | Description |
|---|---|---|
text |
fuzzy-match | items that match text |
^music |
prefix-exact-match | items that start with music |
.mp3$ |
suffix-exact-match | items that end with .mp3 |
'wild |
exact-match (quoted) | items that include wild |
!fire |
inverse-exact-match | items that do not include fire |
!.mp3$ |
inverse-suffix-exact-match | items that do not end with .mp3 |
skim also supports the combination of tokens.
Whitespace has the meaning of AND. With the term src main, skim will search
for items that match both src and main.
| means OR (note the spaces around |). With the term .md$ | .markdown$, skim will search for items ends with either .md or
.markdown.
OR has higher precedence. For example, readme .md$ | .markdown$ is interpreted as
readme AND (.md$ OR .markdown$).
When using the --split-match option, each part around spaces or | will be matched in a split way:
:) is absent from the query, do a normal matchrg to match on both file name and content.If you prefer using regular expressions, skim offers a regex mode:
sk --regexYou can switch to regex mode dynamically by pressing Ctrl-R (Rotate Mode).
| Exit Code | Meaning |
|---|---|
| 0 | Exited normally |
| 1 | No Match found |
| 130 | Aborted by Ctrl-C/Ctrl-G/ESC/etc... |
skimThese tools are or aim to be compatible with skim:
A [