diff --git a/src/autoclaude/cli.py b/src/autoclaude/cli.py index 846d22d..0c95ea2 100644 --- a/src/autoclaude/cli.py +++ b/src/autoclaude/cli.py @@ -467,36 +467,13 @@ class ClaudeCLI: self.print_info("Shortcut already configured in ~/.tmux.conf") return - # Check if 'bind a' is already used by something else + # Remove any existing 'bind a' line (replace it) import re if re.search(r'^\s*bind\s+a\s+', content, re.MULTILINE): - self.print_warning("The key 'a' is already bound in your tmux config") - self.print_info("Current binding:") - for line in content.split('\n'): - if re.search(r'^\s*bind\s+a\s+', line): - print(f" {line.strip()}") - print() - self.print_info("Options:") - print(" 1. Replace the existing binding") - print(" 2. Use a different key") - print(" 3. Cancel installation") - choice = input(f"\n{Colors.BOLD}Choose option (1-3): {Colors.ENDC}") - - if choice == '1': - # Remove existing 'bind a' line - lines = content.split('\n') - lines = [l for l in lines if not re.search(r'^\s*bind\s+a\s+', l)] - content = '\n'.join(lines) - elif choice == '2': - key = input(f"{Colors.BOLD}Enter key to use (e.g., 'b', 'c'): {Colors.ENDC}") - if len(key) != 1 or not key.isalpha(): - self.print_error("Invalid key. Must be a single letter.") - return - # Continue with the custom key - return self._add_shortcut_binding(tmux_conf, content, key) - else: - self.print_info("Installation cancelled") - return + self.print_info("Replacing existing 'bind a' binding") + lines = content.split('\n') + lines = [l for l in lines if not re.search(r'^\s*bind\s+a\s+', l)] + content = '\n'.join(lines) # Get the full path to autoclaude-toggle script script_path = Path(__file__).parent.parent.parent / '.local' / 'bin' / 'autoclaude-toggle' @@ -507,16 +484,16 @@ class ClaudeCLI: self.print_error(f"autoclaude-toggle script not found") return - self._add_shortcut_binding(tmux_conf, content, 'a') + self._add_shortcut_binding(tmux_conf, content) - def _add_shortcut_binding(self, tmux_conf: Path, content: str, key: str): + def _add_shortcut_binding(self, tmux_conf: Path, content: str): script_path = Path.home() / '.local' / 'bin' / 'autoclaude-toggle' # Add the keybinding to tmux config - binding = f'\n# Toggle autoclaude automation for active pane and show status\nbind {key} run-shell "{script_path}"\n' + binding = f'\n# Toggle autoclaude automation for active pane and show status\nbind a run-shell "{script_path}"\n' tmux_conf.write_text(content + binding) - self.print_success(f"Added Ctrl+A+{key.upper()} shortcut to ~/.tmux.conf") + self.print_success(f"Added Ctrl+A+A shortcut to ~/.tmux.conf") self.print_info("Reload tmux config with: tmux source-file ~/.tmux.conf") self.print_info("Or restart your tmux session")