How to make fzf send text that has no match to standard output?

user168651 :

I'm writing a script that opens a terminal and prompts the user to rename a file in fzf. Obviously, there is no match in fzf, so fzf sends an empty string, but I want it to send the string that I wrote. dmenu does this.

Example:

echo "yes\nno" | fzf would only allow either yes or no to be entered, otherwise it prints an empty string

echo "yes\nno" | dmenu Would allow anything to be be entered including yes or no

Kevin Cui :

fzf can print query as the first line: --print-query. To achieve your need, you could try to fetch the last line for both match and no match case: echo "yes\nno" | fzf --print-query | tail -1

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=26150&siteId=1