diff options
| author | Ellie Huxtable <ellie@elliehuxtable.com> | 2024-06-17 15:36:38 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-17 15:36:38 +0100 |
| commit | 88633b8994437180afdd66068cc2c8f02aea1db1 (patch) | |
| tree | 6df7ead44d8cb3c219dd43d0ee86256f4a6025ef /crates/atuin-common/src/shell.rs | |
| parent | chore(deps): bump lucide-react from 0.394.0 to 0.395.0 in /ui (#2148) (diff) | |
| download | atuin-88633b8994437180afdd66068cc2c8f02aea1db1.zip | |
feat(gui): automatically install and setup the cli/shell (#2139)
* feat(gui): automatically install and setup the cli/shell
* add shell config and toasts
Diffstat (limited to 'crates/atuin-common/src/shell.rs')
| -rw-r--r-- | crates/atuin-common/src/shell.rs | 19 |
1 files changed, 19 insertions, 0 deletions
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<std::path::PathBuf> { + 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 |
