Skip to content

feat: add multi-shell architecture with Zsh support#593

Open
ki11e6 wants to merge 4 commits intobasecamp:masterfrom
ki11e6:feature/multi-shell-architecture
Open

feat: add multi-shell architecture with Zsh support#593
ki11e6 wants to merge 4 commits intobasecamp:masterfrom
ki11e6:feature/multi-shell-architecture

Conversation

@ki11e6
Copy link
Copy Markdown

@ki11e6 ki11e6 commented Jan 19, 2026

Summary

Adds a shell-adapter architecture that enables Omakub to support multiple shells. This PR introduces Zsh as an alternative to Bash while maintaining full backward compatibility.

Key Changes

  • Shell-agnostic shared configs (defaults/shared/):

    • environment.sh - PATH, exports, OMAKUB_PATH
    • aliases.sh - All command aliases
    • functions.sh - Utility functions (POSIX-compatible)
  • Zsh adapter (defaults/zsh/):

    • shell - Zsh options with bash compatibility (KSH_ARRAYS, etc.)
    • rc - Sources shared configs + zsh-specific
    • init - Tool initialization (mise, zoxide, fzf)
    • prompt - Minimal Nerd Font prompt
    • completions.zsh - Tab completion + arrow key history search
  • Bash adapter refactor (defaults/bash/):

    • Now sources shared configs
    • Removed duplicated aliases/functions
  • Installer updates:

    • first-run-choices.sh - Shell selection during install
    • a-shell.sh - Dual-shell installation support
  • CLI integration:

    • Added "Shell" option to omakub menu
    • shell.sh - Shell selection menu
    • shell-switch.sh - Switch logic with backup

Architecture

defaults/
├── shared/           # Shell-agnostic (both shells source these)
│   ├── environment.sh
│   ├── aliases.sh
│   └── functions.sh
├── bash/             # Bash-specific adapter
│   ├── rc            # Sources shared + bash-specific
│   ├── shell         # Bash options
│   └── ...
└── zsh/              # Zsh-specific adapter
    ├── rc            # Sources shared + zsh-specific
    ├── shell         # Zsh options (KSH_ARRAYS for bash compat)
    └── ...

Testing

Tested ✓

  • Bash shell config loading
  • Zsh shell config loading
  • Syntax validation of all scripts (bash -n, zsh -n)
  • mise activation (with KSH_ARRAYS workaround)
  • starship prompt rendering in both shells
  • Shell switching via omakub CLI menu
  • Arrow key history search in zsh
  • Shared aliases and functions in both shells
  • app2folder-remove() function (fixed for POSIX compatibility)
  • Full logout/login cycle after shell switch

Not Tested

  • Fresh Omakub installation (first-run-choices.sh shell selection)
  • Clean system without existing shell configs

Notes

  • Shell switch requires logout/login for new terminals (standard chsh behavior)
  • User customizations are backed up but not auto-migrated (user manually copies to avoid breaking shell-specific commands)
  • mise required a workaround: temporarily disable KSH_ARRAYS during activation due to $+functions[...] syntax incompatibility

Introduces shell-adapter pattern allowing users to choose between
Bash and Zsh during installation or switch shells post-installation.

Changes:
- Add defaults/shared/ for shell-agnostic configs (environment, aliases, functions)
- Add defaults/zsh/ adapter with zsh-specific settings and bash compatibility options
- Refactor defaults/bash/ to use shared configs
- Add shell selection to first-run-choices.sh
- Rewrite a-shell.sh installer with dual-shell support
- Add Shell menu to omakub CLI with switch functionality
- Add shell-switch.sh for post-install shell switching with backup/migration
- Rewrite app2folder-remove() to use POSIX-compatible IFS loop
  instead of bash-specific 'read -ra' array syntax
- Add arrow key history search bindings to zsh completions
  (equivalent to bash inputrc functionality)
mise's activation script uses $+functions[name] syntax which is
incompatible with zsh's KSH_ARRAYS option. Temporarily disable
KSH_ARRAYS during mise activation and re-enable it afterward.

This prevents the "(eval):7: bad output format specification" warnings
that appeared when using mise with Omakub's zsh configuration.
- Remove auto-migration of customizations between shells
- Show user where customizations are saved for manual review
- Add note that some commands may need shell-specific adjustments
- Clean up zsh prompt file formatting
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.

1 participant