Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizable Themes #2236

Merged
merged 18 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions crates/atuin-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ sha2 = { version = "0.10", optional = true }
indicatif = "0.17.7"
tiny-bip39 = "1"

# theme
crossterm = "0.27.0"
palette = { version = "0.7.5", features = ["serializing"] }
lazy_static = "1.4.0"
strum_macros = "0.26.3"
strum = { version = "0.26.2", features = ["strum_macros"] }

[dev-dependencies]
tokio = { version = "1", features = ["full"] }
pretty_assertions = { workspace = true }
testing_logger = "0.1.1"
16 changes: 16 additions & 0 deletions crates/atuin-client/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,19 @@ records = true

## The port that should be used for TCP on non unix systems
# tcp_port = 8889

# [theme]
## Color theme to use for rendering in the terminal.
## There are some built-in themes, including the base theme which has the default colors,
## "autumn" and "marine". You can add your own themes to the "./themes" subdirectory of your
## Atuin config (or ATUIN_THEME_DIR, if provided) as TOML files whose keys should be one or
## more of AlertInfo, AlertWarn, AlertError, Annotation, Base, Guidance, Important, and
## the string values as lowercase entries from this list:
## https://ogeon.github.io/docs/palette/master/palette/named/index.html
## If you provide a custom theme file, it should be called "NAME.toml" and the theme below
## should be the stem, i.e. `theme = "NAME"` for your chosen NAME.
# name = "autumn"

## Whether the theme manager should output normal or extra information to help fix themes.
## Boolean, true or false. If unset, left up to the theme manager.
# debug = true
1 change: 1 addition & 0 deletions crates/atuin-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ pub mod record;
pub mod register;
pub mod secrets;
pub mod settings;
pub mod theme;

mod utils;
27 changes: 27 additions & 0 deletions crates/atuin-client/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,18 @@ pub struct Preview {
pub strategy: PreviewStrategy,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Theme {
/// Name of desired theme ("" for base)
pub name: String,

/// Whether any available additional theme debug should be shown
pub debug: Option<bool>,

/// How many levels of parenthood will be traversed if needed
pub max_depth: Option<u8>,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Daemon {
/// Use the daemon to sync
Expand Down Expand Up @@ -366,6 +378,16 @@ impl Default for Preview {
}
}

impl Default for Theme {
fn default() -> Self {
Self {
name: "".to_string(),
debug: None::<bool>,
max_depth: Some(10),
}
}
}

impl Default for Daemon {
fn default() -> Self {
Self {
Expand Down Expand Up @@ -458,6 +480,9 @@ pub struct Settings {

#[serde(default)]
pub daemon: Daemon,

#[serde(default)]
pub theme: Theme,
}

impl Settings {
Expand Down Expand Up @@ -727,6 +752,8 @@ impl Settings {
.set_default("daemon.socket_path", socket_path.to_str())?
.set_default("daemon.systemd_socket", false)?
.set_default("daemon.tcp_port", 8889)?
.set_default("theme.name", "")?
.set_default("theme.debug", None::<bool>)?
.set_default(
"prefers_reduced_motion",
std::env::var("NO_MOTION")
Expand Down
Loading
Loading