summaryrefslogtreecommitdiffstats
path: root/atuin/src/command/init.rs
diff options
context:
space:
mode:
authorMatthieu LAURENT <matthieu.laurent69@protonmail.com>2024-01-29 13:17:36 +0100
committerGitHub <noreply@github.com>2024-01-29 12:17:36 +0000
commitc56f8ff736b8369b9b5cb3bdb42718396247f212 (patch)
tree264200175dab82272878a135d9e7f31b02f65067 /atuin/src/command/init.rs
parent0faf414cd958137ac60a1f37288994f3a1441780 (diff)
Add xonsh support (#1375)
* Add basic xonsh support * Add init xonsh command * Add Xonsh install instructions in docs * Add xonsh ctrl-R search * update xonsh script and instructions Summary of changes: * Added duration to postcommand hook * Switched main search operation to use `subproccess.run()` rather than running as an xonsh shell command - this a) allows us to capture stderr without needing a temporary file and b) avoids a weird broken-buffer state that results from running a fullscreen TUI and then programmatically editing the buffer * Added support for immediately executing chosen command via `__atuin_accept__:` (like bash/zsh/fish) * strip newline from command before sending to atuin * Add basic xonsh support * Add init xonsh command * Add xonsh ctrl-R search * Remove advanced-install guide (was accidentally re-added during rebase) * Clean up Xonsh doesn't import private functions into the local namespace when sourcing a file * Add xonsh ro readme * Respect ATUIN_NOBIND * Format with black, and improve PEP8 compliance * Add up search * Format rust code --------- Co-authored-by: Joseph Montanaro <jfmonty2@gmail.com>
Diffstat (limited to 'atuin/src/command/init.rs')
-rw-r--r--atuin/src/command/init.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/atuin/src/command/init.rs b/atuin/src/command/init.rs
index eb841c9f..3eb50d68 100644
--- a/atuin/src/command/init.rs
+++ b/atuin/src/command/init.rs
@@ -23,6 +23,8 @@ pub enum Shell {
Fish,
/// Nu setup
Nu,
+ /// Xonsh setup
+ Xonsh,
}
impl Cmd {
@@ -140,12 +142,31 @@ bind -M insert \e\[A _atuin_bind_up";
}
}
+ fn init_xonsh(&self) {
+ let base = include_str!("../shell/atuin.xsh");
+ let (bind_ctrl_r, bind_up_arrow) = if std::env::var("ATUIN_NOBIND").is_ok() {
+ (false, false)
+ } else {
+ (!self.disable_ctrl_r, !self.disable_up_arrow)
+ };
+ println!(
+ "_ATUIN_BIND_CTRL_R={}",
+ if bind_ctrl_r { "True" } else { "False" }
+ );
+ println!(
+ "_ATUIN_BIND_UP_ARROW={}",
+ if bind_up_arrow { "True" } else { "False" }
+ );
+ println!("{base}");
+ }
+
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(),
+ Shell::Xonsh => self.init_xonsh(),
}
}
}