From e5df809dd29b0fc73cb39b9debd3180b174e6bf5 Mon Sep 17 00:00:00 2001 From: noyez Date: Fri, 20 May 2022 02:36:53 -0400 Subject: Noyez zsh histdb import (#393) * Attempting to implement zsh-histdb import Import compiles passes tests, but doesn't run b/c of async runtime. zsh-histdb uses sqlite, and sqlx-rs is async, but import code is sync. * More working on importing histdb * Rewriting tests and using `Vec` instead of `String` - Rewriting tests to eliminate depencency on local file system - Using `Vec` for command strings instead of `String` to eliminate the utf8 errors i was seeing previously. Seems to be working. * Running fmt Co-authored-by: Bradley Noyes --- src/command/client/import.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/command/client/import.rs b/src/command/client/import.rs index 580e4b0e..60fd536d 100644 --- a/src/command/client/import.rs +++ b/src/command/client/import.rs @@ -8,7 +8,9 @@ use indicatif::ProgressBar; use atuin_client::{ database::Database, history::History, - import::{bash::Bash, fish::Fish, resh::Resh, zsh::Zsh, Importer, Loader}, + import::{ + bash::Bash, fish::Fish, resh::Resh, zsh::Zsh, zsh_histdb::ZshHistDb, Importer, Loader, + }, }; #[derive(Parser)] @@ -19,6 +21,8 @@ pub enum Cmd { /// Import history from the zsh history file Zsh, + /// Import history from the zsh history file + ZshHistDb, /// Import history from the bash history file Bash, /// Import history from the resh history file @@ -42,10 +46,17 @@ impl Cmd { match self { Self::Auto => { let shell = env::var("SHELL").unwrap_or_else(|_| String::from("NO_SHELL")); - if shell.ends_with("/zsh") { - println!("Detected ZSH"); - import::(db).await + if ZshHistDb::histpath().is_ok() { + println!( + "Detected Zsh-HistDb, using :{}", + ZshHistDb::histpath().unwrap().to_str().unwrap() + ); + import::(db).await + } else { + println!("Detected ZSH"); + import::(db).await + } } else if shell.ends_with("/fish") { println!("Detected Fish"); import::(db).await @@ -59,6 +70,7 @@ impl Cmd { } Self::Zsh => import::(db).await, + Self::ZshHistDb => import::(db).await, Self::Bash => import::(db).await, Self::Resh => import::(db).await, Self::Fish => import::(db).await, -- cgit v1.3.1