A fuzzy launcher I use for the last 2 years

About 2 years ago, I decided to write my own launcher. It's been originally for Yabai WM, which is a tiling WM for the mac. I wrote it because at the time there were no satisfactory replacements to dmenu/rofi that suited my personal needs. Right now I use it with Linux, because it's fully portable.

Since I was short on time, I decided to not write my own GUI. Instead, I was starting a terminal in the middle of the screen without window decorations, which started my launcher instead of bash.

For the launcher, I decided to pick fzf, which already has great fuzzy search-and-complete. It turned out eventually that fzf can not only filter stdin and run a command, but can also run a script that would interactively receive an updated line that the user is typing.

Using change:reload-sync:, you can make fzf run any external program that can essentially produce auto-completions for the line the user is typing. So, using it you can implement prefix commands. In my case, if I type an equal sign and then press space, the shell script underneath will switch into an expression evaluation mode (pipe the rest of the command to "bc" and print the result). As the user edits the expression, the output will be updated as well.

And as a final addition, depending on the prefix command the action taken when the user presses "enter" will be different. For passwords, I use the "pass" tool and the action would be to copy the password to the clipboard. For bookmarks, the action would be to open them in the browser.

To be fair, some other people have come to roughly the same idea. See sway-launcher-desktop for example. I just don't think that other people went as far as to add prefix commands and extensibility.

If you want to read through the code, you can find it here.