feat: add configurable key bindings with ESC quit disable option

- Add unified application configuration system with JSON config file
- Implement configurable quit keys (default: "q", "ctrl+c")
- Add disable_esc_quit option for vim users to prevent accidental exits
- Auto-create default config file at ~/.config/sshm/config.json
- Maintain backward compatibility (ESC quit enabled by default)
- Include comprehensive tests and documentation
This commit is contained in:
zxr
2025-09-29 11:05:26 +08:00
parent 3d746ec49a
commit 120cd6c009
6 changed files with 416 additions and 3 deletions

View File

@@ -17,6 +17,15 @@ import (
// NewModel creates a new TUI model with the given SSH hosts
func NewModel(hosts []config.SSHHost, configFile, currentVersion string) Model {
// Load application configuration
appConfig, err := config.LoadAppConfig()
if err != nil {
// Log the error but continue with default configuration
fmt.Printf("Warning: Could not load application config: %v, using defaults\n", err)
defaultConfig := config.GetDefaultAppConfig()
appConfig = &defaultConfig
}
// Initialize the history manager
historyManager, err := history.NewHistoryManager()
if err != nil {
@@ -39,6 +48,7 @@ func NewModel(hosts []config.SSHHost, configFile, currentVersion string) Model {
sortMode: SortByName,
configFile: configFile,
currentVersion: currentVersion,
appConfig: appConfig,
styles: styles,
width: 80,
height: 24,