linux – Pass a Regex pattern to Rofi’s dmenu and combine it with user’s input

Does the Rofi have an option to match only certain part of the line string before generate the menu? I would like to emulate hotkeys that has 2 letters. When I press the combination, that is unique in the list, I’d like Rofi select that line immediately, without hit enter.

For example:

echo -e "(ls)nls -(la)nls -l (ll)n(ca)tnflameshot (fm)" | rofi -dmenu -p command -format s -auto-select -matching regex -no-click-to-exit

generate this menu:

enter image description here

when I type ls rofi should select the first line and return. Instead, it filter the matching lines:

enter image description here

I know that using -matching regex option I could type the regex expression to select exactly what I what. But since I’m going to run this command indirectly using a golang program to mount the rofi command. I have to tell rofi to combine the Regex passed (before rofi executes) and the user input. any idea how to do this?

  • Sorry, english isn’t my first language