Skip to content

Conversation

@amatsuda
Copy link
Member

Here's another take for the RPROMPT feature that I sent at #878.

Based on a discussion with @tompng, I changed the API from the Reline.rprompt= setter to a keyword argument for Reline.readline / Reline.readmultiline.
Added was a keyword argument rprompt:, plus, prompt: and add_hist: for consistency, keeping the existing positional ones for compatibility.

Usage

Reline.readline("> ", rprompt: "[%H:%M]")  # Setting prompt via positional arg and rprompt via kwarg

or

Reline.readline(prompt: "> ", rprompt: "[%H:%M]")  # Setting both prompt and rprompt via kwarg

Testing

Try this. Now it's much simpler, obviously.

ruby -rreline -Ilib -e 'print Reline.readline("> ", rprompt: "[#{Dir.pwd}]")'

This adds support for displaying a right-aligned prompt (rprompt)
similar to zsh's RPROMPT feature. The rprompt is displayed at the
right edge of the terminal and automatically hides when the input
line gets too long.

Usage:
  Reline.readline("> ", rprompt: "[%H:%M]")

The rprompt is rendered as part of Reline's normal render cycle,
so it persists during line editing unlike workarounds using
pre_input_hook.
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