### Install Skim using Git Source: https://github.com/skim-rs/skim/blob/master/README.md Clones the Skim repository and runs the installation script to set up the `sk` executable in your home directory. ```sh git clone --depth 1 git@github.com:skim-rs/skim.git ~/.skim ~/.skim/install ``` -------------------------------- ### Configure fzf-lua Neovim Plugin for Skim Support Source: https://github.com/skim-rs/skim/blob/master/README.md Instructions for installing and configuring the `fzf-lua` Neovim plugin to enable `skim` as the fuzzy finder, using `lazy.nvim` as an example package manager. This allows Neovim users to leverage skim's capabilities for code navigation. ```lua { "ibhagwan/fzf-lua", -- enable `sk` support instead of the default `fzf` opts = {'skim'} } ``` -------------------------------- ### Install Skim from Crates.io using Cargo Source: https://github.com/skim-rs/skim/blob/master/README.md Installs the `skim` executable directly from the Rust package registry using the Cargo package manager. ```sh cargo install skim ``` -------------------------------- ### Install nu_plugin_skim for Nushell Integration Source: https://github.com/skim-rs/skim/blob/master/README.md Instructions for installing the `nu_plugin_skim` plugin for Nushell, which enhances interaction between `skim` and the Nushell environment. The installation process is demonstrated using the `cargo` package manager. ```nu cargo install nu_plugin_skim plugin add ~/.cargo/bin/nu_plugin_skim ``` -------------------------------- ### Build and Install Skim Manually from Source Source: https://github.com/skim-rs/skim/blob/master/README.md Clones the Skim repository, builds it using Cargo, and compiles the `sk` executable in release mode. The resulting `target/release/sk` executable then needs to be manually added to your system's PATH. ```sh git clone --depth 1 git@github.com:skim-rs/skim.git ~/.skim cd ~/.skim cargo install cargo build --release # Add the resulting `target/release/sk` executable to your PATH ``` -------------------------------- ### Install Skim as Vim Plugin with vim-plug Source: https://github.com/skim-rs/skim/blob/master/README.md Configures vim-plug to install Skim as a Vim/Neovim plugin. This involves cloning the Skim repository into `~/.skim` and executing its installation script. ```vim Plug 'skim-rs/skim', { 'dir': '~/.skim', 'do': './install' } ``` -------------------------------- ### Advanced Skim Color Customization Examples Source: https://github.com/skim-rs/skim/blob/master/README.md Provides advanced examples for customizing `skim`'s color scheme, including combining base themes with specific color overrides and creating high-contrast themes. These examples illustrate the flexibility of skim's color configuration. ```sh sk --color=light,current_bg:24 sk --color=dark,matched:#00FF00,current:#FFFFFF,current_bg:#000080 sk --color=fg:232,bg:255,matched:160,current:255,current_bg:20 ``` -------------------------------- ### Basic Tuikit Terminal UI Application in Rust Source: https://github.com/skim-rs/skim/blob/master/skim-tuikit/README.md This example demonstrates how to create a simple interactive terminal application using Tuikit. It initializes a terminal, prints a message, and allows the user to move text around with arrow keys until 'q' or ESC is pressed. It showcases event polling, screen clearing, printing with attributes, and cursor manipulation. ```rust use skim_tuikit::prelude::*; use std::cmp::{min, max}; fn main() { let term: Term<()> = Term::with_height(TermHeight::Percent(30)).unwrap(); let mut row = 1; let mut col = 0; let _ = term.print(0, 0, "press arrow key to move the text, (q) to quit"); let _ = term.present(); while let Ok(ev) = term.poll_event() { let _ = term.clear(); let _ = term.print(0, 0, "press arrow key to move the text, (q) to quit"); let (width, height) = term.term_size().unwrap(); match ev { Event::Key(Key::ESC) | Event::Key(Key::Char('q')) => break, Event::Key(Key::Up) => row = max(row-1, 1), Event::Key(Key::Down) => row = min(row+1, height-1), Event::Key(Key::Left) => col = max(col, 1)-1, Event::Key(Key::Right) => col = min(col+1, width-1), _ => {} } let attr = Attr{ fg: Color::RED, ..Attr::default() }; let _ = term.print_with_attr(row, col, "Hello World! 你好!今日は。", attr); let _ = term.set_cursor(row, col); let _ = term.present(); } } ``` -------------------------------- ### Basic Skim Library Usage in Rust Source: https://github.com/skim-rs/skim/blob/master/README.md This Rust example demonstrates how to integrate Skim into an application to perform fuzzy finding. It initializes `SkimOptionsBuilder` to configure height and multi-selection, prepares input using `SkimItemReader` from a `Cursor`, runs Skim, and then prints the selected items. It highlights the use of `SkimItemReader` for converting `BufRead` into `SkimItem` streams. ```Rust extern crate skim; use skim::prelude::*; use std::io::Cursor; pub fn main() { let options = SkimOptionsBuilder::default() .height(String::from("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` 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() { println!("{}", item.output()); } } ``` -------------------------------- ### Tuikit Layout Management with HSplit, VSplit, and Win in Rust Source: https://github.com/skim-rs/skim/blob/master/skim-tuikit/README.md This example illustrates how to use Tuikit's layout components (`HSplit`, `VSplit`, `Win`) to organize UI elements. It defines a `Model` that implements `Draw` and `Widget` traits to render text, then arranges multiple instances of this model within a complex horizontal and vertical split structure, demonstrating dynamic layout rendering. ```rust use skim_tuikit::prelude::*; struct Model(String); impl Draw for Model { fn draw(&self, canvas: &mut dyn Canvas) -> DrawResult<()> { let (width, height) = canvas.size()?; let message_width = self.0.len(); let left = (width - message_width) / 2; let top = height / 2; let _ = canvas.print(top, left, &self.0); Ok(()) } } impl Widget for Model{} fn main() { let term: Term<()> = Term::with_height(TermHeight::Percent(50)).unwrap(); let model = Model("middle!".to_string()); while let Ok(ev) = term.poll_event() { if let Event::Key(Key::Char('q')) = ev { break; } let _ = term.print(0, 0, "press 'q' to exit"); let hsplit = HSplit::default() .split( VSplit::default() .basis(Size::Percent(30)) .split(Win::new(&model).border(true).basis(Size::Percent(30))) .split(Win::new(&model).border(true).basis(Size::Percent(30))) ) .split(Win::new(&model).border(true)); let _ = term.draw(&hsplit); let _ = term.present(); } } ``` -------------------------------- ### Apply Built-in Skim Color Schemes Source: https://github.com/skim-rs/skim/blob/master/README.md Examples of applying various built-in color schemes to `skim`, including `dark`, `light`, `16-color`, `black & white`, and `molokai`-inspired themes. These provide quick starting points for customizing skim's appearance. ```sh sk --color=dark sk --color=light sk --color=16 sk --color=bw sk --color=molokai ``` -------------------------------- ### Skim Key Bindings for External Program Execution Source: https://github.com/skim-rs/skim/blob/master/README.md Configures Skim key bindings to execute external programs without leaving the Skim interface. The example shows binding `F1` to open the selected file with `less` and `Ctrl-Y` to copy the selected line to the clipboard using `pbcopy` before aborting Skim. ```sh sk --bind 'f1:execute(less -f {}),ctrl-y:execute-silent(echo {} | pbcopy)+abort' ``` -------------------------------- ### Skim Color Customization Options Reference Source: https://github.com/skim-rs/skim/blob/master/README.md A comprehensive list of UI elements in `skim` that can be customized with specific colors, along with their descriptions and example usage. This table serves as a reference for advanced color scheme configuration. ```APIDOC Element: fg Description: Normal text foreground color Example: --color=fg:232 Element: bg Description: Normal text background color Example: --color=bg:255 Element: matched Description: Matched text in search results Example: --color=matched:108 Element: matched_bg Description: Background of matched text Example: --color=matched_bg:0 Element: current Description: Current line foreground color Example: --color=current:254 Element: current_bg Description: Current line background color Example: --color=current_bg:236 Element: current_match Description: Matched text in current line Example: --color=current_match:151 Element: current_match_bg Description: Background of matched text in current line Example: --color=current_match_bg:236 Element: spinner Description: Progress indicator color Example: --color=spinner:148 Element: info Description: Information line color Example: --color=info:144 Element: prompt Description: Prompt color Example: --color=prompt:110 Element: cursor Description: Cursor color Example: --color=cursor:161 Element: selected Description: Selected item marker color Example: --color=selected:168 Element: header Description: Header text color Example: --color=header:109 Element: border Description: Border color for preview/layout Example: --color=border:59 ``` -------------------------------- ### Save Skim Shell Completions for Automatic Loading Source: https://github.com/skim-rs/skim/blob/master/README.md These commands demonstrate how to save `skim` shell completion scripts to respective configuration files for `bash`, `zsh`, and `fish`. This ensures that completions are automatically loaded every time a new shell session starts, providing persistent `sk` CLI completion. ```sh # 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.fish ``` -------------------------------- ### Set TERMINFO for Display Troubleshooting (Shell) Source: https://github.com/skim-rs/skim/blob/master/README.md This shell command provides a solution for display issues (like no line feed) encountered with Skim on certain environments like Nix, FreeBSD, or Termux. It instructs users to set the `TERMINFO` environment variable to the correct path of their terminfo database, using Termux as a specific example. This helps Skim correctly render its TUI. ```Shell export TERMINFO=/data/data/com.termux/files/usr/share/terminfo ``` -------------------------------- ### Override Skim Default Command for File Listing (Shell) Source: https://github.com/skim-rs/skim/blob/master/README.md This shell command demonstrates how to override Skim's default file listing behavior by setting the `SKIM_DEFAULT_COMMAND` environment variable. It provides an example using `fd`, `git ls-tree`, `rg`, and `find` as fallbacks to generate the input list for Skim. This allows users to customize how files are discovered for fuzzy searching. ```Shell $ SKIM_DEFAULT_COMMAND="fd --type f || git ls-tree -r --name-only HEAD || rg --files || find ." $ sk ``` -------------------------------- ### Skim Search Syntax Tokens and Combinations Source: https://github.com/skim-rs/skim/blob/master/README.md This table outlines the various search syntax tokens supported by `skim`, borrowed from `fzf`. It describes how to perform fuzzy matches, prefix/suffix exact matches, quoted exact matches, and inverse matches, along with how to combine them using `AND` (whitespace) and `OR` (`|`). ```APIDOC Search Syntax Tokens: - `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`) Combinations: - Whitespace: `AND` (e.g., `src main` matches both `src` AND `main`) - ` | `: `OR` (e.g., `.md$ | .markdown$` matches either `.md` OR `.markdown$`). `OR` has higher precedence. ``` -------------------------------- ### Skim Preview Window with ag and Custom Script Source: https://github.com/skim-rs/skim/blob/master/README.md Illustrates how to utilize Skim's preview window feature. It sets up Skim to execute `ag` (The Silver Searcher) in interactive mode and uses an external script (`preview.sh`) to generate and display contextual information for the currently highlighted line in a dedicated preview pane. ```sh sk --ansi -i -c 'ag --color "{}"' --preview "preview.sh {}" ``` -------------------------------- ### Skim Common Key Bindings Source: https://github.com/skim-rs/skim/blob/master/README.md This table lists commonly used key bindings in `skim` for navigation and interaction. It includes actions like accepting selections, aborting operations, moving the cursor, and toggling selections in multi-select mode. ```APIDOC Key Bindings: - 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`) ``` -------------------------------- ### Select Files with Skim and Open in Vim Source: https://github.com/skim-rs/skim/blob/master/README.md This command demonstrates how to use `skim` to interactively select multiple files with a specific extension (e.g., `.rs`) and then open the selected files in Vim. It's a convenient way to quickly manage and edit project files. ```sh vim $(find . -name "*.rs" | sk -m) ``` -------------------------------- ### Integrate Skim with External Search Tools Source: https://github.com/skim-rs/skim/blob/master/README.md `skim` can be used as an interactive interface to dynamically invoke other commands like `grep`, `ack`, `ag`, or `rg` for searching content. The `{}` placeholder is expanded to the current input query, allowing for real-time search results within `skim`. ```sh # 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 "{}"' ``` -------------------------------- ### Customize Skim Key Bindings Source: https://github.com/skim-rs/skim/blob/master/README.md Demonstrates how to specify custom key bindings for `skim` using the `--bind` option, allowing users to define actions for specific key combinations. It also explains how to concatenate multiple actions using the `+` operator. ```sh sk --bind 'alt-a:select-all,alt-d:deselect-all' ``` -------------------------------- ### Generate and Source Skim Shell Completions Directly Source: https://github.com/skim-rs/skim/blob/master/README.md This snippet shows how to generate and directly source `skim` shell completions for `bash`, `zsh`, and `fish` in the current shell session. This enables `sk` CLI usage completions immediately without saving to a file. ```sh # For bash source <(sk --shell bash) # For zsh source <(sk --shell zsh) # For fish sk --shell fish | source ``` -------------------------------- ### Skim Interactive Mode with ripgrep Source: https://github.com/skim-rs/skim/blob/master/README.md Demonstrates how to use Skim in interactive mode (`-i`) to dynamically execute a command (`-c`), in this case, `ripgrep` (`rg`), passing the current query as an argument (`{}`). This allows for dynamic filtering and searching based on user input. ```sh sk --ansi -i -c 'rg --color=always --line-number "{}"' ``` -------------------------------- ### Add Tuikit Dependency to Cargo.toml Source: https://github.com/skim-rs/skim/blob/master/skim-tuikit/README.md To use Tuikit in your Rust project, add `skim-tuikit` as a dependency in your `Cargo.toml` file. This allows Cargo to fetch and compile the library for your application. ```toml [dependencies] skim-tuikit = "*" ``` -------------------------------- ### Skim Color Scheme Command Line Option Format Source: https://github.com/skim-rs/skim/blob/master/README.md Defines the general format for specifying color schemes in `skim` using the `--color` option. This allows for applying a base scheme and then optionally customizing individual UI element colors with ANSI or RGB hex values. ```sh --color=[BASE_SCHEME][,COLOR:ANSI] ``` -------------------------------- ### Add Skim Dependency to Cargo.toml Source: https://github.com/skim-rs/skim/blob/master/README.md This snippet shows how to add the Skim library as a dependency to your Rust project's `Cargo.toml` file. The `*` specifies that any version of Skim is acceptable, allowing Cargo to resolve to the latest compatible version. ```TOML [dependencies] skim = "*" ``` -------------------------------- ### Use Regex Query in Skim Source: https://github.com/skim-rs/skim/blob/master/README.md Configures `skim` to interpret the user's query as a regular expression for matching against the data source. This provides powerful and flexible search capabilities beyond simple substring matching. ```sh sk --regex ``` -------------------------------- ### Skim CLI Exit Codes Reference Source: https://github.com/skim-rs/skim/blob/master/README.md Details the various exit codes returned by the `skim` (sk) command-line tool, indicating the outcome of its execution and providing insights into normal termination, no matches, or user abortion. ```APIDOC Exit Code: 0 Meaning: Exited normally Exit Code: 1 Meaning: No Match found Exit Code: 130 Meaning: Aborted by Ctrl-C/Ctrl-G/ESC/etc... ``` -------------------------------- ### Directly Invoke Skim as a Filter Source: https://github.com/skim-rs/skim/blob/master/README.md Runs the `sk` executable directly without any input, allowing it to act as a general filter or an interactive interface for various tasks. ```bash sk ``` -------------------------------- ### Skim Field-Based Search with Delimiter and Nth Field Source: https://github.com/skim-rs/skim/blob/master/README.md Demonstrates how to configure Skim to perform searches on specific fields of structured input data. By setting a delimiter (`:`) and specifying `--nth 1`, Skim will only consider the first field for matching queries, useful for formats like `filename:line:column`. ```sh sk --delimiter ':' --nth 1 ``` -------------------------------- ### Customize Individual Skim UI Element Colors Source: https://github.com/skim-rs/skim/blob/master/README.md Demonstrates how to customize specific UI elements in `skim` by appending color values (ANSI or RGB hex) to a base scheme. This allows for fine-grained control over the appearance of elements like foreground, background, and current line colors. ```sh sk --color=light,fg:232,bg:255,current_bg:116,info:27 ``` -------------------------------- ### Enable Skim Regular Expression Search Mode Source: https://github.com/skim-rs/skim/blob/master/README.md This command enables the regular expression search mode in `skim`. When activated, `skim` interprets search queries as regular expressions, providing more powerful and flexible pattern matching capabilities. ```sh sk --regex ``` -------------------------------- ### Enable ANSI Color Code Parsing in Skim Source: https://github.com/skim-rs/skim/blob/master/README.md Enables `skim` to parse ANSI color codes (e.g., `\e[32mABC`) present in the input data source. This allows for displaying colored output from external commands or files within skim. ```sh sk --ansi ``` -------------------------------- ### Specify Skim Sort Criteria Source: https://github.com/skim-rs/skim/blob/master/README.md Explains how to customize the sorting order of search results in `skim` using the `--tiebreak` option. Users can define a comma-separated list of sort keys such as `score`, `index`, `begin`, `end`, and `length`, with an optional minus sign for descending order. ```sh sk --tiebreak score,index,-begin ``` -------------------------------- ### Override Skim Default Command in Vim Plugin Source: https://github.com/skim-rs/skim/blob/master/README.md This Vimscript snippet shows how the `SKIM_DEFAULT_COMMAND` environment variable is set within the Skim Vim plugin by default. It explains that this default command, which uses `git ls-tree`, `rg`, `ag`, or `find`, might cause some files not to be shown if they are not recognized by these tools. Users can override this by setting `let $SKIM_DEFAULT_COMMAND = ''` in their Vim configuration. ```Vimscript let $SKIM_DEFAULT_COMMAND = "git ls-tree -r --name-only HEAD || rg --files || ag -l -g \"\" || find ." ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.