Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- `zsh-edit-select` module (zsh): edit the command line like a text editor with
[zsh-edit-select](https://github.com/Michael-Matta1/zsh-edit-select) (Shift
selection, copy, cut, paste, undo, mouse selection). Installed from a pinned
clone (`v0.7.01`); on macOS `apply` builds the clipboard agent from that clone
clone of the [JtheGunner fork](https://github.com/JtheGunner/zsh-edit-select)
(`v0.7.02`), whose installer can configure chosen terminals; on macOS `apply` builds the clipboard agent from that clone
with `make`, so a failed build degrades the module instead of surfacing on the
first shell start. On Linux the plugin still downloads its agent itself on the
first shell start, from its latest release instead of the pinned tag.
It loads after `autosuggestions` and `syntax-highlighting`.
The terminal needs key bindings for it, which omnishell does not write; the
cheatsheet lists them. A manual install of the plugin blocks the module until
its `source` line is removed.
The terminal needs key bindings for it: switch on the `terminal_*` options
(`terminal_ghostty`, `terminal_kitty`, …; off by default) and `apply` runs the
plugin's own installer for those terminals, again only when the choice or the
plugin changes. A failing installer degrades the module. Those files are not
covered by backups, `rollback` or `doctor`. A manual install of the plugin
blocks the module until its `source` line is removed.
- Module check hooks now also run for modules whose software comes only from a
fallback, so a module can finish its setup after the clone.

## [0.10.0] - 2026-11-28

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ copy is backed up. Only `apply`, `remove`, and `uninstall` change your system (a
| `pay-respects` | Suggest a corrected command after a failed one, run via the alias (a Rust `thefuck` alternative) — [iffse/pay-respects](https://github.com/iffse/pay-respects) | `pay-respects` (`brew`); else `git` + `cargo` fallback (needs Rust) | zsh, bash | `alias` (string, default `f`) |
| `atuin` | SQLite-backed shell history with fuzzy search, context and stats — [atuinsh/atuin](https://github.com/atuinsh/atuin). **Mutually exclusive with `fzf`** (both bind Ctrl+R) — enabling both is a config error. | `atuin` (`brew`, `pacman`); else `git` + `cargo` fallback (needs Rust) | zsh, bash | `bind_ctrl_r` (bool, default `true`), `bind_up_arrow` (bool, default `true`) |
| `ble-sh` | Autosuggestions and syntax highlighting for **bash** (until now zsh-only) via [ble.sh](https://github.com/akinomyoga/ble.sh). **Opt-in, bash only: it replaces parts of Readline** with its own line editor, so it **conflicts with `fzf` and `atuin`** (they rebind Ctrl+R and the completion keys; enabling either alongside is a config error) and may interact with your own `bind` settings. Loads after `completion` and `history`; sourced with `--attach=prompt` in interactive shells only. Built from a pinned clone (`v0.4.0-devel3`), so it needs `make`, `gawk` and `git` (on macOS: `brew install gawk`). A missing build is skipped silently. | pinned `git` clone built with `make` (no package manager ships it) | bash | — |
| `zsh-edit-select` | Edit the command line like a text editor: Shift+arrow selection, copy, cut, paste, undo/redo, type-to-replace and mouse selections — [Michael-Matta1/zsh-edit-select](https://github.com/Michael-Matta1/zsh-edit-select) (MIT). **It needs terminal key bindings** that send its key sequences to the shell (Ghostty, iTerm2, Kitty, WezTerm, VS Code: see the plugin's README; restart the terminal afterwards), and on macOS Accessibility permission for mouse selections (`edit-select setup-ax`). omnishell writes no terminal configuration. Loads after `completion`, `autosuggestions` and `syntax-highlighting`. **A manual install blocks it**: remove the plugin's `source` line from `~/.zshrc`, delete the old clone and stop its agent. `omnishell cheatsheet` lists the keys | pinned `git` clone (`v0.7.01`); on macOS `apply` builds the clipboard agent with `make` (Xcode Command Line Tools). **On Linux the plugin itself downloads its agent on the first shell start, from its latest GitHub release rather than the pinned tag** (checked against that release's `SHA256SUMS.txt`, not against anything omnishell pins); `edit-select build` compiles it from source instead | zsh | — |
| `zsh-edit-select` | Edit the command line like a text editor: Shift+arrow selection, copy, cut, paste, undo/redo, type-to-replace and mouse selections — [Michael-Matta1/zsh-edit-select](https://github.com/Michael-Matta1/zsh-edit-select) (MIT), installed from the [JtheGunner fork](https://github.com/JtheGunner/zsh-edit-select) whose installer can configure terminals. **It needs terminal key bindings** that send its key sequences to the shell: switch on the terminals you use with the `terminal_*` options and `apply` runs the plugin's own installer for them (restart the terminal afterwards). On macOS it also needs Accessibility permission for mouse selections (`edit-select setup-ax`). Those terminal files are written by the plugin's installer, not by omnishell, so backups, `rollback` and `doctor` do not cover them. Loads after `completion`, `autosuggestions` and `syntax-highlighting`. **A manual install blocks it**: remove the plugin's `source` line from `~/.zshrc`, delete the old clone and stop its agent. `omnishell cheatsheet` lists the keys | pinned `git` clone of the fork (`v0.7.02`); on macOS `apply` builds the clipboard agent with `make` (Xcode Command Line Tools). **On Linux the plugin itself downloads its agent on the first shell start, from its latest GitHub release rather than the pinned tag** (checked against that release's `SHA256SUMS.txt`, not against anything omnishell pins); `edit-select build` compiles it from source instead | zsh | `terminal_ghostty`, `terminal_kitty`, `terminal_alacritty`, `terminal_wezterm`, `terminal_foot`, `terminal_konsole`, `terminal_iterm2`, `terminal_vscode`, `terminal_windows_terminal` (bool, default `false`) |
| `modern-aliases` | Replace ls/cat/find with [eza](https://github.com/eza-community/eza), [bat](https://github.com/sharkdp/bat) and [fd](https://github.com/sharkdp/fd) when selected | `eza`, `bat`, `fd`; `eza` as a release binary where the manager has no package | zsh, bash | `replace` (`list<enum>` of `ls`, `cat`, `find`; default `["ls", "cat", "find"]`) |
| `colorized-man` | Syntax-highlighted man pages via [bat](https://github.com/sharkdp/bat) when present, with a zero-dependency `less` colour fallback | — (config only) | zsh, bash | — |
| `tealdeer` | A fast `tldr` client: short, practical command examples instead of long man pages — [tealdeer-rs/tealdeer](https://github.com/tealdeer-rs/tealdeer). The page cache is not filled by `apply`; `tldr` downloads it on first use | `tealdeer` (all managers); else a verified release binary (Linux x86_64, arm64, armv7) | zsh, bash | — |
Expand Down
14 changes: 14 additions & 0 deletions docs/design-decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ not built. For how the features work, see the [README](../README.md),
unset, so existing user settings win. `GIT_PAGER` overrides `core.pager`
without editing it. `interactive.diffFilter` (for `git add -p`) cannot be
set through the environment and is left to the user.
- **Exception: `zsh-edit-select` terminal setup.** The plugin only works once
the terminal sends its key sequences to the shell. omnishell does not write
those files itself: the module's `install` hook runs the plugin's own
installer (`--mode integrate --terminals <list>`) for the terminals the user
switched on through the `terminal_*` options. The installer owns the format
and the files (for Ghostty a block in `ghostty.local` plus one import line).
Consequences: backups, `rollback` and `doctor` do not cover these files; the
installer keeps its own backup, and its uninstaller removes the blocks.
`omnishell remove` leaves them in place. The `check` hook records the plugin
commit and the terminal list in `zsh-edit-select.terminals` in the config
dir, so the installer runs again only when either changes, and a failing
installer degrades the module and leaves no record, so the next `apply`
retries. The options are bools because the TUI and `omnishell set` edit
those but not lists.

## Self-update

Expand Down
6 changes: 4 additions & 2 deletions docs/writing-a-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,10 @@ context as environment variables:
| `OMNISHELL_OPT_<UPPERCASE_KEY>` | one per option, e.g. `OMNISHELL_OPT_LOG_FORMAT` |

- `check.sh` — exit `0` = requirement satisfied, exit `1` = missing. Consulted
when the module declares no `[packages]` entry for the detected manager, or
to gate rendering.
when the module declares no `[packages]` entry for the detected manager, to
gate rendering, or when the module's software comes only from a
`[[packages.fallback]]` (no manager packages), so it can finish its setup
after the clone.
- `install.sh` — run only when `check.sh` fails and the package path did not
satisfy the requirement.
- `remove.sh` — run by `omnishell remove <id> --purge`.
Expand Down
52 changes: 52 additions & 0 deletions internal/engine/check_hook_fallback_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package engine_test

import (
"strings"
"testing"

"github.com/JtheGunner/omnishell/internal/engine"
"github.com/JtheGunner/omnishell/internal/pkgmgr"
)

// A module whose software comes only from a fallback can still be gated by a
// check hook: the clone is not the whole requirement (zsh-edit-select configures
// terminals after cloning it).
func TestComputePlanUsesCheckHookForFallbackOnlyModule(t *testing.T) {
withManager := testEngine(t, &pkgmgr.MockManager{NameV: "apt", DetectV: true, Installed: map[string]bool{}})
for name, e := range map[string]engine.Engine{
"without a manager": noManagerEngine(t),
"with a manager": withManager,
} {
if mp := planNoManager(t, e, "fallback-hooked"); !mp.UsesCheckHook {
t.Errorf("%s: UsesCheckHook = false, want true", name)
}
}
}

// A module without a check hook never gets one, whatever its packages are.
func TestComputePlanLeavesModuleWithoutCheckHookAlone(t *testing.T) {
e := testEngine(t, &pkgmgr.MockManager{NameV: "apt", DetectV: true, Installed: map[string]bool{"fzf": true}})
if mp := planNoManager(t, e, "fzf"); mp.UsesCheckHook {
t.Error("fzf has no check hook and must not use one")
}
if mp := planNoManager(t, noManagerEngine(t), "cargo-built"); mp.UsesCheckHook {
t.Error("cargo-built has no check hook and must not use one")
}
}

func TestApplyRunsCheckHookForFallbackOnlyModule(t *testing.T) {
runner := &pkgmgr.MockRunner{}
mgr := &pkgmgr.MockManager{NameV: "apt", DetectV: true, Installed: map[string]bool{}}
if _, err := applyModule(t, "fallback-hooked", mgr, runner); err != nil {
t.Fatal(err)
}
var ran bool
for _, c := range runner.Calls {
if strings.Contains(c, "omnishell-check-") {
ran = true
}
}
if !ran {
t.Fatalf("check hook was not run; calls: %v", runner.Calls)
}
}
16 changes: 14 additions & 2 deletions internal/engine/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,23 @@ func ComputePlan(e Engine, cfg config.Config, lock lockfile.Lock, noPackages boo
return p, nil
}

// hasManagerPackages reports whether the manifest lists packages for any
// package manager.
func hasManagerPackages(mf module.Manifest) bool {
return len(mf.Packages.Brew)+len(mf.Packages.Apt)+len(mf.Packages.Dnf)+
len(mf.Packages.Pacman)+len(mf.Packages.Zypper)+len(mf.Packages.Apk) > 0
}

func planPackages(mp *ModulePlan, e Engine, mod module.Module, shells []string, prev lockfile.ModuleState) {
mf := mp.Manifest
// A module whose software comes only from a fallback is not done once the
// clone is in place (zsh-edit-select configures terminals afterwards), so
// its check hook is consulted too.
if mod.HasHook("check") && len(mf.Packages.Fallback) > 0 && !hasManagerPackages(mf) {
mp.UsesCheckHook = true
}
if !e.ManagerOK {
if len(mf.Packages.Brew)+len(mf.Packages.Apt)+len(mf.Packages.Dnf)+
len(mf.Packages.Pacman)+len(mf.Packages.Zypper)+len(mf.Packages.Apk) > 0 {
if hasManagerPackages(mf) {
mp.DegradedReason = "no package manager detected"
return
}
Expand Down
1 change: 1 addition & 0 deletions internal/engine/testdata/modules/fallback-hooked/bash.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo fallback-hooked
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exit 0
16 changes: 16 additions & 0 deletions internal/engine/testdata/modules/fallback-hooked/manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
platforms = ["macos", "linux"]
shells = ["zsh", "bash"]
requires = []
after = []

[module]
id = "fallback-hooked"
name = "Fallback Hooked"
description = "Fixture: a module whose only software is a git clone, gated by a check hook"
version = "1.0.0"
schema = 1

[[packages.fallback]]
type = "git"
repo = "https://example.com/fallback-hooked.git"
dest = "{{.VendorDir}}/fallback-hooked"
1 change: 1 addition & 0 deletions internal/engine/testdata/modules/fallback-hooked/zsh.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo fallback-hooked
2 changes: 1 addition & 1 deletion modules/builtin/zsh-edit-select/cheatsheet.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
- `{{ $mod }}+A` select all, `{{ $mod }}+C` copy, `{{ $mod }}+X` cut, `{{ $mod }}+Z` undo, `{{ $mod }}+Shift+Z` redo
- Paste with your terminal's own paste shortcut; it replaces a selection
- Run `edit-select config` to change the mouse behaviour and the key bindings
- Needs terminal key bindings that send these sequences to the shell (examples for Ghostty, iTerm2, Kitty, WezTerm and VS Code are in the plugin's README); restart the terminal afterwards
- Needs terminal key bindings that send these sequences to the shell: switch on your terminals with `omnishell set zsh-edit-select terminal_ghostty true` (also `terminal_kitty`, `terminal_alacritty`, `terminal_wezterm`, `terminal_foot`, `terminal_konsole`, `terminal_iterm2`, `terminal_vscode`, `terminal_windows_terminal`) or in the TUI, then run `omnishell apply` and restart the terminal
{{ if eq .Platform "macos" }}- Mouse selections need Accessibility permission for your terminal: run `edit-select setup-ax`
{{ end }}- A manual install of the plugin blocks this module: remove its `source` line from `~/.zshrc`, delete the old clone and stop its agent, otherwise nothing is loaded from here
32 changes: 32 additions & 0 deletions modules/builtin/zsh-edit-select/hooks/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh
# Exit 0 when the terminals chosen in the module options are already set up for
# the current plugin clone, 1 when hooks/install.sh has to run. With no terminal
# chosen there is nothing to configure.
#
# The state is one line in $OMNISHELL_CONFIG_DIR/zsh-edit-select.terminals:
# "<commit of the clone> <comma separated terminals>".

terminals=""
add() {
if [ "$2" = "true" ]; then
terminals="${terminals:+$terminals,}$1"
fi
}

add ghostty "$OMNISHELL_OPT_TERMINAL_GHOSTTY"
add kitty "$OMNISHELL_OPT_TERMINAL_KITTY"
add alacritty "$OMNISHELL_OPT_TERMINAL_ALACRITTY"
add wezterm "$OMNISHELL_OPT_TERMINAL_WEZTERM"
add foot "$OMNISHELL_OPT_TERMINAL_FOOT"
add konsole "$OMNISHELL_OPT_TERMINAL_KONSOLE"
add iterm2 "$OMNISHELL_OPT_TERMINAL_ITERM2"
add vscode "$OMNISHELL_OPT_TERMINAL_VSCODE"
add windows-terminal "$OMNISHELL_OPT_TERMINAL_WINDOWS_TERMINAL"

[ -z "$terminals" ] && exit 0

plugin="$OMNISHELL_VENDOR_DIR/zsh-edit-select"
commit=$(git -C "$plugin" rev-parse HEAD 2>/dev/null) || exit 1

state="$OMNISHELL_CONFIG_DIR/zsh-edit-select.terminals"
[ "$(cat "$state" 2>/dev/null)" = "$commit $terminals" ]
37 changes: 37 additions & 0 deletions modules/builtin/zsh-edit-select/hooks/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
# Configure the chosen terminals with the plugin's own installer, then record
# what was done so hooks/check.sh stays quiet until the choice or the plugin
# changes. The state is written only when the installer succeeds; a failing
# installer leaves it alone, so the next `apply` tries again.

terminals=""
add() {
if [ "$2" = "true" ]; then
terminals="${terminals:+$terminals,}$1"
fi
}

add ghostty "$OMNISHELL_OPT_TERMINAL_GHOSTTY"
add kitty "$OMNISHELL_OPT_TERMINAL_KITTY"
add alacritty "$OMNISHELL_OPT_TERMINAL_ALACRITTY"
add wezterm "$OMNISHELL_OPT_TERMINAL_WEZTERM"
add foot "$OMNISHELL_OPT_TERMINAL_FOOT"
add konsole "$OMNISHELL_OPT_TERMINAL_KONSOLE"
add iterm2 "$OMNISHELL_OPT_TERMINAL_ITERM2"
add vscode "$OMNISHELL_OPT_TERMINAL_VSCODE"
add windows-terminal "$OMNISHELL_OPT_TERMINAL_WINDOWS_TERMINAL"

[ -z "$terminals" ] && exit 0

plugin="$OMNISHELL_VENDOR_DIR/zsh-edit-select"
installer="$plugin/assets/auto-install/install.sh"
if [ ! -f "$installer" ]; then
echo "zsh-edit-select: installer not found at $installer" >&2
exit 1
fi

commit=$(git -C "$plugin" rev-parse HEAD 2>/dev/null) || exit 1

bash "$installer" --local --mode integrate --non-interactive --terminals "$terminals" </dev/null || exit 1

printf '%s %s\n' "$commit" "$terminals" >"$OMNISHELL_CONFIG_DIR/zsh-edit-select.terminals"
Loading
Loading