Skip to content

Commit

Permalink
feat: Auto-detect Kitty terminals
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Aug 2, 2024
1 parent dc4f527 commit 8ef04b1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use ratatui::{
#[command(version)]
struct Args {
/// Image protocol to render graph
#[arg(short, long, value_name = "TYPE", default_value = "iterm")]
#[arg(short, long, value_name = "TYPE", default_value = "auto")]
protocol: ImageProtocolType,

/// Commit ordering algorithm
Expand All @@ -47,19 +47,29 @@ struct Args {

#[derive(Debug, Clone, ValueEnum)]
enum ImageProtocolType {
Auto;
Iterm,
Kitty,
}

impl From<ImageProtocolType> for protocol::ImageProtocol {
fn from(protocol: ImageProtocolType) -> Self {
match protocol {
ImageProtocolType::Auto => protocol::ImageProtocol::Iterm2,
ImageProtocolType::Iterm => protocol::ImageProtocol::Iterm2,
ImageProtocolType::Kitty => protocol::ImageProtocol::Kitty,
}
}
}

fn detect_kitty_else_iterm () -> protcol::ImageProtocol {
if Ok() = env::var('KITTY_WINDOW_ID') {
protocol::ImageProtocol::Kitty
} else {
protocol::ImageProtocol::Iterm2
}
}

#[derive(Debug, Clone, ValueEnum)]
enum CommitOrderType {
Chrono,
Expand Down

0 comments on commit 8ef04b1

Please sign in to comment.