diff options
| author | noyez <noyez@ithryn.net> | 2022-05-20 02:36:53 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-20 07:36:53 +0100 |
| commit | e5df809dd29b0fc73cb39b9debd3180b174e6bf5 (patch) | |
| tree | d56885cb7bf11fcede0fcb3278ed5a2780d51f3b /src/command | |
| parent | Improve default fish keybindings (#420) (diff) | |
| download | atuin-e5df809dd29b0fc73cb39b9debd3180b174e6bf5.zip | |
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<u8>` instead of `String`
- Rewriting tests to eliminate depencency on local file system
- Using `Vec<u8>` 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 <b@noyes.dev>
Diffstat (limited to '')
| -rw-r--r-- | src/command/client/import.rs | 20 |
1 files changed, 16 insertions, 4 deletions
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::<Zsh, DB>(db).await + if ZshHistDb::histpath().is_ok() { + println!( + "Detected Zsh-HistDb, using :{}", + ZshHistDb::histpath().unwrap().to_str().unwrap() + ); + import::<ZshHistDb, DB>(db).await + } else { + println!("Detected ZSH"); + import::<Zsh, DB>(db).await + } } else if shell.ends_with("/fish") { println!("Detected Fish"); import::<Fish, DB>(db).await @@ -59,6 +70,7 @@ impl Cmd { } Self::Zsh => import::<Zsh, DB>(db).await, + Self::ZshHistDb => import::<ZshHistDb, DB>(db).await, Self::Bash => import::<Bash, DB>(db).await, Self::Resh => import::<Resh, DB>(db).await, Self::Fish => import::<Fish, DB>(db).await, |
