feat: Add --install-shortcut parameter to configure tmux automatically
Adds `autoclaude --install-shortcut` command that: - Checks if Ctrl+A+A shortcut is already configured in ~/.tmux.conf - Automatically adds the toggle binding if not present - Reloads tmux config for immediate effect This makes it easier for new users to set up keyboard shortcuts without manual config editing. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -451,6 +451,46 @@ class ClaudeCLI:
|
||||
self._add_target(session, window)
|
||||
self.print_success(f"Automation enabled for {pane_id}")
|
||||
|
||||
def install_shortcut(self):
|
||||
self.print_header("Installing Autoclaude Keyboard Shortcut")
|
||||
|
||||
tmux_conf = Path.home() / '.tmux.conf'
|
||||
|
||||
if not tmux_conf.exists():
|
||||
self.print_error(f"Tmux config not found: {tmux_conf}")
|
||||
return
|
||||
|
||||
content = tmux_conf.read_text()
|
||||
|
||||
# Check if already configured
|
||||
if 'autoclaude-toggle' in content:
|
||||
self.print_info("Shortcut already configured in ~/.tmux.conf")
|
||||
return
|
||||
|
||||
# Get the full path to autoclaude-toggle script
|
||||
script_path = Path(__file__).parent.parent.parent / '.local' / 'bin' / 'autoclaude-toggle'
|
||||
if not script_path.exists():
|
||||
script_path = Path.home() / '.local' / 'bin' / 'autoclaude-toggle'
|
||||
|
||||
if not script_path.exists():
|
||||
self.print_error(f"autoclaude-toggle script not found")
|
||||
return
|
||||
|
||||
# Add the keybinding to tmux config
|
||||
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+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")
|
||||
|
||||
# Try to reload tmux config
|
||||
try:
|
||||
subprocess.run(['tmux', 'source-file', str(tmux_conf)], timeout=5, check=True)
|
||||
self.print_success("Tmux config reloaded successfully")
|
||||
except Exception as e:
|
||||
self.print_warning(f"Could not auto-reload tmux: {e}")
|
||||
|
||||
def show_help(self):
|
||||
self.print_header("Autoclaude - Autonomous Claude Code Control System")
|
||||
|
||||
@@ -584,9 +624,14 @@ Run without arguments for interactive menu.
|
||||
parser.add_argument('command', nargs='?', help='Command to run')
|
||||
parser.add_argument('args', nargs='*', help='Command arguments')
|
||||
parser.add_argument('--version', action='version', version=f'%(prog)s v{__version__}')
|
||||
parser.add_argument('--install-shortcut', action='store_true', help='Install Ctrl+A+A keyboard shortcut in tmux config')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.install_shortcut:
|
||||
cli.install_shortcut()
|
||||
return
|
||||
|
||||
if not args.command:
|
||||
cli.interactive_menu()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user