aboutsummaryrefslogtreecommitdiffstats
path: root/src/command/init.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/command/init.rs')
-rw-r--r--src/command/init.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/command/init.rs b/src/command/init.rs
index 585a8281..7cb4b35e 100644
--- a/src/command/init.rs
+++ b/src/command/init.rs
@@ -21,6 +21,8 @@ pub enum Shell {
Bash,
/// Fish setup
Fish,
+ /// Nu setup
+ Nu,
}
impl Cmd {
@@ -90,11 +92,53 @@ bind -M insert \e\[A _atuin_bind_up";
println!("end");
}
}
+
+ fn init_nu(&self) {
+ let full = include_str!("../shell/atuin.nu");
+ println!("{full}");
+
+ if std::env::var("ATUIN_NOBIND").is_err() {
+ const BIND_CTRL_R: &str = r#"let-env config = (
+ $env.config | upsert keybindings (
+ $env.config.keybindings
+ | append {
+ name: atuin
+ modifier: control
+ keycode: char_r
+ mode: emacs
+ event: { send: executehostcommand cmd: (_atuin_search_cmd) }
+ }
+ )
+)
+"#;
+ const BIND_UP_ARROW: &str = r#"let-env config = (
+ $env.config | upsert keybindings (
+ $env.config.keybindings
+ | append {
+ name: atuin
+ modifier: none
+ keycode: up
+ mode: emacs
+ event: { send: executehostcommand cmd: (_atuin_search_cmd '--shell-up-key-binding') }
+ }
+ )
+)
+"#;
+ if !self.disable_ctrl_r {
+ println!("{BIND_CTRL_R}");
+ }
+ if !self.disable_up_arrow {
+ println!("{BIND_UP_ARROW}");
+ }
+ }
+ }
+
pub fn run(self) {
match self.shell {
Shell::Zsh => self.init_zsh(),
Shell::Bash => self.init_bash(),
Shell::Fish => self.init_fish(),
+ Shell::Nu => self.init_nu(),
}
}
}