Skip to content

Instantly share code, notes, and snippets.

@yrns
Forked from raine/ramda
Last active June 19, 2016 20:41
Show Gist options
  • Save yrns/17e70cc443bcafbdd7445acbf5bc64d8 to your computer and use it in GitHub Desktop.
Save yrns/17e70cc443bcafbdd7445acbf5bc64d8 to your computer and use it in GitHub Desktop.
Browse Ramda documentation in Terminal
#!/usr/bin/env bash
# Browse Ramda documentation in Terminal
# Requires jq and rofi for interactive filtering
LATEST="http://raine.github.io/ramda-json-docs/latest.json"
DOCS_URL="http://ramdajs.com/docs/"
cached=$XDG_CACHE_HOME/$(basename $LATEST)
if [[ ! -r "$cached" ]]; then
curl -s $LATEST -o $cached
fi
functions=$(cat $cached | jq -r '.[] | if .sig and (.sig | length > 0) then .name + " :: " + .sig + " (" + .category + ")" else .name end')
fn=$(echo "$functions" | rofi -fuzzy -eh 1 -dmenu) || exit 0
fn_name=$(echo $fn | awk '{print $1}')
desc=$(cat $cached | jq -r ".[] | select(.name == \"$fn_name\") | .description" | fmt)
docs_url="$DOCS_URL#$fn_name"
# C-M-. opens rofi again with URI
notify-send -u LOW "ramda -- $fn" "$desc\n\n>> $docs_url"
#xdg-open $docs_url # linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment