summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyohei Uto <im@kyoheiu.dev>2023-11-01 15:33:34 +0900
committerKyohei Uto <im@kyoheiu.dev>2023-11-01 15:33:34 +0900
commita7ea41a77672c9e24192a82584efa5e32d8f6284 (patch)
treec54f9debe1b2c57ed4eb515c7638aa6b7e94614a
parent23b31c5cd0fa35959b1ca00a6a68ef0d7bb7291e (diff)
Add has_bat and check_bat
-rw-r--r--src/layout.rs1
-rw-r--r--src/state.rs10
2 files changed, 11 insertions, 0 deletions
diff --git a/src/layout.rs b/src/layout.rs
index a1124f4..0552969 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -32,6 +32,7 @@ pub struct Layout {
pub preview_start: (u16, u16),
pub preview_space: (u16, u16),
pub has_chafa: bool,
+ pub has_bat: bool,
pub is_kitty: bool,
}
diff --git a/src/state.rs b/src/state.rs
index e7c757b..bbfd149 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -262,6 +262,7 @@ impl State {
let split = session.split.unwrap_or(Split::Vertical);
+ let has_bat = check_bat();
let has_chafa = check_chafa();
let has_zoxide = check_zoxide();
let is_kitty = check_kitty_support();
@@ -316,6 +317,7 @@ impl State {
Split::Vertical => (0, 0),
Split::Horizontal => (0, 0),
},
+ has_bat,
has_chafa,
is_kitty,
},
@@ -1941,6 +1943,14 @@ fn read_item(entry: fs::DirEntry) -> ItemInfo {
// Ok(result)
// }
+/// Check if bat is installed.
+fn check_bat() -> bool {
+ std::process::Command::new("bat")
+ .arg("--help")
+ .output()
+ .is_ok()
+}
+
/// Check if chafa is installed.
fn check_chafa() -> bool {
std::process::Command::new("chafa")