aboutsummaryrefslogtreecommitdiffstats
path: root/crates/atuin-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/atuin-common/src')
-rw-r--r--crates/atuin-common/src/shell.rs6
-rw-r--r--crates/atuin-common/src/utils.rs20
2 files changed, 6 insertions, 20 deletions
diff --git a/crates/atuin-common/src/shell.rs b/crates/atuin-common/src/shell.rs
index 995c7bcb..7f9a7b8f 100644
--- a/crates/atuin-common/src/shell.rs
+++ b/crates/atuin-common/src/shell.rs
@@ -62,6 +62,12 @@ impl Shell {
Shell::from_string(shell.to_string())
}
+ pub fn from_env() -> Shell {
+ std::env::var("ATUIN_SHELL").map_or(Shell::Unknown, |shell| {
+ Shell::from_string(shell.trim().to_lowercase())
+ })
+ }
+
pub fn config_file(&self) -> Option<std::path::PathBuf> {
let mut path = if let Some(base) = directories::BaseDirs::new() {
base.home_dir().to_owned()
diff --git a/crates/atuin-common/src/utils.rs b/crates/atuin-common/src/utils.rs
index 056412dd..9f7d99c6 100644
--- a/crates/atuin-common/src/utils.rs
+++ b/crates/atuin-common/src/utils.rs
@@ -118,26 +118,6 @@ pub fn broken_symlink<P: Into<PathBuf>>(path: P) -> bool {
path.is_symlink() && !path.exists()
}
-pub fn is_zsh() -> bool {
- // only set on zsh
- env::var("ATUIN_SHELL_ZSH").is_ok()
-}
-
-pub fn is_fish() -> bool {
- // only set on fish
- env::var("ATUIN_SHELL_FISH").is_ok()
-}
-
-pub fn is_bash() -> bool {
- // only set on bash
- env::var("ATUIN_SHELL_BASH").is_ok()
-}
-
-pub fn is_xonsh() -> bool {
- // only set on xonsh
- env::var("ATUIN_SHELL_XONSH").is_ok()
-}
-
/// Extension trait for anything that can behave like a string to make it easy to escape control
/// characters.
///