diff options
| author | Ellie Huxtable <e@elm.sh> | 2021-04-26 11:50:31 +0100 |
|---|---|---|
| committer | Ellie Huxtable <e@elm.sh> | 2021-04-26 11:57:30 +0100 |
| commit | 7b5c3d543d198a18884c990d540f5debc8a4d8d5 (patch) | |
| tree | ffc6b9121f1b1299f1b30a26322e1988683c06c7 /src/command/init.rs | |
| parent | Revert to storing history as nanos (diff) | |
| download | atuin-7b5c3d543d198a18884c990d540f5debc8a4d8d5.zip | |
Support bash, resolves #3
Diffstat (limited to '')
| -rw-r--r-- | src/command/init.rs | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/command/init.rs b/src/command/init.rs index 022021d0..ed1555a9 100644 --- a/src/command/init.rs +++ b/src/command/init.rs @@ -1,19 +1,32 @@ use std::env; use eyre::{eyre, Result}; +use structopt::StructOpt; + +#[derive(StructOpt)] +pub enum Cmd { + #[structopt(about = "zsh setup")] + Zsh, + #[structopt(about = "bash setup")] + Bash, +} fn init_zsh() { let full = include_str!("../shell/atuin.zsh"); println!("{}", full); } -pub fn init() -> Result<()> { - let shell = env::var("SHELL")?; +fn init_bash() { + let full = include_str!("../shell/atuin.bash"); + println!("{}", full); +} - if shell.ends_with("zsh") { - init_zsh(); +impl Cmd { + pub fn run(&self) -> Result<()> { + match self { + Self::Zsh => init_zsh(), + Self::Bash => init_bash(), + } Ok(()) - } else { - Err(eyre!("Could not detect shell, or shell unsupported")) } } |
