1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
commit bd0a387d9a4c6ad2cea1a3270e2897f2b740ece4
Author: Martin Fischer <martin@push-f.com>
Date: Sun Jun 15 08:37:25 2025 +0200
feat: add --blank option
diff --git a/skim/src/model/mod.rs b/skim/src/model/mod.rs
index ff9ec6c..c3d2966 100644
--- a/skim/src/model/mod.rs
+++ b/skim/src/model/mod.rs
@@ -93,6 +93,7 @@ pub struct Model {
info: InfoDisplay,
no_clear_if_empty: bool,
theme: Arc<ColorTheme>,
+ hide_results_for_empty_query: bool,
// timer thread for scheduled events
timer: Timer,
@@ -177,6 +178,7 @@ impl Model {
info: InfoDisplay::Default,
no_clear_if_empty: false,
theme,
+ hide_results_for_empty_query: false,
timer: Timer::new(),
hb_timer_guard: None,
@@ -201,6 +203,7 @@ impl Model {
} else {
options.info.clone()
};
+ self.hide_results_for_empty_query = options.blank;
self.use_regex = options.regex;
@@ -316,7 +319,9 @@ impl Model {
}
};
self.num_options += matched.len();
- self.selection.append_sorted_items(matched);
+ if !self.hide_results_for_empty_query || !self.query.get_query().is_empty() {
+ self.selection.append_sorted_items(matched);
+ }
}
let items_consumed = self.item_pool.num_not_taken() == 0;
diff --git a/skim/src/options.rs b/skim/src/options.rs
index 657130a..b78b3e7 100644
--- a/skim/src/options.rs
+++ b/skim/src/options.rs
@@ -650,6 +650,10 @@ pub struct SkimOptions {
#[arg(long, default_value = "0", help_heading = "Display")]
pub header_lines: usize,
+ /// Don't show results if the query is empty.
+ #[arg(long, help_heading = "Display")]
+ pub blank: bool,
+
// --- History ---
/// History file
///
diff --git a/skim/src/query.rs b/skim/src/query.rs
index 7a09091..9e9ff24 100644
--- a/skim/src/query.rs
+++ b/skim/src/query.rs
@@ -170,7 +170,7 @@ impl Query {
.collect()
}
- fn get_query(&mut self) -> String {
+ pub fn get_query(&mut self) -> String {
match self.mode {
QueryMode::Query => self.get_fz_query(),
QueryMode::Cmd => self.get_cmd_query(),
|