-
Notifications
You must be signed in to change notification settings - Fork 2
Shell Integration
CheatMD can be embedded into your shell, tmux, or Zellij for instant access.
The widget inserts CheatMD into your shell's readline, so the chosen command lands directly on your prompt line.
# Bash - add to ~/.bashrc
eval "$(cheatmd widget bash)"
# Zsh - add to ~/.zshrc
eval "$(cheatmd widget zsh)"Press Ctrl+G (default) to open the selector. Pick a cheat, resolve its
variables, and the final command is inserted into your current prompt. Press
Enter to run it.
Set key_widget in your config to any readline keyspec:
key_widget: "\\C-g" # Ctrl+G (default)
key_widget: "\\C-n" # Ctrl+N
key_widget: "\\e[24~" # F12Open CheatMD in a split pane; the chosen command is pasted into the previous pane.
Add to ~/.tmux.conf:
bind-key -n C-n split-window "$SHELL --login -i -c 'cheatmd --print | tr -d \"\\r\\n\" | tmux load-buffer -b tmp - ; tmux paste-buffer -t {last} -b tmp -d'"Press Ctrl+N to open. The command is pasted into the pane you came from.
Open CheatMD in a floating pane; the chosen command is typed into the previous pane.
Add to your Zellij config:
bind "Ctrl n" {
Run "sh" "-c" "content=$(cheatmd --print); zellij action toggle-floating-panes; zellij action write-chars \"$content\"" {
floating true
close_on_exit true
};
}Press Ctrl+N to open in a floating pane.
The integrations above use --print mode (or output: print in config).
The three modes:
| Mode | Behavior |
|---|---|
print |
Print command to stdout (for piping/capture) |
copy |
Copy to system clipboard |
exec |
Execute immediately in the configured shell |
Set globally in config or per-invocation with --output:
cheatmd --output exec # Run immediately
cheatmd --output copy # Copy to clipboard