This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/.local/bin/dmenuopen

24 lines
532 B
Bash
Executable File

#! /bin/sh
# Fuzzy-find a file and open it with appropriate application
filetypes=".pdf .png .jpg .txt .mom .tex .mkv" # could be augmented
filetype=\\$(printf "$filetypes" | sed "s| |\n|g" | dmenu -i -p "type of the file?")
if [ -z "$filetype" ]; then
exit 0
fi
file=$(find $HOME/ -type f | grep "$filetype" | dmenu -i -l 20 -p "open")
if [ -z "$file" ]; then
exit 0
fi
case "$filetype" in
*.pdf) zathura "$file" ;;
*.png|.jpg) feh "$file" ;;
*.txt|*.mom|*.tex) "$TERMINAL" -e nvim "$file" ;;
*.mkv) mpv "$file";;
esac