Simple utility for managing and printing helpful markdown tips in terminal. Essentially a simple wrapper utility for jq with pretty printing. Anything it does can be done manually on the json file as well. Supports fetching hosted tips and easily sharing knowledge!
Made by Tooster, licensed MIT, full license text at https://mit-license.org/
- Tips stored in a familiar
jsonformat as string array, which if needed can be easily processed. - Track hosted tips by adding them to remotes with
tips remtoe-addcommand. Remotes won't duplicate. - Easily fetch new and changed tips from tracked remotes with
tips fetch. Tips won't duplicate. - Easily import other's collections of tips by importing and mergin their remotes with
tips import-remotes. - If
gumis installed it formats tips nicely.
- required:
bashor something that runs bashjq- for managing db dataspongefrommoreutils- for updating dbcurl- for upgrades and fetching tips from remotes
- optional (recommended):
# Debian based (uses apt and bash language)
curl https://gist.githubusercontent.com/T3sT3ro/bc06294f51091c0e34176c62683d538e/raw/install.sh | /bin/bashFor manual installation copy tips executable into appropriate place and copy tips.json, remotes.json into ~/.local/share/tips/. Create empty current file in this directory as well.
To uninstall, simply remove those files:
rm -rf ~/.local/share/tips
rm $(which tips)
# and remove appropriate entries from .bashrc or wher eyou called itYou can use following environment variables to configure how tips (add them and export e.g. in .bashrc before calling tips):
TIPS_DIR- root location for tips data, defaults to~/.local/share/tips. Holdstips.json(tips database),remotes.json(remotes tracker) andcurrent(holding pointer to current tip)TIPS_FORMATTER- the output oftipsis piped through this. Defaults togum format --theme=darkifgumis present. I highly recommend usingglow, butcatis the default for safety.
Invoke in your .bashrc to print a tip on new terminal startup.
tips [next/current/previous]: select active tip and display ittips -h: print full help, show arguments and usagetips <n>: print n-th tip (modulo count), without changing active tiptips all: displays all tipstips stats: show number of entries, remotes and current tip indextips remote-add <name> <remote_url>: add remote toremotes.jsonthat will be used to fetch tipstips import-remotes <url to remotes.json>: adds all remotes from url hostingremotes.jsonto you remotestips fetch: fetch tips from tracked remotestips upgrade: upgrade the tips script
More info after using tips --help.
remotes.json: a single json object mapping urls to remote names. Keys and JSON spec enforce uniqueness. The tips database is rebuilt on eachtips fetchby merging respones from remotes.{ "https://someRemote.com/tips.json": "some descriptive remote name", "<url to another tips.json>": "<another remote name>" }current: managed bytips, a single file declaring a variable holding current tip index in thetips.jsonarraytips.json: a volatile (overwritten ontips fetch), single JSON array containing strings with tip's. Each entry is a single tip. To use your own tips I recommnd creating a public (private gists not supported yet, auth token would be required) gist fortips.jsonin correct format and add the raw url (i.e. returning onlytips.json, not html document) to your remotes viatips remote-addcommand.[ "tip 1", "tip 2, in **markdown**, useful when displayed with formatter like __glow__" ]
- Host
tips.jsonin some accessible place, for example https://gist.github.com. - Use
tips remote-add <name> <raw url to tips.json>to start tracking hostedtips.json. - Perform
tips fetchto fetch and update/merge in tips from the tracked remotes.
You can also import all remotes from someone else if they host remotes.json: tips import-remotes <url to remotes.json> will merge your remotes with their remotes.
- if
ghis installed, use api requests + glow to edit and add new tips remotely straight from the CLI - support some kidn of auth tokens/a method to send extra curl data to access scured private tips if needed.
gh auth - support editing/toggling remotes/tips with the help of
gumtools likegum select - compare with
fortuneprogram? - add version info and migrations scripts if db format ever changes (based on commit info?)
- 1:1 mapping between remote url and remote name to avoid duplicate urls/names
- add tip tags, with enabling/disabling tags and browsing a category
- local
tips-local.jsonif needed - not sure if I want to add that, I won't personaly use it and I deem them unnecessary if private tips can be used instead. - check out
stowfor easy installation
Feel free to leave any comments or suggestions ❤️
To the ones who shared their knowledge with me, and the authors of glow, gum, curl, jq and moreutils 👍
