diff options
| author | Conrad Ludgate <conradludgate@gmail.com> | 2021-12-11 09:48:53 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-11 09:48:53 +0000 |
| commit | 87df7d80eca0ede9e149d1ef533e71650e4b919a (patch) | |
| tree | 389e2c5b32208a8a05259d308af857f7a61cb7f9 /src | |
| parent | Bump serde_json from 1.0.64 to 1.0.72 (#219) (diff) | |
| download | atuin-87df7d80eca0ede9e149d1ef533e71650e4b919a.zip | |
Fish importing (#234)
* make a start on fish
* fix
* test
* enable fish
* fmt
* update histpath
set up fish init script
* update readme
* cover edge case
* fmt
* fix session variables
Co-authored-by: PJ <me@panekj.dev>
* respect NOBIND
Co-authored-by: PJ <me@panekj.dev>
* fix env var setting
Co-authored-by: PJ <me@panekj.dev>
* fix whitespace
Co-authored-by: PJ <me@panekj.dev>
* add fish to supported shells
Co-authored-by: PJ <me@panekj.dev>
Diffstat (limited to 'src')
| -rw-r--r-- | src/command/import.rs | 11 | ||||
| -rw-r--r-- | src/command/init.rs | 8 | ||||
| -rw-r--r-- | src/shell/atuin.fish | 28 |
3 files changed, 47 insertions, 0 deletions
diff --git a/src/command/import.rs b/src/command/import.rs index 53940abb..166fcd3e 100644 --- a/src/command/import.rs +++ b/src/command/import.rs @@ -1,5 +1,6 @@ use std::{env, path::PathBuf}; +use atuin_client::import::fish::Fish; use eyre::{eyre, Result}; use structopt::StructOpt; @@ -33,6 +34,12 @@ pub enum Cmd { aliases=&["r", "re", "res"], )] Resh, + + #[structopt( + about="import history from the fish history file", + aliases=&["f", "fi", "fis"], + )] + Fish, } const BATCH_SIZE: usize = 100; @@ -54,6 +61,9 @@ impl Cmd { if shell.ends_with("/zsh") { println!("Detected ZSH"); import::<Zsh<_>, _>(db, BATCH_SIZE).await + } else if shell.ends_with("/fish") { + println!("Detected Fish"); + import::<Fish<_>, _>(db, BATCH_SIZE).await } else { println!("cannot import {} history", shell); Ok(()) @@ -63,6 +73,7 @@ impl Cmd { Self::Zsh => import::<Zsh<_>, _>(db, BATCH_SIZE).await, Self::Bash => import::<Bash<_>, _>(db, BATCH_SIZE).await, Self::Resh => import::<Resh, _>(db, BATCH_SIZE).await, + Self::Fish => import::<Fish<_>, _>(db, BATCH_SIZE).await, } } } diff --git a/src/command/init.rs b/src/command/init.rs index b6fbe4b3..5d3ffed2 100644 --- a/src/command/init.rs +++ b/src/command/init.rs @@ -6,6 +6,8 @@ pub enum Cmd { Zsh, #[structopt(about = "bash setup")] Bash, + #[structopt(about = "fish setup")] + Fish, } fn init_zsh() { @@ -18,11 +20,17 @@ fn init_bash() { println!("{}", full); } +fn init_fish() { + let full = include_str!("../shell/atuin.fish"); + println!("{}", full); +} + impl Cmd { pub fn run(&self) { match self { Self::Zsh => init_zsh(), Self::Bash => init_bash(), + Self::Fish => init_fish(), } } } diff --git a/src/shell/atuin.fish b/src/shell/atuin.fish new file mode 100644 index 00000000..5d59d01d --- /dev/null +++ b/src/shell/atuin.fish @@ -0,0 +1,28 @@ + +set -gx ATUIN_SESSION (atuin uuid) +set -gx ATUIN_HISTORY (atuin history list) + +function _atuin_preexec --on-event fish_preexec + set -gx ATUIN_HISTORY_ID (atuin history start "$argv[1]") +end + +function _atuin_postexec --on-event fish_postexec + set s $status + if test -n "$ATUIN_HISTORY_ID" + RUST_LOG=error atuin history end $ATUIN_HISTORY_ID --exit $s &; disown + end +end + +function _atuin_search + set h (RUST_LOG=error atuin search -i (commandline -b) 3>&1 1>&2 2>&3) + commandline -f repaint + if test -n "$h" + commandline -r $h + end +end + +if test -z $ATUIN_NOBIND + bind -k up '_atuin_search' + bind \eOA '_atuin_search' + bind \e\[A '_atuin_search' +end |
