Add a post about fuzzy launcher
This commit is contained in:
parent
9c8c3f8739
commit
14cb3a1225
1 changed files with 31 additions and 0 deletions
31
content/posts/a_fuzzy_laungher_i_use/note.md
Normal file
31
content/posts/a_fuzzy_laungher_i_use/note.md
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
X-Date: 2023-08-21T23:30:00Z
|
||||||
|
X-Note-Id: 19a3f09f-467c-4ba5-ba58-fd954cd931ea
|
||||||
|
Subject: A fuzzy launcher I use for the last 2 years
|
||||||
|
X-Slug: a_fuzzy_launcher_i_use
|
||||||
|
|
||||||
|
About 2 years ago, I decided to write [my own launcher](https://git.sr.ht/~knazarov/q.sh).
|
||||||
|
It's been originally for [Yabai](https://github.com/koekeishiya/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](https://github.com/Biont/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](https://git.sr.ht/~knazarov/q.sh).
|
Loading…
Reference in a new issue