Fuzzy Finder in rust!

Related tags

rust fuzzyfinder skim
Overview

Crates.io Build & Test

Life is short, skim!

Half of our life is spent on navigation: files, lines, commands… You need skim! It is a general fuzzy finder that saves you time.

skim demo

skim provides a single executable: sk. Basically anywhere you would want to use grep, try sk instead.

Table of contents

Installation

The skim project contains several components:

  1. sk executable -- the core.
  2. sk-tmux -- script for launching sk in a tmux pane.
  3. Vim/Nvim plugin -- to call sk inside Vim/Nvim. check skim.vim for more Vim support.

Package Managers

Distribution Package Manager Command
macOS Homebrew brew install sk
macOS MacPorts sudo port install skim
Fedora dnf dnf install skim
Alpine apk apk add skim
Arch pacman pacman -S skim

Install as Vim plugin

Via vim-plug (recommended):

Plug 'lotabout/skim', { 'dir': '~/.skim', 'do': './install' }

Hard Core

Any of the following applies:

  • Using Git
    $ git clone --depth 1 [email protected]:lotabout/skim.git ~/.skim
    $ ~/.skim/install
  • Using Binary: directly download the sk executable.
  • Install from crates.io: cargo install skim
  • Build Manually
    $ git clone --depth 1 [email protected]:lotabout/skim.git ~/.skim
    $ cd ~/.skim
    $ cargo install
    $ cargo build --release
    $ # put the resulting `target/release/sk` executable on your PATH.

Usage

skim can be used as a general filter (like grep) or as an interactive interface for invoking commands.

As filter

Try the following

# directly invoke skim
sk

# or pipe some input to it: (press TAB key select multiple items with -m enabled)
vim $(find . -name "*.rs" | sk -m)

The above command will allow you to select files with ".rs" extension and open the ones you selected in Vim.

As Interactive Interface

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 "{}" .'
# works with ack
sk --ansi -i -c 'ack --color "{}"'
# works with ag
sk --ansi -i -c 'ag --color "{}"'
# works with rg
sk --ansi -i -c 'rg --color=always --line-number "{}"'

interactive mode demo

Key Bindings

Some 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 full list of key bindings, check out the man page (man sk).

Search Syntax

skim borrowed 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. So readme .md$ | .markdown$ is grouped into readme AND (.md$ OR .markdown$).

In case that you want to use regular expressions, skim provides regex mode:

sk --regex

You can switch to regex mode dynamically by pressing Ctrl-R (Rotate Mode).

exit code

Exit Code Meaning
0 Exit normally
1 No Match found
130 Abort by Ctrl-C/Ctrl-G/ESC/etc...

Customization

The doc here is only a preview, please check the man page (man sk) for a full list of options.

Keymap

Specify the bindings with comma separated pairs (no space allowed), example:

sk --bind 'alt-a:select-all,alt-d:deselect-all'

Additionally, use + to concatenate actions, such as execute-silent(echo {} | pbcopy)+abort.

See the KEY BINDINGS section of the man page for details.

Sort Criteria

There are five sort keys for results: score, index, begin, end, length, you can specify how the records are sorted by sk --tiebreak score,index,-begin or any other order you want.

Color Scheme

It is a high chance that you are a better artist than me. Luckily you won't be stuck with the default colors, skim supports customization of the color scheme.

--color=[BASE_SCHEME][,COLOR:ANSI]

The configuration of colors starts with the name of the base color scheme, followed by custom color mappings. For example:

sk --color=current_bg:24
sk --color=light,fg:232,bg:255,current_bg:116,info:27

See --color option in the man page for details.

Misc

  • --ansi: to parse ANSI color codes (e.g., \e[32mABC) of the data source
  • --regex: use the query as regular expression to match the data source

Advanced Topics

Interactive mode

With "interactive mode", you could invoke command dynamically. Try out:

sk --ansi -i -c 'rg --color=always --line-number "{}"'

How it works?

skim's interactive mode

  • Skim could accept two kinds of source: command output or piped input
  • Skim has two kinds of prompts: A query prompt to specify the query pattern and a command prompt to specify the "arguments" of the command
  • -c is used to specify the command to execute while defaults to SKIM_DEFAULT_COMMAND
  • -i is to tell skim open command prompt on startup, which will show c> by default.

If you want to further narrow down the results returned by the command, press Ctrl-Q to toggle interactive mode.

Executing external programs

You can set up key bindings for starting external processes without leaving skim (execute, execute-silent).

# Press F1 to open the file with less without leaving skim
# Press CTRL-Y to copy the line to clipboard and aborts skim (requires pbcopy)
sk --bind 'f1:execute(less -f {}),ctrl-y:execute-silent(echo {} | pbcopy)+abort'

Preview Window

This is a great feature of fzf that skim borrows. For example, we use 'ag' to find the matched lines, once we narrow down to the target lines, we want to finally decide which lines to pick by checking the context around the line. grep and ag has an option --context, skim can do better with preview window. For example:

sk --ansi -i -c 'ag --color "{}"' --preview "preview.sh {}"

(Note the preview.sh is a script to print the context given filename:lines:columns) You got things like this:

preview demo

How does it work?

If the preview command is given by the --preview option, skim will replace the {} with the current highlighted line surrounded by single quotes, call the command to get the output, and print the output on the preview window.

Sometimes you don't need the whole line for invoking the command. In this case you can use {}, {1..}, {..3} or {1..5} to select the fields. The syntax is explained in the section "Fields Support".

Last, you might want to configure the position of preview windows, use --preview-window.

  • --preview-window up:30% to put the window in the up position with height 30% of the total height of skim.
  • --preview-window left:10:wrap, to specify the wrap allows the preview window to wrap the output of the preview command.
  • --preview-window wrap:hidden to hide the preview window at startup, later it can be shown by the action toggle-preview.

Fields support

Normally only plugin users need to understand this.

For example, you have the data source with the format:

<filename>:<line number>:<column number>

However, you want to search <filename> only when typing in queries. That means when you type 21, you want to find a <filename> that contains 21, but not matching line number or column number.

You can use sk --delimiter ':' --nth 1 to achieve this.

Also you can use --with-nth to re-arrange the order of fields.

Range Syntax

  • <num> -- to specify the num-th fields, starting with 1.
  • start.. -- starting from the start-th fields, and the rest.
  • ..end -- starting from the 0-th field, all the way to end-th field, including end.
  • start..end -- starting from start-th field, all the way to end-th field, including end.

Use as a library

Skim can be used as a library in your Rust crates.

First, add skim into your Cargo.toml:

[dependencies]
skim = "*"

Then try to run this simple example:

extern crate skim;
use skim::prelude::*;
use std::io::Cursor;

pub fn main() {
    let options = SkimOptionsBuilder::default()
        .height(Some("50%"))
        .multi(true)
        .build()
        .unwrap();

    let input = "aaaaa\nbbbb\nccc".to_string();

    // `SkimItemReader` is a helper to turn any `BufRead` into a stream of `SkimItem`
    // `SkimItem` was implemented for `AsRef<str>` by default
    let item_reader = SkimItemReader::default();
    let items = item_reader.of_bufread(Cursor::new(input));

    // `run_with` would read and show items from the stream
    let selected_items = Skim::run_with(&options, Some(items))
        .map(|out| out.selected_items)
        .unwrap_or_else(|| Vec::new());

    for item in selected_items.iter() {
        print!("{}{}", item.output(), "\n");
    }
}

Given an Option<SkimItemReceiver>, skim will read items accordingly, do its job and bring us back the user selection including the selected items, the query, etc. Note that:

  • SkimItemReceiver is crossbeam::channel::Receiver<Arc<dyn SkimItem>>
  • If it is none, it will invoke the given command and read items from command output
  • Otherwise, it will read the items from the (crossbeam) channel.

Trait SkimItem is provided to customize how a line could be displayed, compared and previewed. It is implemented by default for AsRef<str>

Plus, SkimItemReader is a helper to convert a BufRead into SkimItemReceiver (we can easily turn a File for String into BufRead). So that you could deal with strings or files easily.

Check more examples under examples/ directory.

FAQ

How to ignore files?

Skim invokes find . to fetch a list of files for filtering. You can override that by setting the environment variable SKIM_DEFAULT_COMMAND. For example:

$ SKIM_DEFAULT_COMMAND="fd --type f || git ls-tree -r --name-only HEAD || rg --files || find ."
$ sk

You could put it in your .bashrc or .zshrc if you like it to be default.

Some files are not shown in Vim plugin

If you use the Vim plugin and execute the :SK command, you might find some of your files not shown.

As described in #3, in the Vim plugin, SKIM_DEFAULT_COMMAND is set to the command by default:

let $SKIM_DEFAULT_COMMAND = "git ls-tree -r --name-only HEAD || rg --files || ag -l -g \"\" || find ."

That means, the files not recognized by git will not shown. Either override the default with let $SKIM_DEFAULT_COMMAND = '' or find the missing file by yourself.

Differences to fzf

fzf is a command-line fuzzy finder written in Go and skim tries to implement a new one in Rust!

This project is written from scratch. Some decisions of implementation are different from fzf. For example:

  1. skim is a binary as well as a library while fzf is only a binary.
  2. skim has an interactive mode.
  3. skim supports pre-selection
  4. The fuzzy search algorithm is different.
  5. UI of showing matched items. fzf will show only the range matched while skim will show each character matched. (fzf has this now)
  6. skim's range syntax is Git style: now it is the same with fzf.

How to contribute

Create new issues if you meet any bugs or have any ideas. Pull requests are warmly welcomed.

Issues
  • `sk` suddenly stop working (no response)

    `sk` suddenly stop working (no response)

    Hi, I am a big fan of Rust and has since moved to sk from fzf. Thanks for the great work.

    Before updating 0.8.1, sk was working fine at all. After updating, all of a sudden it just stops working. sk does not have any response. I use fzf side-by-side with sk and fzf is still working as normal.

    Using pacman. I removed skim. Reinstall it. Issue persists.

    # Start cleanly
    bash --noprofile --norc
    
    fzf
    # working normally
    
    sk
    # no response
    sk
    # no response
    sk
    # no response
    
    echo $?
    # 101
    sk --version
    # 0.8.1
    sk --help
    # Usage: sk [options]
    #   Options
    #     -h, --help           print this help menu
    #     --version [...]
    # [truncated ..............................................]
    
    cat /etc/os-release
    #    1 NAME="Arch Linux"
    #    2 PRETTY_NAME="Arch Linux"
    #    3 ID=arch
    #    4 BUILD_ID=rolling
    #    5 ANSI_COLOR="0;36"
    #    6 HOME_URL="https://www.archlinux.org/"
    #    7 DOCUMENTATION_URL="https://wiki.archlinux.org/"
    #    8 SUPPORT_URL="https://bbs.archlinux.org/"
    #    9 BUG_REPORT_URL="https://bugs.archlinux.org/"
    #   10 LOGO=archlinux
    
    
    bug 
    opened by JodyStats 23
  • 'abort' doesn't abort all the time

    'abort' doesn't abort all the time

    When running find|sk --bind 'enter:execute(echo {})+abort', skim doesn't always abort.

    That is, the selection is printed, then a newline. But the caret stays on an empty line below, skim keeps running, and hitting enter again doesn't get us back to the shell. Typing ctrl-c is needed to end the program.

    Tested on Ubuntu 19.04 running konsole, bash 5.0.3 and skim 0.7.0.

    cannot-reproduce 
    opened by ngirard 12
  • Reuse as a library?

    Reuse as a library?

    I'd like to reuse skim inside my own application. With this, I mean reusing skim as a library. Inside my code, I'd like to pass Skim my sources, hand over control to skim which runs its CLI and once the user selects something, returns the selected items back to me. Mainly these are the features I'd like to have:

    • fuzzy finding, including interactivity and options (multi, non-multi).
    • providing my own input source, while decoupling the text that is shown to the user from what I get returned.

    A possible API could be this:

    /// Defined by skim.
    pub trait SkimItem: Send {
       /// The text displayed to the user.
       fn display(&self) -> Cow<&str>;
    }
    
    struct MyItem {
       .... many interesting fields.
    }
    
    impl SkimItem for MyItem {...}
    
    let (tx, rx) = channel::<MyItem>();
    // Launch a thread, send MyItems as they are generated into `tx`.
    let mut skim = Skim::with_sender(rx, SkimOptionsBuilder::new().multi_select(true).ignore_case(true));
    let result = skim.query_user();  // Consumes `sk`.
    
    /// Join the producing thread. `result` is now either an Err or a Vec<SkimItem>, so I know what was selected.
    

    I looked through the code and it seemed like this was not very easy to do right now, since the clap::ArgMatches is passed around instead of option structs and the UI and filtering code is a bit interleaved. Do you think this is a feasible feature request?

    opened by SirVer 12
  • Ignoring files

    Ignoring files

    It would be nice to be able to ignore certain files (e.g., dotfiles). It would be really nice if fzf-rs could read .gitignore etc (like ack, ag, and friends).

    opened by Stebalien 9
  • Exact matching mode without case sensitivity?

    Exact matching mode without case sensitivity?

    It seems the fuzzy matching mode is always case insensitive, and the exact matching mode is always case sensitive.

    However, is there any way to get the contiguous matching mode that exact provides (i.e. match whole words) while not having to also match the case? In other words, is it possible to set exact mode to case insensitivity, or smart-case?

    For explanation: My use case is full-text searching my notes (with rg) and then searching over the output with skim. Matching the output with the fuzzy matcher mostly shows completely unrelated notes, and exact matching shows the perfect answers except for always having to search for the right case.

    opened by marty-oehme 8
  • [ Fedora ] Error: Unable to find a match: skim

    [ Fedora ] Error: Unable to find a match: skim

    ❯ sudo dnf install skim
    Last metadata expiration check: 4:59:00 ago on Wed 24 Jun 2020 17:13:12 +0530.
    No match for argument: skim
    Error: Unable to find a match: skim
    
    opened by kaushalyap 8
  • [Library] nth option is broken?

    [Library] nth option is broken?

    examples/nth.rs:

    extern crate skim;
    use skim::prelude::*;
    use std::io::Cursor;
    
    pub fn main() {
        let input = "foo 123";
    
        let options = SkimOptionsBuilder::default()
            .nth(Some("2"))
            .query(Some("f"))
            .build()
            .unwrap();
        let item_reader = SkimItemReader::default();
    
        dbg!(options.nth);
    
        let items = item_reader.of_bufread(Cursor::new(input));
        let selected_items = Skim::run_with(&options, Some(items))
            .map(|out| out.selected_items)
            .unwrap_or_else(|| Vec::new());
    
        for item in selected_items.iter() {
            print!("{}{}", item.output(), "\n");
        }
    }
    
    cargo run --example nth
    

    It generates a match foo 123 although it shouldn't match anything (2nd field consists of numbers, we match on a letter). Am I doing anything wrong?

    skim in terminal works as expected

    > echo "foo 123" | sk --nth=1 --filter f
    foo 123
    > echo "foo 123" | sk --nth=2 --filter f
    # no output, exit code 1
    
    opened by murlakatamenka 7
  • skim panic - attempt to unwrap None value

    skim panic - attempt to unwrap None value

    Using a function like this and selecting some process (just tried random until it broke) as skims' selection produces a panic:

    $ fkill
    thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', 27
    
    function fkill -d 'fuzzy kill processes'
      ps -ef | sed 1d | sk --multi
    end
    
    cannot-reproduce 
    opened by bryaan 7
  • Strange characters on first line (fish)

    Strange characters on first line (fish)

    After switching from zsh to fish, I get some strange characters on the first line after invoking sk:

    Screenshot 2019-08-11 at 20 07 44

    Setting/unsetting SKIM_DEFAULT_{COMMAND,OPTS} does not change the behaviour, neither does changing the prompt (my initial suspicion).

    Under zsh, the problem vanishes:

    Screenshot 2019-08-11 at 20 14 17

    opened by muellerj 6
  • Compiling error E0283

    Compiling error E0283

    I was trying to install skim via cargo and the following error occurred.

       Compiling skim v0.6.7
         Running `rustc --edition=2018 --crate-name skim /home/lucius/.cargo/registry/src/github.com-1ecc6299db9ec823/skim-0.6.7/src/lib.rs --color always --crate-type lib --emit=dep-info,link -C opt-level=3 --cfg 'feature="default"' -C metadata=a04a50de2ae59014 -C extra-filename=-a04a50de2ae59014 --out-dir /tmp/cargo-install8CeDWS/release/deps -L dependency=/tmp/cargo-install8CeDWS/release/deps --extern bitflags=/tmp/cargo-install8CeDWS/release/deps/libbitflags-7da479843b005ba4.rlib --extern chrono=/tmp/cargo-install8CeDWS/release/deps/libchrono-cf861bfc2931365a.rlib --extern clap=/tmp/cargo-install8CeDWS/release/deps/libclap-3884add869b87984.rlib --extern derive_builder=/tmp/cargo-install8CeDWS/release/deps/libderive_builder-807bbaf018e8f267.so --extern env_logger=/tmp/cargo-install8CeDWS/release/deps/libenv_logger-4955433a86104d7c.rlib --extern fuzzy_matcher=/tmp/cargo-install8CeDWS/release/deps/libfuzzy_matcher-b9f152d64ff9e136.rlib --extern lazy_static=/tmp/cargo-install8CeDWS/release/deps/liblazy_static-56fd04421d7a44b1.rlib --extern log=/tmp/cargo-install8CeDWS/release/deps/liblog-823d679605fab846.rlib --extern nix=/tmp/cargo-install8CeDWS/release/deps/libnix-a800fcb68f6367fa.rlib --extern rayon=/tmp/cargo-install8CeDWS/release/deps/librayon-367d697d4a5534be.rlib --extern regex=/tmp/cargo-install8CeDWS/release/deps/libregex-d05f5024a307020a.rlib --extern shlex=/tmp/cargo-install8CeDWS/release/deps/libshlex-800fb40da39b7401.rlib --extern time=/tmp/cargo-install8CeDWS/release/deps/libtime-6b14c6221822b10c.rlib --extern timer=/tmp/cargo-install8CeDWS/release/deps/libtimer-b2432a3b9e64419a.rlib --extern tuikit=/tmp/cargo-install8CeDWS/release/deps/libtuikit-d0145bc165de8889.rlib --extern unicode_width=/tmp/cargo-install8CeDWS/release/deps/libunicode_width-138429304f8bb71a.rlib --extern vte=/tmp/cargo-install8CeDWS/release/deps/libvte-c99aeea6a2fee451.rlib --cap-lints allow`
    error[E0283]: type annotations required: cannot resolve `_: std::convert::Into<tuikit::container::Size>`
       --> /home/lucius/.cargo/registry/src/github.com-1ecc6299db9ec823/skim-0.6.7/src/model.rs:567:14
        |
    567 |             .basis(if self.inline_info { 0 } else { 1 }.into())
        |              ^^^^^
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0283`.
    error: failed to compile `skim v0.6.7`, intermediate artifacts can be found at `/tmp/cargo-install8CeDWS`
    
    opened by lebensterben 6
  • Add support for install on armv7 and aarch64

    Add support for install on armv7 and aarch64

    This allows the script to work with Raspbian/Arch/Manjaro running on a Raspberry Pi

    opened by crodjer 1
  • FreeBSD: skim does not render properly

    FreeBSD: skim does not render properly

    Using a fresh install of FreeBSD 13 (minimum install) and skim 0.9.4 via cargo install skim, I get this: grafik

    Same rendering issue via SSH and console.

    opened by Korkman 1
  • Support Wildcards / Chain of Fall Backs for

    Support Wildcards / Chain of Fall Backs for "Smart Search"

    While speaking of future functionality for the rust file manager kamyaa/joshuto the idea of a "smart search" with a "chain of fall backs" was described in this comment here which also refers to an issue in gokechan/lf that describes an fzf implementation:

    gokcehan/lf#69 : maybe an "ultra smart search" could work too (i.e. when there is at least one unescaped wildcard character in the search string, consider it a wildcard search, but if it yields too few results - configurable number try to fill results up to - or if there is no wildcard character, then search as if it was an exact case-sensitive substring search, and if even then there is too few results - still smaller than the configurable number - then try to search with fuzzy search which will consider all characters separately as they all must appear somewhere in the record and in the order given in the search string

    and then this comment makes a good case for smart search being more user friendly in practice:

    it seems to me that skim doesn't support "smart search" (i.e. the "chain of fallbacks" as I outlined above) which forces one to learn and remember to always put the right character in front of the string which is tedious. Or maybe I misread the documentation?

    I also did a quick search and it looks like becheran/wildmatch may be a good choice for implementing the wildcards.

    opened by JacobTravers 0
  • Trying to use the preview.sh and --with-nth but without success

    Trying to use the preview.sh and --with-nth but without success

    With preview.sh I always get the preview-window to show lines starting from line 1 onwards and not from the line number the match is found, loading the whole file in question (showing the first x lines depending how many I have chosen to show in --preview-window.

    sk --ansi -i -c 'rg --color=always --line-number "{}" ~/mnt/b ' --preview "preview.sh {}" --preview-window down:10:wrap --ansi --bind="enter:execute(printf %s {} | awk -F: '{print \"+\"\$2, \$1}' | xargs -o vim )"

    I tried the preview.sh directly too in which case it outputs the whole file or does not work because wrong syntax: preview.sh mnt/b/01_a:100 preview.sh mnt/b/01_a[:100] preview.sh mnt/b/01_a:100:1

    Another thing I have tried to manipulate without success is the order of the output.

    I have tried: sk --with-nth=1{5..} sk --with-nth=N[5..] sk --with-nth={5..} etc.. but it always shows the file path followed by the line number and then the line content.

    Output looks like this:

    > /home/xxx/mnt/b/10_pol:2261:                        F {} "se syötärakka juoksi poikki polven."
      /home/xxx/mnt/b/10_pol:825:                    F {} "pagoh poltau. juoksou poltau."
      /home/xxx/mnt/b/10_pol:807:                    F {} "hebo juostez jallam poltau muadu vaste."
    

    In other words my iq is not high enough to understand without some examples :)

    The files I am using these are dictionary files.

    A snippet from inside such file copy-pasted from terminal output of preview.sh:

    29874 D {'s': '992', 'i': 'alttina'}
    29875     H {}
    29876         He {} "alttina"
    29877         Se {} "alttina"
    29878         P {}
    29879             Pa {'d': 'no', 'f': 's.', 'f': 'noun'}
    29880         G {'d': 'yes'} "s."
    29881         De {} "kolmen kopeekan raha."
    29882         E {}
    29883             Ex {}
    29884                 E. {}
    29885                     F {} "alt́t́ina"
    

    The line numbers are brown in color.

    If I pipe the output to less, it shows color codes. Maybe I have a problem related to ansi causing problems, at least I have this other ansi related problem https://github.com/lotabout/skim/issues/408

    output from preview.sh mnt/b/01_a:100 | less

    ESC[38;5;238m   2ESC[0m ESC[38;5;231m    H {}ESC[0m
    ESC[38;5;238m   3ESC[0m ESC[38;5;231m        He {} "a"ESC[0m
    ESC[38;5;238m   4ESC[0m ESC[38;5;231m        Se {} "a"ESC[0m
    ESC[38;5;238m   5ESC[0m ESC[38;5;231m    S {'s': '1.'}ESC[0m
    

    Then as a bonus I mention that I have one more thing, which I haven't tried to solve very much yet myself, so maybe I could find an answer to it myself but I'm not sure if that's the case. I would want to remove the whitespaces at the begin of lines when the content is shown in skim aswell as in skim's preview-window. Then maybe even strip out line breaks altogether from the preview-window

    opened by khlsvr 0
  • Some keybindings fail when iTerm2 is set to report modifiers with CSI u

    Some keybindings fail when iTerm2 is set to report modifiers with CSI u

    Test: echo 1 | sk --bind 'f1:accept' Versions: iTerm2 3.4.6 skim 0.9.4

    opened by Korkman 0
  • not getting colors with --ansi

    not getting colors with --ansi

    I see that someone https://github.com/lotabout/skim/issues/245 had a problem with colors and tested with the commands below and it was that the newer version had it fixed, but for me I still have the problem. I have 0.9.4 version of sk.

    no colors, just black and white: fd --color always | sk --ansi

    If I run without --ansi I get: ?[38;5;81msanakirja/?[0m?[38;5;81mkks1/?[0m04_ha.xml in the output in skim pager, and pressing enter returns me to cmd prompt with colors shown properly of the selected entry in the prompt.

    colors work normally in fzf: fd --color always | fzf --ansi

    In fzf the no --ansi version works similarly as in sk, showing those color codes and when selecting one I get it colored on cmd prompt.

    I would have a use for skim as a viewer for these dictionary files in xml but the colors are important and they are not working there either: sk --ansi -c 'bat -f /home/xxx/mnt/languages/karjalan_kieli/sanakirja/*/*.xml '

    With grep I get colors though: sk --ansi -i -c 'grep -rI --color=always --line-number "{}" .'

    opened by khlsvr 0
  • Implementation of preview callback

    Implementation of preview callback

    The preview feature of skim is great, however when skim is used as a library, there's no way to render a preview from Rust code.

    This PR adds a new option to SkimOptionsBuilder:

    .preview_fn(| items: Vec<String> | -> Vec<AnsiString<'static>> {})
    

    The closure will be called with the currently selected items to render.

    opened by alexxbb 1
  • remove mention of nightly

    remove mention of nightly

    I've seen after compiling on rust stable 1.51 that skim used to require nightly

    Can we now remove this line ?

    opened by PCouaillier 0
  • update script

    update script

    Dear @lotabout,

    I wanted to add the following script to update the skim binary (say in ~/bin to be run by a cron job) to the wiki but I cannot access this page. Below it is:

    #!/usr/bin/env sh
    
    # debug output and exit on error or use of undeclared variable or pipe error:
    set -o xtrace -o errtrace -o errexit -o nounset -o pipefail
    
    latest_tag="$(curl --location --head https://github.com/lotabout/skim/releases/latest | grep -i location: | sed 's/^.*\/tag\/\([^\/]*\)\r$/\1/')"
    filename="skim-${latest_tag}-x86_64-unknown-linux-gnu.tar.gz"
    uri_to_download="https://github.com/lotabout/skim/releases/download/${latest_tag}/${filename}"
    
    {
    cd "$(mktemp --directory "${TMPDIR:-/tmp}/skim-update.XXXXXXXXXX")"
        curl --fail --show-error --remote-name --location "$uri_to_download"
        tar xf "$filename"
        chmod a+x sk
        cp sk "$HOME/bin"
    }
    
    if [ ! -x "$HOME/bin/sk" ]; then
        echo '"Skim" was not successfully installed!' >&2
        # DISPLAY=:0 notify-send --urgency=critical "Failed updating peco!
          # Run $0 to check."
        exit 2
    fi
    
    opened by Konfekt 0
  • WIP - Pre-select works in single-select mode and moves user selection too

    WIP - Pre-select works in single-select mode and moves user selection too

    This is related to my need here - I want pre-selection to move the actual initial user selector and work also in single mode (without the -m flag).

    At this point it works, even though the code is very hacky - Mainly, I am using the EvHeartBeat event to check whether the cursor can be moved or not yet.

    I would love to hear your feedback:

    1. As a feature - Is it something you'd like to merge into the project?
    2. Do you have a better idea than putting the callback in EvHeartBeat?
    3. What else should be done to merge this feature into skim?
    opened by vitalybe 0
Releases(v0.9.4)
Owner
Jinzhou Zhang
A Program is a Process, Not a Thing
Jinzhou Zhang
Fuzzy Finder in rust!

Life is short, skim! Half of our life is spent on navigation: files, lines, commands… You need skim! It is a general fuzzy finder that saves you time.

Jinzhou Zhang 2.6k Jun 15, 2021
GTK application for browsing and installing fonts from Google's font archive

Font Finder This project is a from-scratch implementation of TypeCatcher in Rust. It is a GTK3 application for browsing through and installing fonts f

Michael Murphy 224 Jun 3, 2021
A simple, fast and user-friendly alternative to 'find'

fd [中文] [한국어] fd is a program to find entries in your filesytem. It is a simple, fast and user-friendly alternative to find. While it does not aim to

David Peter 17.5k Jun 5, 2021
A faster way to navigate your filesystem

zoxide A faster way to navigate your filesystem Table of contents Introduction Examples Getting started Step 1: Install zoxide Step 2: Install fzf (op

Ajeet D'Souza 2.8k Jun 13, 2021
A fast duplicate file finder

The Directory Differential hTool DDH traverses input directories and their subdirectories. It also hashes files as needed and reports findings. The H

Jon Moroney 271 Jun 16, 2021
This project now lives on in a rewrite at https://gitlab.redox-os.org/redox-os/parallel

MIT/Rust Parallel: A Command-line CPU Load Balancer Written in Rust This is an attempt at recreating the functionality of GNU Parallel, a work-stealer

Michael Murphy 1.2k May 8, 2021
A modern replacement for ‘ls’.

exa exa is a modern replacement for ls. README Sections: Options — Installation — Development exa is a modern replacement for the venerable file-listi

Benjamin Sago 13.5k Jun 13, 2021
Cross-platform Rust rewrite of the GNU coreutils

uutils coreutils uutils is an attempt at writing universal (as in cross-platform) CLI utilities in Rust. This repository is intended to aggregate GNU

null 8.5k Jun 14, 2021
🔮 Futuristic take on hexdump, made in Rust.

hex (hx) Futuristic take on hexdump. hx accepts a file path as input and outputs a hexadecimal colorized view to stdout. $ hx tests/files/alphanumeric

Julian Sitkevich 275 Jun 4, 2021
Blazing 💥 fast terminal-ui for git written in rust 🦀

Blazing fast terminal client for git written in Rust Features Fast and intuitive keyboard only control Context based help (no need to memorize tons of

Stephan Dilly 4.8k Jun 13, 2021
🍂 A Rust-based simulated DOM (browser-independent replacement for web_sys)

DOM in Rust without a browser Hello and welcome. This library provides server-side or browserless simulation of a DOM. Example Usage use std::sync::Ar

Philip Peterson 37 May 27, 2021
A simple and fast download accelerator, written in Rust

zou A simple and fast download accelerator, written in Rust Zou is a Snatch fork by @k0pernicus. Snatch is a fast and interruptable download accelerat

Antonin Carette 152 Apr 16, 2021
Count your code, quickly.

Tokei (時計) Tokei is a program that displays statistics about your code. Tokei will show the number of files, total lines within those files and code,

null 5k Jun 17, 2021
Untrusted IPC with maximum performance and minimum latency. On Rust, on Linux.

Untrusted IPC with maximum performance and minimum latency. On Rust, on Linux. When is this Rust crate useful? Performance or latency is crucial, and

null 24 Jun 10, 2021