From 88633b8994437180afdd66068cc2c8f02aea1db1 Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Mon, 17 Jun 2024 15:36:38 +0100 Subject: feat(gui): automatically install and setup the cli/shell (#2139) * feat(gui): automatically install and setup the cli/shell * add shell config and toasts --- crates/atuin-common/Cargo.toml | 1 + crates/atuin-common/src/shell.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'crates') diff --git a/crates/atuin-common/Cargo.toml b/crates/atuin-common/Cargo.toml index 85e41ef6..5fdcbfa7 100644 --- a/crates/atuin-common/Cargo.toml +++ b/crates/atuin-common/Cargo.toml @@ -22,6 +22,7 @@ eyre = { workspace = true } sqlx = { workspace = true } semver = { workspace = true } thiserror = { workspace = true } +directories = { workspace = true } sysinfo = "0.30.7" lazy_static = "1.4.0" diff --git a/crates/atuin-common/src/shell.rs b/crates/atuin-common/src/shell.rs index afdccea7..80cdc742 100644 --- a/crates/atuin-common/src/shell.rs +++ b/crates/atuin-common/src/shell.rs @@ -59,6 +59,25 @@ impl Shell { Shell::from_string(shell.to_string()) } + pub fn config_file(&self) -> Option { + let mut path = if let Some(base) = directories::BaseDirs::new() { + base.home_dir().to_owned() + } else { + return None; + }; + + // TODO: handle all shells + match self { + Shell::Bash => path.push(".bashrc"), + Shell::Zsh => path.push(".zshrc"), + Shell::Fish => path.push(".config/fish/config.fish"), + + _ => return None, + }; + + Some(path) + } + /// Best-effort attempt to determine the default shell /// This implementation will be different across different platforms /// Caller should ensure to handle Shell::Unknown correctly -- cgit v1.3.1