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
json
format as string array, which if needed can be easily processed. - Track hosted tips by adding them to remotes with
tips remtoe-add
command. 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
gum
is installed it formats tips nicely.
- required:
bash
or something that runs bashjq
- for managing db datasponge
frommoreutils
- 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/bash
For 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 it
You 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 oftips
is piped through this. Defaults togum format --theme=dark
ifgum
is present. I highly recommend usingglow
, butcat
is 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.json
that will be used to fetch tipstips import-remotes <url to remotes.json>
: adds all remotes from url hostingremotes.json
to 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 fetch
by 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.json
arraytips.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.json
in correct format and add the raw url (i.e. returning onlytips.json
, not html document) to your remotes viatips remote-add
command.[ "tip 1", "tip 2, in **markdown**, useful when displayed with formatter like __glow__" ]
- Host
tips.json
in 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 fetch
to 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
gh
is 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
gum
tools likegum select
- compare with
fortune
program? - 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.json
if 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
stow
for 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 👍