From 60f4c1d17be03a6fa2a9c1aa1aad1e0c5bcfae08 Mon Sep 17 00:00:00 2001 From: Loric ANDRE Date: Thu, 15 Jan 2026 14:11:53 +0100 Subject: [PATCH] feat: add disabled flag (closes #500) --- man/man1/sk.1 | 5 ++++- shell/completion.bash | 2 +- shell/completion.fish | 1 + shell/completion.zsh | 1 + src/options.rs | 5 +++++ src/tui/app.rs | 11 +++++++++-- tests/options.rs | 10 ++++++++++ 7 files changed, 31 insertions(+), 4 deletions(-) diff --git a/man/man1/sk.1 b/man/man1/sk.1 index b27d30f7..b1b0d7ea 100644 --- a/man/man1/sk.1 +++ b/man/man1/sk.1 @@ -4,7 +4,7 @@ .SH NAME sk \- Fuzzy Finder in rust! .SH SYNOPSIS -\fBsk\fR [\fB\-\-tac\fR] [\fB\-\-min\-query\-length\fR] [\fB\-\-no\-sort\fR] [\fB\-t\fR|\fB\-\-tiebreak\fR] [\fB\-n\fR|\fB\-\-nth\fR] [\fB\-\-with\-nth\fR] [\fB\-d\fR|\fB\-\-delimiter\fR] [\fB\-e\fR|\fB\-\-exact\fR] [\fB\-\-regex\fR] [\fB\-\-algo\fR] [\fB\-\-case\fR] [\fB\-b\fR|\fB\-\-bind\fR] [\fB\-m\fR|\fB\-\-multi\fR] [\fB\-\-no\-multi\fR] [\fB\-\-no\-mouse\fR] [\fB\-c\fR|\fB\-\-cmd\fR] [\fB\-i\fR|\fB\-\-interactive\fR] [\fB\-I \fR] [\fB\-\-color\fR] [\fB\-\-no\-hscroll\fR] [\fB\-\-keep\-right\fR] [\fB\-\-skip\-to\-pattern\fR] [\fB\-\-no\-clear\-if\-empty\fR] [\fB\-\-no\-clear\-start\fR] [\fB\-\-no\-clear\fR] [\fB\-\-show\-cmd\-error\fR] [\fB\-\-cycle\fR] [\fB\-\-layout\fR] [\fB\-\-reverse\fR] [\fB\-\-height\fR] [\fB\-\-no\-height\fR] [\fB\-\-min\-height\fR] [\fB\-\-margin\fR] [\fB\-p\fR|\fB\-\-prompt\fR] [\fB\-\-cmd\-prompt\fR] [\fB\-\-selector\fR] [\fB\-\-multi\-selector\fR] [\fB\-\-ansi\fR] [\fB\-\-tabstop\fR] [\fB\-\-info\fR] [\fB\-\-no\-info\fR] [\fB\-\-inline\-info\fR] [\fB\-\-header\fR] [\fB\-\-header\-lines\fR] [\fB\-\-border\fR] [\fB\-\-history\fR] [\fB\-\-history\-size\fR] [\fB\-\-cmd\-history\fR] [\fB\-\-cmd\-history\-size\fR] [\fB\-\-preview\fR] [\fB\-\-preview\-window\fR] [\fB\-q\fR|\fB\-\-query\fR] [\fB\-\-cmd\-query\fR] [\fB\-\-read0\fR] [\fB\-\-print0\fR] [\fB\-\-print\-query\fR] [\fB\-\-print\-cmd\fR] [\fB\-\-print\-score\fR] [\fB\-1\fR|\fB\-\-select\-1\fR] [\fB\-0\fR|\fB\-\-exit\-0\fR] [\fB\-\-sync\fR] [\fB\-\-pre\-select\-n\fR] [\fB\-\-pre\-select\-pat\fR] [\fB\-\-pre\-select\-items\fR] [\fB\-\-pre\-select\-file\fR] [\fB\-f\fR|\fB\-\-filter\fR] [\fB\-\-shell\fR] [\fB\-\-man\fR] [\fB\-\-tmux\fR] [\fB\-\-log\-file\fR] [\fB\-\-expect\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] +\fBsk\fR [\fB\-\-tac\fR] [\fB\-\-min\-query\-length\fR] [\fB\-\-no\-sort\fR] [\fB\-t\fR|\fB\-\-tiebreak\fR] [\fB\-n\fR|\fB\-\-nth\fR] [\fB\-\-with\-nth\fR] [\fB\-d\fR|\fB\-\-delimiter\fR] [\fB\-e\fR|\fB\-\-exact\fR] [\fB\-\-regex\fR] [\fB\-\-algo\fR] [\fB\-\-case\fR] [\fB\-b\fR|\fB\-\-bind\fR] [\fB\-m\fR|\fB\-\-multi\fR] [\fB\-\-no\-multi\fR] [\fB\-\-no\-mouse\fR] [\fB\-c\fR|\fB\-\-cmd\fR] [\fB\-i\fR|\fB\-\-interactive\fR] [\fB\-I \fR] [\fB\-\-color\fR] [\fB\-\-no\-hscroll\fR] [\fB\-\-keep\-right\fR] [\fB\-\-skip\-to\-pattern\fR] [\fB\-\-no\-clear\-if\-empty\fR] [\fB\-\-no\-clear\-start\fR] [\fB\-\-no\-clear\fR] [\fB\-\-show\-cmd\-error\fR] [\fB\-\-cycle\fR] [\fB\-\-disabled\fR] [\fB\-\-layout\fR] [\fB\-\-reverse\fR] [\fB\-\-height\fR] [\fB\-\-no\-height\fR] [\fB\-\-min\-height\fR] [\fB\-\-margin\fR] [\fB\-p\fR|\fB\-\-prompt\fR] [\fB\-\-cmd\-prompt\fR] [\fB\-\-selector\fR] [\fB\-\-multi\-selector\fR] [\fB\-\-ansi\fR] [\fB\-\-tabstop\fR] [\fB\-\-info\fR] [\fB\-\-no\-info\fR] [\fB\-\-inline\-info\fR] [\fB\-\-header\fR] [\fB\-\-header\-lines\fR] [\fB\-\-border\fR] [\fB\-\-history\fR] [\fB\-\-history\-size\fR] [\fB\-\-cmd\-history\fR] [\fB\-\-cmd\-history\-size\fR] [\fB\-\-preview\fR] [\fB\-\-preview\-window\fR] [\fB\-q\fR|\fB\-\-query\fR] [\fB\-\-cmd\-query\fR] [\fB\-\-read0\fR] [\fB\-\-print0\fR] [\fB\-\-print\-query\fR] [\fB\-\-print\-cmd\fR] [\fB\-\-print\-score\fR] [\fB\-1\fR|\fB\-\-select\-1\fR] [\fB\-0\fR|\fB\-\-exit\-0\fR] [\fB\-\-sync\fR] [\fB\-\-pre\-select\-n\fR] [\fB\-\-pre\-select\-pat\fR] [\fB\-\-pre\-select\-items\fR] [\fB\-\-pre\-select\-file\fR] [\fB\-f\fR|\fB\-\-filter\fR] [\fB\-\-shell\fR] [\fB\-\-man\fR] [\fB\-\-tmux\fR] [\fB\-\-log\-file\fR] [\fB\-\-expect\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] .SH DESCRIPTION sk \- fuzzy finder in Rust .PP @@ -539,6 +539,9 @@ Show error message if command fails .TP \fB\-\-cycle\fR Cycle the results by wrapping around when scrolling +.TP +\fB\-\-disabled\fR +Disable matching entirely .SH LAYOUT .TP \fB\-\-layout\fR \fI\fR [default: default] diff --git a/shell/completion.bash b/shell/completion.bash index 64757864..44d205eb 100644 --- a/shell/completion.bash +++ b/shell/completion.bash @@ -23,7 +23,7 @@ _sk() { case "${cmd}" in sk) - opts="-t -n -d -e -b -m -c -i -I -p -q -1 -0 -f -x -h -V --tac --min-query-length --no-sort --tiebreak --nth --with-nth --delimiter --exact --regex --algo --case --bind --multi --no-multi --no-mouse --cmd --interactive --color --no-hscroll --keep-right --skip-to-pattern --no-clear-if-empty --no-clear-start --no-clear --show-cmd-error --cycle --layout --reverse --height --no-height --min-height --margin --prompt --cmd-prompt --selector --multi-selector --ansi --tabstop --info --no-info --inline-info --header --header-lines --border --history --history-size --cmd-history --cmd-history-size --preview --preview-window --query --cmd-query --read0 --print0 --print-query --print-cmd --print-score --select-1 --exit-0 --sync --pre-select-n --pre-select-pat --pre-select-items --pre-select-file --filter --shell --man --tmux --log-file --extended --literal --hscroll-off --filepath-word --jump-labels --no-bold --pointer --marker --phony --expect --help --version" + opts="-t -n -d -e -b -m -c -i -I -p -q -1 -0 -f -x -h -V --tac --min-query-length --no-sort --tiebreak --nth --with-nth --delimiter --exact --regex --algo --case --bind --multi --no-multi --no-mouse --cmd --interactive --color --no-hscroll --keep-right --skip-to-pattern --no-clear-if-empty --no-clear-start --no-clear --show-cmd-error --cycle --disabled --layout --reverse --height --no-height --min-height --margin --prompt --cmd-prompt --selector --multi-selector --ansi --tabstop --info --no-info --inline-info --header --header-lines --border --history --history-size --cmd-history --cmd-history-size --preview --preview-window --query --cmd-query --read0 --print0 --print-query --print-cmd --print-score --select-1 --exit-0 --sync --pre-select-n --pre-select-pat --pre-select-items --pre-select-file --filter --shell --man --tmux --log-file --extended --literal --hscroll-off --filepath-word --jump-labels --no-bold --pointer --marker --phony --expect --help --version" if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 diff --git a/shell/completion.fish b/shell/completion.fish index 9a548b9d..20c77636 100644 --- a/shell/completion.fish +++ b/shell/completion.fish @@ -77,6 +77,7 @@ complete -c sk -l no-clear-start -d 'Do not clear items on start' complete -c sk -l no-clear -d 'Do not clear screen on exit' complete -c sk -l show-cmd-error -d 'Show error message if command fails' complete -c sk -l cycle -d 'Cycle the results by wrapping around when scrolling' +complete -c sk -l disabled -d 'Disable matching entirely' complete -c sk -l reverse -d 'Shorthand for reverse layout' complete -c sk -l no-height -d 'Disable height (force full screen)' complete -c sk -l ansi -d 'Parse ANSI color codes in input strings' diff --git a/shell/completion.zsh b/shell/completion.zsh index 6cbf4962..5c95ae32 100644 --- a/shell/completion.zsh +++ b/shell/completion.zsh @@ -90,6 +90,7 @@ reverse-list\:"Display from the top of the screen, prompt at the bottom"))' \ '--no-clear[Do not clear screen on exit]' \ '--show-cmd-error[Show error message if command fails]' \ '--cycle[Cycle the results by wrapping around when scrolling]' \ +'--disabled[Disable matching entirely]' \ '--reverse[Shorthand for reverse layout]' \ '--no-height[Disable height (force full screen)]' \ '--ansi[Parse ANSI color codes in input strings]' \ diff --git a/src/options.rs b/src/options.rs index 34d27685..08bc199e 100644 --- a/src/options.rs +++ b/src/options.rs @@ -613,6 +613,10 @@ pub struct SkimOptions { #[cfg_attr(feature = "cli", arg(long, help_heading = "Interface"))] pub cycle: bool, + /// Disable matching entirely + #[cfg_attr(feature = "cli", arg(long, help_heading = "Interface"))] + pub disabled: bool, + // --- Layout --- /// Set layout /// @@ -1041,6 +1045,7 @@ pub struct SkimOptions { impl Default for SkimOptions { fn default() -> Self { Self { + disabled: false, tac: Default::default(), min_query_length: Default::default(), no_sort: Default::default(), diff --git a/src/tui/app.rs b/src/tui/app.rs index e807fd79..a9f9b0bf 100644 --- a/src/tui/app.rs +++ b/src/tui/app.rs @@ -1078,7 +1078,9 @@ impl<'a> App<'a> { pub(crate) fn restart_matcher(&mut self, force: bool) { // Check if query meets minimum length requirement - if let Some(min_length) = self.options.min_query_length { + if let Some(min_length) = self.options.min_query_length + && !self.options.disabled + { let query_to_check = &self.input.value; if query_to_check.chars().count() < min_length { @@ -1105,7 +1107,9 @@ impl<'a> App<'a> { self.status.matcher_running = true; // In interactive mode, use empty query so all items are shown // The input contains the command to execute, not a filter query - let query = if self.options.interactive { + let query = if self.options.disabled { + "" + } else if self.options.interactive { &input::Input::default() } else { &self.input @@ -1163,6 +1167,9 @@ impl<'a> App<'a> { /// Restart matcher with debouncing to avoid excessive restarts during rapid typing fn restart_matcher_debounced(&mut self) { + if self.options.disabled { + return; + } const DEBOUNCE_MS: u64 = 50; let now = std::time::Instant::now(); diff --git a/tests/options.rs b/tests/options.rs index 6dfed90b..0ec5cf1c 100644 --- a/tests/options.rs +++ b/tests/options.rs @@ -667,3 +667,13 @@ sk_test!(opt_cycle_header_lines, "a\\nb\\nc\\nd", &["--cycle", "--header-lines", @capture[5] trim().eq("d"); @capture[3] starts_with("> b"); }); + +sk_test!(opt_disabled, "a\\nb\\nc\\nd", &["--disabled"], { + @capture[0] starts_with(">"); + @capture[1] trim().starts_with("4/4"); + @capture[2] trim().starts_with("> a"); + @keys Key('b'); + @capture[0] starts_with("> b"); + @capture[1] trim().starts_with("4/4"); + @capture[2] trim().starts_with("> a"); +});