Issue: Centralized Configuration System for MLH
Title
Implement centralized configuration system (mlh.conf) for all plugins
Labels
enhancement, configuration, refactoring
Description
Problem
Currently, each plugin has its own configuration approach:
bookmark-alias.conf exists only for bookmark alias configuration
- Future plugins will need their own config files
- No standardized configuration pattern across the project
Proposal
Create a unified configuration system using a single mlh.conf file in ~/.mylinuxhelper/ that all plugins can read.
Benefits
- Single source of truth: All MLH configuration in one place
- User-friendly: Users only need to edit one file
- Maintainable: Easier to document and support
- Extensible: Easy to add new configuration options
- Consistent: All plugins use the same config reading pattern
Proposed Structure
File location: ~/.mylinuxhelper/mlh.conf
Format (Bash-sourceable):
# MyLinuxHelper Configuration
# This file is sourced by MLH scripts to read configuration
# === Bookmark Configuration ===
# Alias/shortcut for bookmark command (default: none)
# Valid values: alphanumeric and underscore only (e.g., bm, b, fav)
BOOKMARK_ALIAS="bm"
# === History Configuration ===
# Maximum number of history entries to display (default: 1000)
HISTORY_MAX_ENTRIES=1000
# === Docker Configuration ===
# Default container image (default: ubuntu:22.04)
DOCKER_DEFAULT_IMAGE="ubuntu:22.04"
# === Future configurations ===
# More options can be added here as new features are developed
Implementation Plan
Phase 1: Create Config Infrastructure
- Create
mlh.conf.example in repository root with documented examples
- Update
.gitignore to exclude ~/.mylinuxhelper/mlh.conf (user-specific)
- Create helper function in
install.sh or a new lib/config.sh:
# Load MLH configuration
load_mlh_config() {
local config_file="${HOME}/.mylinuxhelper/mlh.conf"
if [ -f "$config_file" ]; then
# shellcheck source=/dev/null
source "$config_file" 2>/dev/null || true
fi
}
Phase 2: Migrate Existing Configs
- Update
mlh-bookmark.sh to use mlh.conf instead of bookmark-alias.conf
- Add backward compatibility: check both files, prefer new format
- Update
setup.sh to:
- Read from
mlh.conf
- Generate
mlh.conf from mlh.conf.example on first setup
- Show migration notice if old config files exist
Phase 3: Documentation
- Update
docs/CONFIGURATION.md (new file) with:
- All available configuration options
- Default values
- Examples for common use cases
- Update
README.md to reference configuration guide
- Update
CLAUDE.md with config system architecture
Phase 4: Testing
- Add tests for config loading (
tests/test-mlh-config.sh)
- Test backward compatibility with old config files
- Test config validation (invalid values, syntax errors)
Migration Path
For existing users with bookmark-alias.conf:
Option A: Automatic migration in setup.sh
# If old config exists and new doesn't
if [ -f "$HOME/.mylinuxhelper/bookmark-alias.conf" ] && [ ! -f "$HOME/.mylinuxhelper/mlh.conf" ]; then
echo "Migrating bookmark-alias.conf to mlh.conf..."
# Read old config and create new one
fi
Option B: Show warning and instructions
if [ -f "$HOME/.mylinuxhelper/bookmark-alias.conf" ]; then
echo "⚠️ Notice: bookmark-alias.conf is deprecated"
echo " Please migrate to mlh.conf (see docs/CONFIGURATION.md)"
fi
Recommendation: Option A (automatic migration) for better UX
File Organization
Before:
~/.mylinuxhelper/
├── bookmarks.json
├── bookmark-alias.conf # Plugin-specific
├── .update-config # Another config format
└── .history-timestamp # Yet another format
After:
~/.mylinuxhelper/
├── bookmarks.json # Data (JSON)
├── mlh.conf # Unified config (Bash-sourceable)
├── .update-config # Internal state (keep separate)
└── .history-timestamp # Internal state (keep separate)
Note: Internal state files (.update-config, .history-timestamp) are automatically managed and should remain separate from user-editable config.
Security Considerations
- Config file validation: Add basic validation for critical settings
- Sourcing safety: Use
set -u to catch undefined variables
- Permissions: Ensure config file is user-readable only (
chmod 600)
- Injection prevention: Don't eval arbitrary code, only source config
Alternative Considered
INI-style config (e.g., using crudini or custom parser):
[bookmark]
alias = bm
[history]
max_entries = 1000
Rejected because:
- Requires additional parsing logic or dependencies
- Bash-sourceable format is simpler and native to shell scripts
- Most system config files in Linux use shell-sourceable format (e.g.,
/etc/default/*)
Breaking Changes
None if backward compatibility is implemented. Old config files will continue to work.
Example Config File
See attached: mlh.conf.example
# MyLinuxHelper Configuration
# Location: ~/.mylinuxhelper/mlh.conf
#
# This file is sourced by MLH scripts to read user preferences.
# Edit values below and run './setup.sh' to apply changes.
# ============================================================================
# BOOKMARK CONFIGURATION
# ============================================================================
# Bookmark command alias (shortcut)
# Set this to create a shorter command alias (e.g., 'bm' instead of 'bookmark')
# Valid values: alphanumeric and underscore only [a-zA-Z0-9_]
# Examples: bm, b, fav, goto, marks
# Default: "" (no alias)
BOOKMARK_ALIAS="bm"
# ============================================================================
# HISTORY CONFIGURATION (Future)
# ============================================================================
# Maximum number of history entries to display
# Default: 1000
# HISTORY_MAX_ENTRIES=1000
# Show timestamps in history output
# Default: true
# HISTORY_SHOW_TIMESTAMPS=true
# ============================================================================
# DOCKER CONFIGURATION (Future)
# ============================================================================
# Default container image for 'linux' command
# Default: ubuntu:22.04
# DOCKER_DEFAULT_IMAGE="ubuntu:22.04"
# Mount current directory in containers
# Default: true
# DOCKER_MOUNT_CWD=true
Success Criteria
- Single
mlh.conf file works for all current and future plugins
- Backward compatibility maintained (old configs still work)
- Documentation is clear and comprehensive
- Tests cover config loading and validation
- User experience improved (one config file, clear structure)
Timeline Estimate
- Phase 1 (Infrastructure): 2-3 hours
- Phase 2 (Migration): 2-3 hours
- Phase 3 (Documentation): 1-2 hours
- Phase 4 (Testing): 1-2 hours
- Total: 6-10 hours
Dependencies
None. This is a standalone enhancement.
References
- Current implementation:
bookmark-alias.conf.example
- Similar systems: systemd environment files,
/etc/default/* configs
Issue: Centralized Configuration System for MLH
Title
Implement centralized configuration system (
mlh.conf) for all pluginsLabels
enhancement,configuration,refactoringDescription
Problem
Currently, each plugin has its own configuration approach:
bookmark-alias.confexists only for bookmark alias configurationProposal
Create a unified configuration system using a single
mlh.conffile in~/.mylinuxhelper/that all plugins can read.Benefits
Proposed Structure
File location:
~/.mylinuxhelper/mlh.confFormat (Bash-sourceable):
Implementation Plan
Phase 1: Create Config Infrastructure
mlh.conf.examplein repository root with documented examples.gitignoreto exclude~/.mylinuxhelper/mlh.conf(user-specific)install.shor a newlib/config.sh:Phase 2: Migrate Existing Configs
mlh-bookmark.shto usemlh.confinstead ofbookmark-alias.confsetup.shto:mlh.confmlh.conffrommlh.conf.exampleon first setupPhase 3: Documentation
docs/CONFIGURATION.md(new file) with:README.mdto reference configuration guideCLAUDE.mdwith config system architecturePhase 4: Testing
tests/test-mlh-config.sh)Migration Path
For existing users with
bookmark-alias.conf:Option A: Automatic migration in
setup.shOption B: Show warning and instructions
Recommendation: Option A (automatic migration) for better UX
File Organization
Before:
After:
Note: Internal state files (
.update-config,.history-timestamp) are automatically managed and should remain separate from user-editable config.Security Considerations
set -uto catch undefined variableschmod 600)Alternative Considered
INI-style config (e.g., using
crudinior custom parser):Rejected because:
/etc/default/*)Breaking Changes
None if backward compatibility is implemented. Old config files will continue to work.
Example Config File
See attached:
mlh.conf.exampleSuccess Criteria
mlh.conffile works for all current and future pluginsTimeline Estimate
Dependencies
None. This is a standalone enhancement.
References
bookmark-alias.conf.example/etc/default/*configs