aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/command/client/init.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/turtle/src/command/client/init.rs')
-rw-r--r--crates/turtle/src/command/client/init.rs129
1 files changed, 0 insertions, 129 deletions
diff --git a/crates/turtle/src/command/client/init.rs b/crates/turtle/src/command/client/init.rs
deleted file mode 100644
index 0db9b143..00000000
--- a/crates/turtle/src/command/client/init.rs
+++ /dev/null
@@ -1,129 +0,0 @@
-use crate::atuin_client::settings::Settings;
-use clap::{Parser, ValueEnum};
-
-mod bash;
-mod fish;
-mod powershell;
-mod xonsh;
-mod zsh;
-
-#[derive(Parser, Debug)]
-pub(crate) struct Cmd {
- shell: Shell,
-
- /// Disable the binding of CTRL-R to atuin
- #[clap(long)]
- disable_ctrl_r: bool,
-
- /// Disable the binding of the Up Arrow key to atuin
- #[clap(long)]
- disable_up_arrow: bool,
-
- /// Disable the binding of ? to Atuin AI
- #[clap(long)]
- disable_ai: bool,
-}
-
-#[derive(Clone, Copy, ValueEnum, Debug)]
-#[value(rename_all = "lower")]
-#[expect(clippy::enum_variant_names)]
-pub(crate) enum Shell {
- /// Zsh setup
- Zsh,
-
- /// Bash setup
- Bash,
-
- /// Fish setup
- Fish,
-
- /// Nu setup
- Nu,
-
- /// Xonsh setup
- Xonsh,
-
- /// PowerShell setup
- PowerShell,
-}
-
-impl Cmd {
- 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"$env.config = (
- $env.config | upsert keybindings (
- $env.config.keybindings
- | append {
- name: atuin
- modifier: control
- keycode: char_r
- mode: [emacs, vi_normal, vi_insert]
- event: { send: executehostcommand cmd: (_atuin_search_cmd) }
- }
- )
-)";
- const BIND_UP_ARROW: &str = r"
-$env.config = (
- $env.config | upsert keybindings (
- $env.config.keybindings
- | append {
- name: atuin
- modifier: none
- keycode: up
- mode: [emacs, vi_normal, vi_insert]
- event: {
- until: [
- {send: menuup}
- {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}");
- }
- }
- }
-
- fn static_init(&self) {
- match self.shell {
- Shell::Zsh => {
- zsh::init_static(self.disable_up_arrow, self.disable_ctrl_r);
- }
- Shell::Bash => {
- bash::init_static(self.disable_up_arrow, self.disable_ctrl_r);
- }
- Shell::Fish => {
- fish::init_static(self.disable_up_arrow, self.disable_ctrl_r);
- }
- Shell::Nu => {
- self.init_nu();
- }
- Shell::Xonsh => {
- xonsh::init_static(self.disable_up_arrow, self.disable_ctrl_r);
- }
- Shell::PowerShell => {
- powershell::init_static(self.disable_up_arrow, self.disable_ctrl_r);
- }
- }
- }
-
- pub(crate) fn run(self, settings: &Settings) {
- if !settings.paths_ok() {
- eprintln!(
- "Atuin settings paths are broken. Disabling atuin shell hooks. Run `atuin doctor` to diagnose."
- );
- }
-
- self.static_init();
- }
-}