Skip to main content

Bash Plugin

The Bash plugin provides in-prompt text expansion through Bash's readline interface.

Installation

Add to your ~/.bashrc:

source /path/to/shell/cli-expander.bash

Usage

The primary workflow is :trigger[Space]. Type a trigger and press Space to expand.

$ :hello[Space]
$ Hello World!

This opens form TUI for matches that have forms, then inserts the generated result directly into the prompt — ready for editing or execution.

Manual Expansion

Press Ctrl+T to manually expand the current prompt buffer without Space.

Press Ctrl+F or Alt+F to open a fuzzy search dialog over your entire trigger library:

$ [Ctrl+F]
> findx
:findx Interactive form with 4 fields forms-advanced
:findname Find by name with manual inputs forms-linux
:findrm Find and delete with confirmation forms-linux
:findexec Find and exec on results forms-linux

Selecting a trigger inserts it into the prompt and expands it automatically. The preview panel on the right shows full trigger details using ce details.

The fzf picker features:

FeatureBehavior
SearchFuzzy match across trigger name, description, and category
PreviewRight panel shows ce details output for the selected trigger
Ctrl+TToggle preview window between right, bottom, and hidden
EnterSelect trigger and expand inline
EscCancel, leaving prompt unchanged

The picker runs ce list --csv piped through fzf with --preview='ce details {1}'. This requires the fzf binary to be installed.

How It Works

The plugin captures keybindings via bind -x:

BindingFunctionDescription
Space_cli_expander_on_spaceIntercepts space after a trigger and expands inline
Ctrl+T_cli_expander_expandManually expand current prompt buffer
Ctrl+F_cli_expander_fzf_searchOpen fzf fuzzy search over all triggers
Alt+F_cli_expander_fzf_searchFallback fzf search (same as Ctrl+F)

For :trigger[Space]:

  1. The prompt buffer is sent to ce expand
  2. If the trigger is a form, the TUI opens for user input
  3. The generated text replaces READLINE_LINE
  4. The result is editable before execution

For Ctrl+F:

  1. Runs ce list --csv and pipes it into fzf
  2. Displays triggers with fuzzy search and preview pane
  3. On selection, extracts the trigger name and expands it via _cli_expander_expand
  4. On cancel, the prompt is unchanged

Important

Avoid using :trigger[Enter] for command builders. Enter executes the typed trigger as a shell command. Use :trigger[Space] so the expansion lands in the editable command line first.

Changing the Keybinding

Edit shell/cli-expander.bash and change the bind line:

# Change to Ctrl+E instead of Ctrl+T
bind -x '"\C-e": _cli_expander_expand'

For fzf, the binding is:

# Change to Ctrl+G instead of Ctrl+F
bind -x '"\C-g": _cli_expander_fzf_search'

What's Next

Set up the Fish Plugin if you use that shell.