Skip to content

Instantly share code, notes, and snippets.

Last active May 12, 2023 06:08
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
flatpak shim until they're added to path as expected
#!/usr/bin/env zsh
# * leading tabs: indent here-document (heredoc)
# * spaces: indent code within heredoc
if [[ $# -eq 0 ]]; then
Place in path (e.g., /usr/local/bin/fp) and make executable (chmod +x fp).
fp <app>
# fp auto-completion
() {
# list of each flatpak app name in lowercase ("Brave Browser" == "brave")
local FLATPAK_APPS=$(flatpak list --app | cut -f1 | awk '{print tolower($1)}')
autoload -Uz bashcompinit && bashcompinit
autoload -Uz compinit && compinit
complete -W $FLATPAK_APPS fp
# run flatpak apps from cli (e.g., "fp okular")
function fp() {
app=$(flatpak list --app | cut -f2 | awk -v app="$1" '(tolower($NF) ~ tolower(app))')
# abort if the app name was not entered
test -z $1 && printf "\nINSTALLED APPS\n$app\n" && return
# remove app name from "$@" array
shift 1
# run the flatpak app async (subshell in background) and don't show any stdout and stderr
( flatpak run "$app" "$@" &> /dev/null & )
# launch main function with all arguments
fp "$@"
Copy link

This is mostly necessary as I didn't want to add an alias to ~/.bashrc or ~/.bash_aliases and don't want to use zsh (bash + starship ftw)

Added to /usr/local/libexec on Fedora. /usr/local/bin works too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment