Get help and examples for commands from the command line, without switching context or applications.
Project description
hint
Hint exists to get help on commands from the command line, without switching context or applications.
Project status
This product is in nearly daily use by me, and probably me alone. For all intents and purposes this tool is completely unsupported. I make no guarantees about backwards compatibility or commitment to responding to issues or PRs. It is a personal project which I'm happy to share, as open source software licensed with the MIT license if you find it useful and/or want any changes I would suggest forking this repo.
Installation
Recommended installation method is with pipx.
pipx install hint-cli
Usage
The first time you run hint TOPIC
it will prompt for configuration values for the following:
- Repository for the hint source - Address of the remote git repository to clone containing your hint content. Use the sample repo from GitHub of
git@github.com:agarthetiger/hint-cli-samples.git
to get started. It is expected that you will create your own content and configure your own repo later. The only topic in the example repo isbash
. Note that while both the ssh and https clone addresses will work to view content, all functionality to add and modify content will require the ssh style repo address.
Then run hint TOPIC
where TOPIC is the name of a markdown file in the repository root, without the .md file extension.
eg.
hint bash
- Display the formatted contents of https://raw.githubusercontent.com/agarthetiger/hint/trunk/docs/examples/bash.mdhint bash curl
- Display only thecurl
subsection from the bash.md file. Valid subsections are any level headings in the markdown document. To display only an H4 subsection, just use the H4 heading text as the 2nd argument.hint --edit bash
- Edit the file bash.md using vim. This requires vim to be installed, the repo to be cloned using ssh, ssh key based authentication to github.com configured for the current user and no restrictions on pushing to the default branch. After an edit, all changes in the locally cloned repository will be added, committed to the local clone and then pushed to GitHub.hint --search pipx
- search for the string pipx as a topic or a string within all topic files.hint --help
- Get helphint --version
- Print the version of hint-cli
Tab completion for available TOPICs
Tab-completion of TOPICs can be enabled as follows
For Bash, add this to ~/.bashrc:
eval "$(_HINT_COMPLETE=source_bash hint)"
For Zsh, add this to ~/.zshrc:
eval "$(_HINT_COMPLETE=source_zsh hint)"
Open a new shell to enable completion. Or run the eval command directly in your current shell to enable it temporarily.
The above eval examples will invoke your application every time a shell is started. This may slow down shell startup time significantly.
Alternatively, export the generated completion code as a static script to be executed. You can ship this file with your builds; tools like Git do this. At least Zsh will also cache the results of completion files, but not eval scripts.
For Bash:
_HINT_COMPLETE=source_bash hint > hint-complete.sh
For Zsh:
_HINT_COMPLETE=source_zsh hint > hint-complete.sh
In .bashrc or .zshrc, source the script instead of the eval command:
. /path/to/hint-complete.sh
Upgrading
This project is still in a beta state and as such any version bumps may be breaking until 1.0.0 is released. When upgrading versions prior to v1.0.0 I recommend deleting the config file ~/.hintrc
before running the new version, so that the correct config options are set.
From 1.0.0 onwards, releases will be versioned semantically according to semver.org 2.0.0. Until then, minor version bumps may contain breaking changes.
Creating content
hint
is written for you to create your own content, for whatever useful information you would like to access from the command line. It is expected that you will setup your own repository with your own hints.
The repository is expected to contain markdown files with a .md file extension in the root of the repository. Each file name is considered a topic, and each heading a subsection. There is some basic formatting applied to the markdown before being displayed using Click's echo and style support.
- Section headings are displayed in bold and cyan.
- Text surrounded by ` characters is displayed in bold and blue.
- All other text is displayed as typed in the markdown file.
Once a repo has been setup and cloned via ssh from GitHub, new pages can be created by running hint --edit TOPIC
where TOPIC is the name of the file to create. The extension .md
will be added to the repo automatically and the new file pushed to GitHub after saving and exiting vim.
Switching hint repositories
Version 0.4.0 changes from using requests to query content directly from GitHub.com to using GitPython to clone the remote repository for the hint content. If you are using hint-cli >=v0.4.0 and want to change the remote repository, update the value for repo
in ~/.hintrc
and delete the folder ~/.hints.d/hints
and then run hint again.
Alternatives and comparisons
If you want a tool which pulls community content rather than writing your own, look at cheat.sh. It provides "unified access to the best community driven cheat sheets repositories of the world".
Another tool worth looking at is How Do I, with a question and answer format also from the command line.
Term Cheat is quite a similar tool, with one big list but in a text-based UI which supports searching for the command you want.
eg is another great tool with a lot of overlap with hint (and more maturity for sure). It has colourised output, a mix of pre-existing community content as well as the option to add your own examples, and a host of configuration possibilities.
cheat has a wonderful amount of community content ready to go.
Why does hint exist when there are all these other great tools?
- I want to curate my own content. Specifically I don't necessarily want a community-chosen example/answer and I don't want to have to justify what I want as an example in a PR.
- I wanted to be able to access my content from any machine with an internet connection, including but not limited to my work laptop, personal laptop, home lab Raspberry Pi hosts, etc.
- I want to add features I didn't see in any individual existing tool. I have seen almost everything implemented across all the alternative tools out there, and cherry-picked some features for use in hint. Thank you all open-source authors for sharing your ideas.
- I wanted to format the examples on the command line in a specific manner.
... and for completeness,
- When I started this I didn't know some of them existed.
- I wanted to write this myself as a project to continue to learn python so I would have done it anyway.
System Requirements
- Python >= 3.11
- Pip
- Access to pypi.org or another pip repo with the
hint-cli
python package and dependencies - Network access to the hints git repository. This may be internet access to GitHub.com but could also be an internal Git server.
Concept
I use GitHub Pages and MKDocs as well as other Notes applications to collect technical information which I personally find useful. I have a few cheat-sheets with reminders on commands I use regularly but infrequently. The man
and info
commands provide help on most commands, however they are very detailed and more useful commands often involve multiple cli tools. Examples bridge the gap between the low level documentation and complex infrequent commands which won't necessarily be in the command history for the current system.
Often I'm using a terminal within PyCharm or VS Code and it's undesirable to switch context to a different application, navigate to a site which may not be open, get the right page and click or scroll to the relevant section. It's not an insurmountable problem, but a workflow which I wanted to optimise.
This tool was inspired in multiple ways by Thomas Stringer's post on My Personal Wiki … Now Through the Terminal. The fact that I stumbled across this while searching for something else is validation for having a tool and workflow which enables me to remain in the IDE and not switch to a browser. It's similar to taking an alcoholic to a pub and constantly offering them a drink, then saying it's his fault if he ends up drinking. Sure, there is some level of personal responsibility with the alcoholic to resist but a better solution would be to avoid the pub. hint
keeps me focused, puts the information I need at my fingertips away from distractions.
Backlog of ideas for improvement
Err, it's vast. My ability to dream up cool things I could add to hint easily outstrips my available time to implement them. The ones I think are worthy of at least writing down will end up on the project page.
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file hint-cli-0.11.1.tar.gz
.
File metadata
- Download URL: hint-cli-0.11.1.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3722e9cda48b0940a55f73d12dc85ae3e0be3460a69d4c5a09023b7e53e986af |
|
MD5 | c0cf1d2133c47cee105e440badb11e6d |
|
BLAKE2b-256 | 890c30c8e6fde2f4091da31573465970f100c921c7a891fa3139a12523f098f0 |
File details
Details for the file hint_cli-0.11.1-py3-none-any.whl
.
File metadata
- Download URL: hint_cli-0.11.1-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6e579aad17d5f02f963c94bde306bdd4750be22ee5665ef330aab9a2eedf965 |
|
MD5 | 05b16ee5fca311fd82dd0f1b5b4bfa49 |
|
BLAKE2b-256 | 54533c255063a3ac231e5483f660c7f4b014457f598de9d7cbbc942a8ba39808 |