Sample Header Ad - 728x90

How can I use a terminal emulator as an efficient application launcher?

5 votes
1 answer
680 views
### The Problem I've used various application launchers like rofi, albert, wofi, dmenu, and others throughout my Linux years. While they have their pros and cons, one thing has always bothered me: **they're not a bash shell.** Why does this matter? I really enjoy some of the bash's features, such as: - **GNU Readline shortcuts:** Navigating or edit text with Ctrl+A (beginning of line), Ctrl+E (end), Ctrl+K (kill text), Ctrl+Y (yank), Meta+Y (yank history), and more. - **Command history:** Using ~/.bash_history for searching with Ctrl+R/Ctrl+S, or navigating commands with Ctrl+P/Ctrl+N. - **Tab completion:** With tools like bash-completion and bash-complete-alias, I have powerful auto-completion for paths, command names, and arguments. - **Aliases:** Some programs are easier and faster to launch via my custom aliases. --- ### My Goal I want to use a terminal emulator as a simple application launcher. Here’s how it should work: 1. Press a shortcut key to launch the terminal (e.g., kitty). 2. Type a command (e.g., firefox). 3. Press ``. The terminal should: - Launch the command. - Immediately close itself. - Leave the launched application running. For example, typing firefox should behave like executing firefox & disown & exit or nohup firefox > /dev/null 2>&1 & exit. Typing & disown & exit after the command achieves the desired effect, but, of course, I don't want to manually add & disown & exit every time. Note: this is **not window swallowing**. I don’t want the terminal window to linger after the application closes; I only need it for input. --- ### What I’ve Tried 1. **Using read:** Launching kitty with this command:
kitty -e bash -i -c 'read -e -p "Command: " cmd; eval "$cmd"'
This approach fails because typing via read bypasses some of the shell features I want, like tab completion and command history. 2. **Automating with a secondary shortcut:** Typing the command and using another shortcut (e.g., Super+) to append and execute & disown & exit with a tool like wtype. This is very workaroundish, but I'd settle for it, if it worked. Unfortunately, it does not: pressing a modifier key like Super causes unwanted behavior: every character in the string (& disown & exit) is sent with the modifier, triggering shortcuts instead of being interpreted as text. --- ### Conclusion How can I achieve this? I want a solution that lets me quickly launch applications while leveraging all the features of an interactive bash shell.
Asked by chedieck (71 rep)
Dec 1, 2024, 09:23 PM
Last activity: Mar 10, 2025, 05:09 AM