Add --ghost=TEXT to display a ghost text when the input is empty
Some checks are pending
CodeQL / Analyze (go) (push) Waiting to run
Test fzf on Linux / build (push) Waiting to run
Test fzf on macOS / build (push) Waiting to run

This commit is contained in:
Junegunn Choi
2025-03-14 16:46:23 +09:00
parent 6c104d771e
commit 4298c0b1eb
5 changed files with 44 additions and 0 deletions

View File

@@ -234,6 +234,7 @@ type Terminal struct {
wrap bool
wrapSign string
wrapSignWidth int
ghost string
separator labelPrinter
separatorLen int
spinner []string
@@ -847,6 +848,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
infoCommand: opts.InfoCommand,
infoStyle: opts.InfoStyle,
infoPrefix: opts.InfoPrefix,
ghost: opts.Ghost,
separator: nil,
spinner: makeSpinner(opts.Unicode),
promptString: opts.Prompt,
@@ -2359,6 +2361,11 @@ func (t *Terminal) printPrompt() {
t.prompt()
before, after := t.updatePromptOffset()
if len(before) == 0 && len(after) == 0 && len(t.ghost) > 0 {
w.CPrint(tui.ColInput.WithAttr(tui.Dim), t.ghost)
return
}
color := tui.ColInput
if t.paused {
color = tui.ColDisabled