Last active
June 15, 2025 14:24
-
-
Save thingsiplay/bc093fc431c6cf4f2584755862e1643a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
local="${HOME}/.config/retroarch" | |
repo='https://github.com/libretro/docs' | |
open='okular' | |
cd -- "${local}" || exit | |
if [[ "${1}" == '' ]]; then | |
mode="$(printf 'open\nupdate' | fzf)" | |
else | |
mode="${1}" | |
fi | |
if [[ "${mode}" == "update" ]]; then | |
if [[ -e "${local}/docs" ]]; then | |
cd docs || exit | |
git pull --depth 1 -- "${repo}" | |
else | |
git clone --depth 1 -- "${repo}" | |
fi | |
elif [[ "${mode}" == "open" ]]; then | |
cd docs || exit | |
if [[ "${2}" == '' ]]; then | |
category="$(find ./* -mindepth 1 -maxdepth 1 -type d -printf '%P\n' | | |
grep -v -E '(image|overrides|stylesheets)' | | |
sort | | |
fzf --reverse --preview 'ls -- docs/{}')" | |
else | |
category="${2}" | |
fi | |
if [[ ! "${category}" == '' ]]; then | |
selection="$(find "docs/${category}" -type f -iname '*.md' | | |
sed "s+docs/${category}/++" | | |
sort | | |
fzf --reverse --preview "cat -- docs/${category}/{}")" | |
input_file="docs/${category}/${selection}" | |
if [[ ! "${selection}" == '' ]]; then | |
realpath "${input_file}" | |
"${open}" "${input_file}" | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment