Giter Site home page Giter Site logo

skim's Introduction

Crates.io Build & Test Packaging status Skim Discord

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
Gentoo Portage emerge --ask app-misc/skim

See repology for a comprehensive overview of package availability.

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.

Troubleshooting

No line feed issues with nix , FreeBSD, termux

If you encounter display issues like:

$ for n in {1..10}; do echo "$n"; done | sk
  0/10 0/0.> 10/10  10  9  8  7  6  5  4  3  2> 1

For example

You need to set TERMINFO or TERMINFO_DIRS to the path to a correct terminfo database path

For example, with termux, you can add in your bashr:

export TERMINFO=/data/data/com.termux/files/usr/share/terminfo

skim's People

Contributors

0xflotus avatar alexreg avatar blindingdark avatar brookst avatar bugabinga avatar eclipseo avatar euank avatar grant0417 avatar ignatenkobrain avatar konfekt avatar leoyvens avatar lhaeger avatar lilydjwg avatar lompik avatar lotabout avatar marcusbuffett avatar marsam avatar mb720 avatar mephistophiles avatar mgttlinger avatar mohamedhayibor avatar n8henrie avatar ngirard avatar pkubik avatar rdeaton avatar remiliaforever avatar sisrfeng avatar td-sky avatar tiziano88 avatar yazgoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

skim's Issues

feature-request: allow all fzf options

It would be great if this was a drop in replacement for fzf, so could do alias fzf=sk and it'd just work.

A way to get closer to that goal would be to allow currently not implemented fzf options and just ignore them.

For example:

sk --select-1                                                                                                                                                                                                         [21:49:38]
error: Found argument '--select-1' which wasn't expected, or isn't valid in this context

USAGE:
    sk [FLAGS] [OPTIONS]

For more information try --help

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

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).

Integration with ripgrep(rg)

Hi,

I'm trying to use skim with https://github.com/BurntSushi/ripgrep instead of Ag.
I've modified the Ag example command to sk --ansi -i -c 'rg "{}"' and the search seems to work.

Though there are a few things that I've noticed, and would be great to have them working.

Line numbers don't show up. Neither when searching nor when then the result is returned.

Let's say we have a folder test with two files a.txt and b.txt. When I start the command above, and type A, the following is shown:

> a.txt:A
  1/1
> A

As you can see there are no line numbers shown. The result returned after pressing Enter is a.txt:A.

When searching for A using the rg command rg A, the returned result is:

a.txt
1:A

Also, if line numbers can be returned, I would also like to integrate this with an editor like Vim. It's possible to call vim with the following parameters vim +{lineNumber} {fileName}.

Is the integration with ripgrep possible with some configs? Or a code change is required?

Interactive mode colors with Ripgrep

It seems colors are not working with rg as they do in ag. Here are some screenshots to illustrate:

Invoked Commands

Appearance in interactive mode

Normal appearance in shell

Here is the ag output from ... | cat -evt

^[[1;32mansi/README.md^[[0m^[[K:^[[1;33m43^[[0m^[[K:  .write('^[[30;43mHello World!^[[0m^[[K') // Write '^[[30;43mHello World!^[[0m^[[K' to stdout$
^[[1;32mbrowserify-transform-tools/README.md^[[0m^[[K:^[[1;33m141^[[0m^[[K:var content = "console.log('^[[30;43mHello World!^[[0m^[[K');";$
^[[1;32mhandlebars/README.markdown^[[0m^[[K:^[[1;33m52^[[0m^[[K:var context = { posts: [{url: "/hello-world", body: "^[[30;43mHello World!^[[0m^[[K"}] };$
^[[1;32mhandlebars/README.markdown^[[0m^[[K:^[[1;33m61^[[0m^[[K://   <li><a href='/hello-world'>^[[30;43mHello World!^[[0m^[[K</a></li>$
^[[1;32mhandlebars/README.markdown^[[0m^[[K:^[[1;33m118^[[0m^[[K:var context = { posts: [{url: "/hello-world", body: "^[[30;43mHello World!^[[0m^[[K"}] };$
^[[1;32mnpm/node_modules/ansi/README.md^[[0m^[[K:^[[1;33m43^[[0m^[[K:  .write('^[[30;43mHello World!^[[0m^[[K') // Write '^[[30;43mHello World!^[[0m^[[K' to stdout$
^[[1;32mplist/README.md^[[0m^[[K:^[[1;33m34^[[0m^[[K:var val = plist.parse('<plist><string>^[[30;43mHello World!^[[0m^[[K</string></plist>');$
^[[1;32mplist/README.md^[[0m^[[K:^[[1;33m35^[[0m^[[K:console.log(val);  // "^[[30;43mHello World!^[[0m^[[K"$
^[[1;32mplist/README.md^[[0m^[[K:^[[1;33m47^[[0m^[[K:  var val = plist.parse('<plist><string>^[[30;43mHello World!^[[0m^[[K</string></plist>');$
^[[1;32mplist/README.md^[[0m^[[K:^[[1;33m48^[[0m^[[K:  console.log(val);  // "^[[30;43mHello World!^[[0m^[[K"$
^[[1;32mplist/README.md^[[0m^[[K:^[[1;33m72^[[0m^[[K:var obj = plist.parse('<plist><string>^[[30;43mHello World!^[[0m^[[K</string></plist>');$
^[[1;32mplist/README.md^[[0m^[[K:^[[1;33m73^[[0m^[[K:console.log(obj);  // ^[[30;43mHello World!^[[0m^[[K$
^[[1;32msimplesmtp/test/client.js^[[0m^[[K:^[[1;33m386^[[0m^[[K:            client.write("From: [email protected]\r\nTo:[email protected]\r\nSubject: test\r\n\r\n^[[30;43mHello World!^[[0m^[[K");$
^[[1;32myamlparser/tests/example.yml^[[0m^[[K:^[[1;33m2^[[0m^[[K:# ^[[30;43mHello World!^[[0m^[[K$

and here is the output for the same with rg:

^[[m^[[35mansi/README.md^[[m:  .write('^[[m^[[31m^[[1mHello World!^[[m') // Write '^[[m^[[31m^[[1mHello World!^[[m' to stdout$
^[[m^[[35mbrowserify-transform-tools/README.md^[[m:var content = "console.log('^[[m^[[31m^[[1mHello World!^[[m');";$
^[[m^[[35mhandlebars/README.markdown^[[m:var context = { posts: [{url: "/hello-world", body: "^[[m^[[31m^[[1mHello World!^[[m"}] };$
^[[m^[[35mhandlebars/README.markdown^[[m://   <li><a href='/hello-world'>^[[m^[[31m^[[1mHello World!^[[m</a></li>$
^[[m^[[35mhandlebars/README.markdown^[[m:var context = { posts: [{url: "/hello-world", body: "^[[m^[[31m^[[1mHello World!^[[m"}] };$
^[[m^[[35mplist/README.md^[[m:var val = plist.parse('<plist><string>^[[m^[[31m^[[1mHello World!^[[m</string></plist>');$
^[[m^[[35mplist/README.md^[[m:console.log(val);  // "^[[m^[[31m^[[1mHello World!^[[m"$
^[[m^[[35mplist/README.md^[[m:  var val = plist.parse('<plist><string>^[[m^[[31m^[[1mHello World!^[[m</string></plist>');$
^[[m^[[35mplist/README.md^[[m:  console.log(val);  // "^[[m^[[31m^[[1mHello World!^[[m"$
^[[m^[[35mplist/README.md^[[m:var obj = plist.parse('<plist><string>^[[m^[[31m^[[1mHello World!^[[m</string></plist>');$
^[[m^[[35mplist/README.md^[[m:console.log(obj);  // ^[[m^[[31m^[[1mHello World!^[[m$
^[[m^[[35msimplesmtp/test/client.js^[[m:            client.write("From: [email protected]\r\nTo:[email protected]\r\nSubject: test\r\n\r\n^[[m^[[31m^[[1mHello World!^[[m");$
^[[m^[[35myamlparser/tests/example.yml^[[m:# ^[[m^[[31m^[[1mHello World!^[[m$
^[[m^[[35mnpm/node_modules/ansi/README.md^[[m:  .write('^[[m^[[31m^[[1mHello World!^[[m') // Write '^[[m^[[31m^[[1mHello World!^[[m' to stdout$

I am using tmux 2.3, with $TERM=screen-256color. Emulator is macOS Sierra Terminal.
rg version 0.4.0
ag version 1.0.2
sk version 0.2.0

Let me know if there is any other useful information I can provide!

Can not paste contents when integrated with tmux

I used in tmux, and type sk for search some file in terminal, I already copied the filename in clipboard.
Then paste it with tmux pasting shortcut, the content is not pasted to sk's input.
I tried fzf, there is no paste problem from tmux.

ANSI color code support

This feature tries to interpret ANSI color codes of the input.

What is ANSI color code
ANSI color code is kind of escape sequence that can be used to control the color of the terminal so that we can print out color text with simple strings. For example: echo -e "\x1B[1;30;47mABC" will print "ABC" as bold, black foreground color, white background color.

Why is it useful
As proposed in #9 , skim tends to serve as an interactive interface for invoking commands such as ag. It would be very helpful to keep the color output for highlighting. That is the original purpose of adding ANSI color support.

Detail of this feature
Interpret the ANSI color codes from the input(e.g. command output) and reflect them in the output.

References

How to pass current line as one argument to the preview command?

Currently the preview command is invoked by a shell, so when I try to preview a command line (from the history) I can't get it to work correctly because there will be single quotes in the line too. I get syntax errors from the shell when I try to preview complex command line.

vim Integration with rg is broken

If a SKIM_DEFAULT_COMMAND is specified, skim breaks after fuzzy selecting a file with:

Too many arguments for function: 9
[Process exited 0]

The interesting part is that the number 9 increases by 2 each time you try to fuzzy open a file, but starts at 9.
I'll take a look later into this if I find time, but any pointers appreciated.

Search syntax doesn't work

Hi,

I just discovered skim on reddit and installed it via homebrew on macos sierra.
I've set SKIM_DEFAULT_COMMAND='rg -l ".*"'
when i execute skim on the command line, typing sk, using ', ^ or other search syntax doesn't work at all (no more matches)
iirc it doesn't work with the default command either.

-c command still running after skim finishes

When running sk --ansi -c 'rg --color=always --line-number "{}"' as suggested in the readme, on directories with lots of files (say one's ~/) the inner command still runs (to completion) after sk has exited.

I am using

~ sk --version
0.1.2
➜  ~ rg --version
ripgrep 0.4.0
➜  ~ zsh --version
zsh 5.2 (x86_64-apple-darwin16.0)

couldn't compile what's wrong?

I just tried to compile this software but failed. What's wrong?

$ rustc -V
rustc 1.14.0 (e8a012324 2016-12-16)
$ cargo -V
cargo 0.15.0-nightly (298a012 2016-12-20)
$ cargo build --release
   Compiling shlex v0.1.1
   Compiling winapi-build v0.1.1
   Compiling getopts v0.2.14
   Compiling lazy_static v0.2.2
   Compiling regex-syntax v0.3.9
   Compiling utf8-ranges v0.1.3
   Compiling kernel32-sys v0.2.2
   Compiling winapi v0.2.8
   Compiling libc v0.2.19
   Compiling gcc v0.3.41
   Compiling memchr v0.1.11
   Compiling aho-corasick v0.5.3
   Compiling thread-id v2.0.0
   Compiling thread_local v0.2.7
   Compiling ncurses v5.85.0
   Compiling regex v0.1.80
   Compiling skim v0.2.1-beta.1 (file:///Users/akira/share/skim)
error[E0554]: #[feature] may not be used on the stable release channel
 --> src/main.rs:1:1
  |
1 | #![feature(io)]
  | ^^^^^^^^^^^^^^^

error: aborting due to previous error

error: Could not compile `skim`.

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?

Change the name of the project

Change the name to skim.

The reason that I want to change the name is:

  1. fzf-rs will be easily confused with fzf which is the Go version.
  2. fzf-rs is hard to type and not beautiful.

As hoodie suggests, skim sounds a great name for me.

Esc key does not work while indexing

With the current built, pressing any abort key (Esc or CTRL-G) while indexing file doesn't work. skim stays open until all files have been indexed after which it closes.
I would expect to be able to close skim while indexing.

It is easy to reproduce this by running sk when in the root of your file system. Then, while indexing (which could take a while on big file systems), pressing Esc doesn't close skim until indexing is done.

Is it possible to fix this issue? I might be able to look into it in the future myself, but I currently don't have much time.

Option to search in the file content?

This is an idea/feature request that might be quite a big in scope.

I wish instead of searching just in the file name, the content would be searched (just like in ag or ack). It is obviously much heavier operation, but for software projects, etc. might be totally feasible.

I wish I could replace ag with skim, since I like the interactive interface better.

On large lists scroll continues beyond keypress

Replicate:

  1. Use git branch --all | sk on a repo with at least 80 branches
  2. Hold up or down arrow to scroll, hold for 2 seconds or more, and release
  3. Observe the selection continues to scroll for another 2-3 seconds

Interestingly, rg --files | sk scrolls fine with more than 500 files.

Anyone else experiencing this? (using fish shell latest version)

Update:
After managing to get the same effect with an rg command I decided it might be related to using powerline/nerdline fonts. It seems the theory holds weight as changing from Hasklig (Nerdline patched) to Meslo (Nerdline patched) solved the problem. However, being that they are both nerdline patched fonts there must be more to this story.

Another Update: what I thought was fixed is actually still broken only occurring less frequently. Haven't determined any further LCD. Maybe long line is the problem?

Passing an initial query using '-q' doesn't work as expected in interactive mode

When running skim in interactive mode and providing an initial query '-q', the query does not show up in the input prompt and the initial query is not provided to the command, but instead is applied using skims fuzzy matching logic.

For example running:

sk -i -q 'test' -c 'ls -la | grep "{}"'

will result in 'test' being fuzzy matched against the results of running the command with empty input:

problem

However, I would expect it to prefill the initial query into the command prompt and have run the initial command with it as input:

expected

Thanks!

Reduce flicker

Don't redraw the screen until you have enough text fo fill it. Otherwise, the terminal flickers when searching large directories (e.g., the rust project).

integration for zsh

it would be great if there was some way easy way to plug skim to the auto-suggestion engine of zsh

Compile on stable

I've noticed a couple of issues about failing to compile already, but I feel it should be possible to compile on stable Rust. I'm not sure what the io feature is (it doesn't seem to be listed in the reference or anywhere my google-fu can reach), so I'm not sure how heavily this project depends upon it, but if there's a way to get around it, it would be great to have binaries built with a stable compiler.

fields should behave the same as fzf/cut

To recreate this bug:

  1. Create a file with some sample input:
    printf "%s\n" /{0..3}/{4..6}/{7..9} > test.txt
  2. See the output of cut, which includes empty fields such as the first one:
$ cut -d/ -f3- test.txt | head -n5
4/7
4/8
4/9
5/7
5/8
  1. Compare the default behavior of fzf and sk in this regard:
unset FZF_DEFAULT_OPTS SKIM_DEFAULT_OPTIONS
fzf -d/ --with-nth=3.. < test.txt
sk -d/ --with-nth=3.. < test.txt

When I do this, I see that fzf behaves the same as cut and sk only shows the last fields.

I feel this should be changed to match people's expectations of what a field is and allow for more seamless interaction with other tools like cut. This is especially so considering that sk and fzf are very similar tools and both use the same option names and semantics for "field expressions". At the very least, this difference should be better documented if for some reason this behavior is intended as a feature and not a bug.

utf8 support

sk --ansi -i -c 'rg -S -n --color=always "{}"'

In the response the utf8 characters aren't showing correctly:

_empty_filter

although after the first character everything look fine:

_empty_filter_one

Building fails

Unfortunately I know nothing about rust. Tried building both with --release and without.

cargo build  --verbose
       Fresh libc v0.2.17
       Fresh regex-syntax v0.3.9
       Fresh lazy_static v0.2.2
       Fresh getopts v0.2.14
       Fresh num_cpus v0.2.13
       Fresh ncurses v5.84.0
       Fresh memchr v0.1.11
       Fresh winapi v0.2.8
       Fresh winapi-build v0.1.1
       Fresh utf8-ranges v0.1.3
       Fresh aho-corasick v0.5.3
       Fresh kernel32-sys v0.2.2
       Fresh thread-id v2.0.0
       Fresh thread_local v0.2.7
       Fresh regex v0.1.80
   Compiling skim v0.1.2 (file:///home/quite/.skim)
     Running `rustc src/main.rs --crate-name sk --crate-type bin -g -C metadata=8c0cfc5409c9b61e --out-dir /home/quite/.skim/target/debug --emit=dep-info,link -L dependency=/home/quite/.skim/target/debug/deps --extern libc=/home/quite/.skim/target/debug/deps/liblibc-ad32fde1bd850538.rlib --extern getopts=/home/quite/.skim/target/debug/deps/libgetopts-33691dbdf8852281.rlib --extern regex=/home/quite/.skim/target/debug/deps/libregex-36c8e259ac5ba542.rlib --extern ncurses=/home/quite/.skim/target/debug/deps/libncurses-40460d940e0412dc.rlib --extern lazy_static=/home/quite/.skim/target/debug/deps/liblazy_static-7f1b96a3a3eb529d.rlib --extern num_cpus=/home/quite/.skim/target/debug/deps/libnum_cpus-9256729e2e3ab66d.rlib --extern skim=/home/quite/.skim/target/debug/deps/libskim.rlib`
error[E0554]: #[feature] may not be used on the stable release channel
 --> src/main.rs:1:1
  |
1 | #![feature(io)]
  | ^^^^^^^^^^^^^^^

Proposal: Delete skim.vim repo and recreate it.

Hi! I'm an enthusiastic fzf user, and so glad to heard that someone reimplemented fzf in Rust!

I recommend you to delete the skim.vim repository and recreate it as a plane repository (not as forked repository) for the sake of SEO. Currently, forked repository is not able to be searched in GitHub.

2017-10-26 10 52 57

I happened for me and ctrlp.vim. As issues, PR, and stars pile up in your repository, this problem becomes increasingly irritating. It's possible to remove the "Forked sign" by contacting the GitHub. But since skim.vim currently has no star, issue, and PR, re-creating the repository is the easiest way to remove that "Forked sign".

Thank you for maintaining Skim!

diff-so-fancy in preview is not rendered properly

I have some commands that preview git diffs trough diff-so-fancy, but they are not rendered properly.

Example command:

fshow () {
	git log --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr% C(auto)%an" "$@" | sk --ansi --reverse --tiebreak=index --no-multi --preview $_viewGitLogLine --header "enter to view, alt-y to copy hash" --bind "enter:execute:$_viewGitLogLine   | less -R" --bind "alt-y:execute:$_gitLogLineToHash | xclip"
}

_viewGitLogLine="echo {} | grep -o '[a-f0-9]\{7\}' | head -1 | xargs -I % sh -c 'git show --color=always %' | diff-so-fancy"

$_gitLogLineToHash="echo {} | grep -o '[a-f0-9]\{7\}' | head -1"

Output with fzf vs with sk:
https://imgur.com/a/CL1XO

Would you be interested in a PR which migrates to clap?

Something I got used to by now is a consistent interface when using a Rust CLI.
In case of skim, it will panic on unknown flags, which like any other panic should probably not happen.

Please let me know in your reply, or close this issue otherwise.
Thanks

edit: realized I was using the old sk binary, which was superseded by sk, which supports --version.

Does not build on arm

The code assumes char is signed.

error[E0308]: mismatched types
   --> src/curses.rs:113:51
    |
113 |         let stdin = unsafe { fdopen(STDIN_FILENO, "r".as_ptr() as *const i8)};
    |                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^ expected u8, found i8
    |
    = help: here are some functions which might fulfill your needs:
            - .offset(...)
            - .wrapping_offset(...)

error[E0308]: mismatched types
   --> src/curses.rs:114:53
    |
114 |         let stderr = unsafe { fdopen(STDERR_FILENO, "w".as_ptr() as *const i8)};
    |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^ expected u8, found i8
    |
    = help: here are some functions which might fulfill your needs:
            - .offset(...)
            - .wrapping_offset(...)

error: aborting due to 2 previous errors

error: Could not compile `skim`.

libskim

Hi,

Thanks for a great tool! I thought about integrating it in another tool (to match files within a UI) and for me having it as a separate crate would be great! I wonder if you have any plans of separating out the code into a separate crate (which you can also use) but other (Rust) projects can depend on.

Toggle between regular expression searching while running

Sometimes I start a search in plain mode and while searching I realize that a regex would be nice. Intuitively I hit ctrl-r expecting this to get me into regex search mode, but apparently this gets me into rotate-mode.

  1. What is rotate-mode? It seems not documented.
  2. Please consider making a mode to switch to regex search.

--print-query doesn't work when aborted

My use case: the user starts searching her command history, but doesn't find what she wants. So she wants to start with the query string instead.

skim doesn't print anything when aborted currently.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.