diff options
author | Ellie Huxtable <e@elm.sh> | 2021-02-13 20:54:35 +0000 |
---|---|---|
committer | Ellie Huxtable <e@elm.sh> | 2021-02-13 20:55:06 +0000 |
commit | fbaeedbba441a89be7778be5cffa89a421007d17 (patch) | |
tree | 125bb90ef0452005d4c5690e1d9f3bddb34025cb | |
parent | ccdaa21fc6471faaf6def79f9ad7a80a5993dc13 (diff) |
Minor fixes
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | README.md | 48 | ||||
-rw-r--r-- | src/command/import.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 7 |
5 files changed, 58 insertions, 3 deletions
diff --git a/Cargo.lock b/Cargo.lock index bd8b36090..fbf0360bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "atuin" -version = "0.2.1" +version = "0.2.2" dependencies = [ "chrono", "directories", diff --git a/Cargo.toml b/Cargo.toml index c4b67a8cf..f3f71cdf9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "atuin" -version = "0.2.1" +version = "0.2.2" authors = ["Ellie Huxtable <e@elm.sh>"] edition = "2018" license = "MIT" @@ -17,3 +17,51 @@ As well as the expected command, this stores - hostname - time - a unique session ID + +## Install + +`atuin` needs a recent version of Rust + Cargo! It's best to use rustup for. + +``` +cargo install atuin +``` + +and then add this to your ~/.zshrc + +``` +export ATUIN_SESSION=$(atuin uuid) + +_atuin_preexec(){ + id=$(atuin history start $1) + export ATUIN_HISTORY_ID="$id" +} + +_atuin_precmd(){ + local EXIT="$?" + + [[ -z "${ATUIN_HISTORY_ID}" ]] && return + + atuin history end $ATUIN_HISTORY_ID --exit $EXIT +} + +add-zsh-hook preexec _atuin_preexec +add-zsh-hook precmd _atuin_precmd +``` + +We're not replacing anything here, so your default shell history file will still +be written to! + +## Usage + +### Import history + +``` +atuin import auto # detect shell, then import +atuin import zsh # specify shell +``` + +### List history + +``` +atuin history list +``` diff --git a/src/command/import.rs b/src/command/import.rs index 5ce0e7493..a593ef615 100644 --- a/src/command/import.rs +++ b/src/command/import.rs @@ -112,7 +112,7 @@ impl ImportCmd { } } - ImportCmd::Zsh => Ok(()), + ImportCmd::Zsh => self.import_zsh(db), } } } diff --git a/src/main.rs b/src/main.rs index 22c8b21df..86540a97a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use std::env; use std::path::PathBuf; use directories::ProjectDirs; @@ -84,5 +85,11 @@ impl Atuin { fn main() -> Result<()> { pretty_env_logger::init(); + let session = env::var("ATUIN_SESSION"); + + if session.is_err() { + panic!("Please follow the atuin setup! Missing session.") + } + Atuin::from_args().run() } |