Skip to content

feat: add configurable Enter execution for executables and Ctrl+O terminal access#2

Merged
kooler merged 4 commits intokooler:mainfrom
rguziy:feature/execute-terminal
Apr 11, 2026
Merged

feat: add configurable Enter execution for executables and Ctrl+O terminal access#2
kooler merged 4 commits intokooler:mainfrom
rguziy:feature/execute-terminal

Conversation

@rguziy
Copy link
Copy Markdown

@rguziy rguziy commented Apr 4, 2026

Pull Request Description

Description

This PR adds two major usability improvements to MiddayCommander, inspired by Midnight Commander:

  1. Configurable Enter Key Execution: Allow pressing Enter on executable files to run them directly instead of opening in editor
  2. Terminal Console Access: Add Ctrl+O key binding to open a shell in the current directory with return capability

Changes

Configuration

  • Added "execute" option to enter_action in behavior config section
  • Added terminal key binding (defaults to ctrl+o)

Core Features

  • Enter Execution: When enter_action = "execute", pressing Enter on executable files runs them in foreground
  • Terminal Access: Ctrl+O opens interactive shell in current panel directory
  • Shell Return: Ctrl+O in the shell exits back to MiddayCommander (works with bash/zsh)

Files Modified

  • internal/config/config.go: Added config options and key bindings
  • internal/ui/panel/panel.go: Modified Enter handling for executables
  • internal/app/app.go: Added message handling and key dispatch
  • internal/app/commands.go: Implemented execution and terminal commands
  • internal/app/keymap.go: Added terminal key binding
  • internal/ui/help/help.go: Updated help documentation
  • README.md: Updated features and config docs
  • config.example.toml: Added new options

Configuration

Add to ~/.config/mdc/config.toml:

[behavior]
enter_action = "execute"  # Options: "edit", "preview", "execute"

[keys]
terminal = "ctrl+o"  # Open terminal

Testing

  1. Enter Execution:

    • Set enter_action = "execute" in config
    • Navigate to an executable file (e.g., script with execute permissions)
    • Press Enter → should run the file in terminal
    • Press Enter on non-executables → should still edit/preview as before
  2. Terminal Access:

    • Press Ctrl+O → opens shell in current directory
    • Press Ctrl+O in shell → returns to MiddayCommander
    • Directory changes in shell don't affect panel (standard mc behavior)
  3. Help:

    • Press F1 → should show "Terminal" in Tools section

Motivation

Addresses user pain points with script execution convenience:

  • Eliminates need for Ctrl+R + typing command for simple script execution
  • Provides familiar mc-style terminal access
  • Maintains backward compatibility with existing workflows

Screenshots

N/A - Terminal application, functionality can be tested via described steps.

Checklist

  • Code compiles without errors
  • Backward compatible (existing configs work)
  • Help documentation updated
  • Config examples updated
  • Tested with bash and zsh shells
  • Follows existing code patterns and style

…access

- Add 'execute' option to enter_action config for running executable files
- Implement Ctrl+O key binding to open terminal in current directory
- Add shell return binding (Ctrl+O exits shell back to mdc)
- Update help documentation and config examples
- Support bash and zsh shells with temporary config files
Copy link
Copy Markdown
Owner

@kooler kooler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good code!

Not a blocker but a thought -- perhaps would make sense to ask user for a confirmation before executing the file? to avoid incidently running something. Can be a setting that is ON by default but can be disabled if needed.

Also perhaps show something like "press any key to continue" after script is executed? so that if script quickly outputs something or fails user can see the output before it blinks back?

Comment thread internal/ui/panel/panel.go Outdated
@rguziy
Copy link
Copy Markdown
Author

rguziy commented Apr 11, 2026

  • Added confirm_execute behavior config to prompt before running executable files with Enter.
  • Added pause_after_execute config (default false) so execution can optionally pause and wait before returning to Midday Commander.
  • Updated config example and README docs.
  • Kept existing Enter/preview behavior intact and only applies when enter_action = "execute".

@kooler
Copy link
Copy Markdown
Owner

kooler commented Apr 11, 2026

awesome, thanks @rguziy !

@kooler kooler merged commit 657ed0c into kooler:main Apr 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants