Skip to content

trungng92/cheatbuffer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cheatbuffer is a zsh plugin that displays command help info in the minibuffer (the buffer below the prompt that is used by tab completion, reverse history search, etc).

When you activate cheatbuffer (ctrl + h by default), it will display help text by:

  1. reading the current command
  2. trying a host of help commands (by default it tries to run the command with --help and if not successful, the cheat plugin)
  3. displaying the help in the minibuffer.

cheatbuffer demo asciinema link

Installation

Dependencies

Required

Optional

  • brew
  • cheat (installed through brew with brew install cheat)

Installing

  1. git clone https://github.com/trungng92/cheatbuffer.git "$HOME/.oh-my-zsh/custom/plugins/cheatbuffer"
  2. add the cheatbuffer plugin in the plugins list $HOME/.zshrc:
plugins=(
  # other plugins
  cheatbuffer
)

Note: If you don't install the cheat plugin, this will only perform --help functionality

Modifiable environment variables

The current list of environment variables are:

# maximum buffer lines to show
export CHEATBUFFER_MAX_LINES=30
# Space separated function names that will be called when you try to run cheatbuffer
# by default we call _cheatbuffer_help and _cheatbuffer_cheat (which are defined in the cheatbuffer plugin).
# However, you are also able to add your own custom functions by modifying this variable
export CHEATBUFFER_FUNC_ORDER='_cheatbuffer_help _cheatbuffer_cheat'
# key bind to activate cheatbuffer, defaults to ctrl + h
export CHEATBUFFER_KEY_SEQ='^h'

Example: Modifying cheatbuffer to use man

You can run these lines to make the minibuffer to show the man page:

# for docs on how to write a custom function, look inside cheatbuffer.plugin.zsh
man_example() {
    local BUFFER="$1"
    # man prints the help text to stderr
    OUTPUT=$(eval "man $BUFFER") 2>&1
    echo "$OUTPUT"
}

export CHEATBUFFER_FUNC_ORDER='man_example _cheatbuffer_help _cheatbuffer_cheat'

And when you press ctrl + h (or whatever CHEATBUFFER_KEY_SEQ is set to), it will display the man page instead.

More info on how zsh plugin works

You can find documentation on widgets here.

Possible future features

  • cycling through multiple help commands (or aggregating multiple help commands?)

About

plugin to add help text to 'minibuffer'

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages