From 41f072a8b443b5a404916598f0c9b7a52f5c05fb Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Mon, 15 Feb 2021 23:33:30 +0000 Subject: Add init command (#12) * Add init command This makes setting up the shell part of A'tuin much easier. Eval the output of "atuin init". * Update readme, add up binding --- src/command/init.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/command/init.rs (limited to 'src/command/init.rs') diff --git a/src/command/init.rs b/src/command/init.rs new file mode 100644 index 00000000..022021d0 --- /dev/null +++ b/src/command/init.rs @@ -0,0 +1,19 @@ +use std::env; + +use eyre::{eyre, Result}; + +fn init_zsh() { + let full = include_str!("../shell/atuin.zsh"); + println!("{}", full); +} + +pub fn init() -> Result<()> { + let shell = env::var("SHELL")?; + + if shell.ends_with("zsh") { + init_zsh(); + Ok(()) + } else { + Err(eyre!("Could not detect shell, or shell unsupported")) + } +} -- cgit v1.3.1