anyrun

Crates.ioanyrun
lib.rsanyrun
version0.2.1
created_at2025-06-01 03:50:41.494731+00
updated_at2025-08-30 23:08:42.670568+00
descriptionRun anything from the commandline including desktop files and flatpaks
homepage
repositoryhttps://gitlab.com/caferen/anyrun
max_upload_size
id1696857
size8,198
(caferen)

documentation

README

Finds the associated desktop file for its argument and executes its Exec line. Also accepts input from stdin.

  • If a full path to an desktop file is given, it's executed without searching.
  • For any other string, anyrun will loop through all desktop files in XDG_DATA_DIRS and semi-fuzzily match the Name line to find its target.

Any other argument after the first one is passed to the launched application as is.

Notes

  • Semi-fuzzy match will short-circuit on first success. You may not get the application you want if its too ambigous. Try copying your most used applications to ~/.local/share/applications and make sure it's the first directory in XDG_DATA_DIRS.
  • You might need to manually add ${FLATPAK_USER_DIR}/exports/share to XDG_DATA_DIRS. See.
  • To automatically pass anything that's not a valid executable to anyrun, add this to ~/.zshrc (make sure anyrun is in your path):
intercept-exec() {
    read -r cmd args <<< "${(z)BUFFER}"
    if [[ -z $(command -v "$cmd") && "$cmd" != *=* ]]; then
        BUFFER="anyrun $BUFFER &>/dev/null &!"
    fi
    zle accept-line
}

zle -N intercept-exec
bindkey '^M' intercept-exec

This'll make your shell commands run as usual but will append anyrun to anything else. e.g. running chrm in your shell will launch Chromium/Chrome, even if they're flatpaks.

Examples

anyrun frfx: Launches Firefox, even if it's a flatpak.

anyrun frfx @@ /path/to/some/file @@: Opens the file in Firefox.

anyrun firef --new-window https://gitlab.com/caferen/anyrun: Opens anyruns repository in a new Firefox window.

anyrun <<< "firef --new-window https://gitlab.com/caferen/anyrun": Opens anyruns repository in a new Firefox window but cooler.

Commit count: 10

cargo fmt