aboutsummaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
Diffstat (limited to 'src/command')
-rw-r--r--src/command/history.rs6
-rw-r--r--src/command/init.rs19
-rw-r--r--src/command/mod.rs5
3 files changed, 27 insertions, 3 deletions
diff --git a/src/command/history.rs b/src/command/history.rs
index 09dd4364..bd440163 100644
--- a/src/command/history.rs
+++ b/src/command/history.rs
@@ -30,7 +30,7 @@ pub enum Cmd {
)]
List {
#[structopt(long, short)]
- dir: bool,
+ cwd: bool,
#[structopt(long, short)]
session: bool,
@@ -77,13 +77,13 @@ impl Cmd {
Ok(())
}
- Self::List { session, dir, .. } => {
+ Self::List { session, cwd, .. } => {
const QUERY_SESSION: &str = "select * from history where session = ?;";
const QUERY_DIR: &str = "select * from history where cwd = ?;";
const QUERY_SESSION_DIR: &str =
"select * from history where cwd = ?1 and session = ?2;";
- let params = (session, dir);
+ let params = (session, cwd);
let cwd = env::current_dir()?.display().to_string();
let session = env::var("ATUIN_SESSION")?;
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"))
+ }
+}
diff --git a/src/command/mod.rs b/src/command/mod.rs
index 78e55a0d..0952540b 100644
--- a/src/command/mod.rs
+++ b/src/command/mod.rs
@@ -6,6 +6,7 @@ use crate::local::database::Database;
mod history;
mod import;
+mod init;
mod server;
mod stats;
@@ -26,6 +27,9 @@ pub enum AtuinCmd {
#[structopt(about = "calculate statistics for your history")]
Stats(stats::Cmd),
+ #[structopt(about = "output shell setup")]
+ Init,
+
#[structopt(about = "generates a UUID")]
Uuid,
}
@@ -41,6 +45,7 @@ impl AtuinCmd {
Self::Import(import) => import.run(db),
Self::Server(server) => server.run(),
Self::Stats(stats) => stats.run(db),
+ Self::Init => init::init(),
Self::Uuid => {
println!("{}", uuid_v4());