├── .gitignore ├── LICENSE ├── MANIFEST.in ├── Pypi_README.md ├── README.md ├── assets ├── issue1.png ├── preview_cheatshh_1.mov └── preview_cheatshh_2.mov ├── cheatshh ├── __init__.py ├── cheats.sh ├── cheatshh.toml ├── commands.json ├── groups.json └── main.py ├── docs ├── cheatshh_configurations.md ├── man │ └── cheatshh.1 └── tldr │ └── cheatshh.md ├── library ├── Games │ ├── commands.json │ └── groups.json ├── General Commands │ ├── commands.json │ └── groups.json ├── Pypi Publishing │ ├── commands.json │ └── groups.json ├── README.md ├── Terminal Show off │ ├── commands.json │ └── groups.json ├── Terminal Utilities │ ├── commands.json │ └── groups.json ├── docker │ ├── commands.json │ └── groups.json └── git │ ├── commands.json │ └── groups.json ├── pyproject.toml └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | cheatshh.egg-info 2 | dist 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include cheats.sh 2 | include commands.json 3 | include groups.json 4 | include cheatshh.toml -------------------------------------------------------------------------------- /Pypi_README.md: -------------------------------------------------------------------------------- 1 | # cheatshh 2 | 3 | Cheatshh is an interactive CLI meant for managing command line cheatsheets. Now you don't have to remember CLI commands and just refer your cheatsheet. You can group commands and view their TLDR and MAN pages along with a custom description for the command. 4 | 5 | # Features 6 | 7 | - Comprehensive cheatsheets for various command-line utilities and tools. 8 | - Easy-to-use interface for quickly accessing and executing commands, powered by fuzzy finder(fzf) and whiptail. 9 | - Customizable cheatsheets and groups to suit your needs. 10 | - TLDR and MAN pages visible in the preview. 11 | - Easy to add, edit, delete commands and groups and playing around. 12 | - Press Enter on a command to copy it to clipboard and exit. 13 | - Bookmark your favourite commands and view them in main preview despite being in a group. 14 | - Change configurations like colors, automatic man page display, usages of other cheatsheets like tldr, cheats.sh, etc. 15 | 16 | Visit the Github Repository for more details: https://github.com/AnirudhG07/cheatshh 17 | 18 | # Version 19 | 1.1.1 20 | 21 | ## Note: 22 | - This package is best used in Unix based systems, like linux and MacOS. For Windows, see the github repository for more details. 23 | - The package is installed in ~/.config/cheatshh directory. 24 | 25 | ## New Features: 26 | - You can now change various configurations of cheatshh like color_schemes, copy command to use, etc. 27 | - You can change the cheatsheet tool you are using from tldr(default) to cheats.sh, cheatsheet, bropages, etc. 28 | - You can automate the display of man pages for commands. 29 | - You can configure your main preview with group_name/group_command way to find your command really fast. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cheatshh ![Static Badge](https://img.shields.io/badge/version-1.1.1-blue) 2 | 3 | Cheatshh is an interactive CLI meant for managing command line cheatsheets, written in shell script. Now you don't have to remember CLI commands and just refer your cheatsheet. You can group commands and view their TLDR(or anyother) and MAN pages along with a custom description for the command. 4 |
5 | 6 | > **Note:** This software is tested on and initially configured for MacOS. Please check out the [configuration documentation] to set it up for your system. 7 | 8 | ## Table of Contents 9 | 10 | * [Preview/Screenshots ](#previewscreenshots-) 11 | * [Features](#features) 12 | * [Installation](#installation) 13 | * [Pip Installation](#pip-installation) 14 | * [Homebrew Installation](#homebrew-installation) 15 | * [Manual Installation through git clone](#manual-installation-through-git-clone) 16 | * [For MacOS and Linux](#for-macos-and-linux) 17 | * [For Windows](#for-windows) 18 | * [Libraries and Groups](#libraries-and-groups) 19 | * [Bookmarking](#bookmarking) 20 | * [Dependencies](#dependencies) 21 | * [Cheatshh Configuration](#cheatshh-configuration) 22 | * [Saving cheatshh](#saving-cheatshh) 23 | * [Trouble-shooting](#trouble-shooting) 24 | * [Documentation](#documentation) 25 | * [Check it out](#check-it-out) 26 | * [Contributing](#contributing) 27 | * [Contribution Guidelines](#contribution-guidelines) 28 | 29 | 30 | # Preview/Screenshots  31 | 32 | https://github.com/AnirudhG07/cheatshh/assets/146579014/d064f201-2b2f-46b3-a341-7b913646e4ef 33 | 34 | # Features 35 | 36 | - Comprehensive cheatsheets for various command-line utilities and tools. 37 | - Easy-to-use interface for quickly accessing and executing commands, powered by fuzzy finder(fzf) and whiptail. 38 | - Customizable cheatsheets and groups to suit your needs. 39 | - TLDR(any more) and MAN pages visible in the preview. 40 | - Easy to add, edit, delete commands & groups and play around. 41 | - Bookmark commands to access them outside of group as well. 42 | - Change configurations like colors, automatic man page display, usages of other cheatsheets like tldr, cheats.sh, etc. 43 | 44 | # Installation 45 | 46 | The following installation guidelines hold for Linux and MacOS.
47 | You can download cheatshh through following ways- (more will be added soon) 48 | 49 | ## Pip Installation 50 | 51 | Before running the below commands, make sure your dependencies are satisfied. See the DEPENDENCIES section for more info. 52 | From your command line, run- 53 | 54 | ```bash 55 | pip install cheatshh 56 | ``` 57 | 58 | This will create ~/.config/cheatshh in your home directory. Now simply run- 59 | 60 | ```bash 61 | cheatshh 62 | ``` 63 | 64 | and you are done. Use various options to add, edit and delete commands and groups. 65 | 66 | ## Homebrew Installation 67 | 68 | This tool can also be installed using Homebrew(for MacOS only). You can install it by tapping my homebrew-tap repo and installing the tool. 69 | 70 | ```bash 71 | brew install AnirudhG07/AnirudhG07/cheatshh 72 | ``` 73 | 74 | You can now run the tool by running `cheatshh -h` in your terminal. If you are facing issues, try running- 75 | 76 | ```bash 77 | brew tap AnirudhG07/AnirudhG07 78 | brew install cheatshh 79 | ``` 80 | 81 | Make sure you have Homebrew installed in your MacOS and it is updated which can be done by running `brew update`. 82 | 83 | ## Manual Installation through git clone 84 | 85 | You can setup manual installation with the following guidelines- 86 | 87 | ### For MacOS and Linux 88 | 89 | 1. Clone the repository 90 | 91 | ```bash 92 | git clone https://github.com/AnirudhG07/cheatshh 93 | ``` 94 | 95 | 2. Navigate to the project directory run below if downloaded in home directory 96 | 97 | ```bash 98 | cd ~/cheatshh 99 | ``` 100 | 101 | 3. Install the requirements through 102 | 103 | ``` 104 | pip install -r requirements.txt 105 | ``` 106 | 107 | 4. (optional) Make sure you have `poetry` installed which will be required to build the project. If not you can run either of the below commands- 108 | ```bash 109 | pip install poetry 110 | # OR 111 | curl -sSL https://install.python-poetry.org | python - 112 | ``` 113 | This will download `peotry`. Now you can proceed to the next step. 114 | 115 | 5. Run the below code to set cheatshh 116 | 117 | ```bash 118 | pip install . 119 | ``` 120 | 121 | Now you should be able to use the tool by running `cheatshh` in your terminal. Feel free to raise an issue if any error comes up. 122 | 123 | ## For Windows 124 | 125 | For Windows, you can use Virtual Machines of Linux, or change configurations manually.
126 | > From version >= 1.1.1, the configurations for having `cheatshh` on Windows has greatly been improved. 127 | 128 | - Change the path to directory `~/.config/cheatshh` to `absolute/path/to/your/directory/cheatshh`, by using grep command in the cheatshh directory, in `cheatshh.toml` and `cheats.sh` only at the one place. 129 | 130 | - This should run cheatshh appropriately. Make sure the dependencies are installed, since they are easily available for Unix applications. 131 | 132 | # Libraries and Groups 133 | 134 | You can create custom groups using- 135 | 136 | ```bash 137 | cheatshh -g 138 | ``` 139 | 140 | We also have premade libraries of groups here which you can download with the instructions given there itself.
141 | We welcome you to publish your own libraries for everyone to see. 142 | 143 | # Bookmarking 144 | Bookmarking let's you save your command in the main preview despite them being present in a group.
145 | You can bookmark a command by pressing Enter and selecting `Bookmark`. Now you don't need to find it in a group and access it in the main preview.
You can always remove Bookmark of a command by pressing Enter and selecting `Remove Bookmark`. 146 | 147 | # Dependencies 148 | 149 | Cheatshh uses the following as its main tools. Ensure that these are pre-installed in your computer. 150 | 151 | - fuzzy finder(fzf) 152 | - whiptail 153 | - jq 154 | - yq 155 | **NOTE:** jq and yq used in the package is the version present in Homebrew. Thus please install that instead of from Pypi.(It didn't work for me.)
156 | 157 | In MacOS, you can use HomeBrew to install the above packages with- 158 | 159 | ```bash 160 | brew install 161 | ``` 162 | 163 | For MacOS & Linux both, you can run the following command to download the packages. 164 | 165 | ```bash 166 | sudo apt install 167 | ``` 168 | 169 | For Windows, you can use your favourite package manager or download from their website itself. 170 | 171 | # Cheatshh Configuration 172 | You can change various configurations of cheatshh like colors, automatic man page display, usages of other cheatsheets like tldr, cheats.sh, etc. You can do this by going to the `cheatshh/cheatshh.toml` file and changing the values as per your needs.
173 | **NOTE:** All the instructions on how to change suitably is mentioned within the file itself. If you are facing any issues, feel free to raise an issue. 174 | 175 | # Saving cheatshh 176 | When you have configured your cheatshh, you would definitely want to save them. If you want to use cheatshh in some different machine without rewriting again(cause that's a lot of trouble). Here's how you can save it. 177 | 1. Make a repository by the name `Your_handle/cheatshh` or any other name. You can also add it to your repo where you are storing your dot files. 178 | 2. You can use `stow` command to configure everything in an instant. Here's the layout of the directory if you will use stow- 179 | 180 | ```markdown 181 | cheatshh 182 | └─── .config 183 | └── cheatshh 184 | ├── cheats.sh 185 | ├── commands.json 186 | ├── groups.json 187 | └── any/other/file 188 | ``` 189 | 190 | Now you can simply download this directory, run `stow cheatshh`, this will setup your cheatshh in the `.config/cheatshh` as it should be.
191 | OR you can manually set it up, in that case you don't need the above tree, you can simply use have the last level of tree inside cheatshh directory. 192 |
193 | 194 | Don't forget to make `setup.sh` executable. 195 | 196 | # Trouble-shooting 197 | 1. If you are facing issues with `jq` and `yq`, please try the following first - 198 | - Add ABSOLUTE PATH of your `.config/cheatshh` in the `cheatshh.toml` and `cheats.sh` file as pointed [for Windows](#for-windows) 199 | - The jq and yq used in the packages is from Homebrew and Pypi yq would not work. So make sure you have that `jq` and `yq` installed. 200 | 201 | 2. If permission denial error shows up, run the same command using sudo. You will have to provide password in this case. 202 | 203 | ```bash 204 | sudo 205 | ``` 206 | 207 | This might be needed in the case for man page display or maybe for installation of dependency. 208 | 209 | 3. If `WARNING: The script cheatshh is installed in '/home/admin/.local/bin' which is not on PATH.` error comes, then cheatshh script has to be included in the system PATH, you can add the following lines to the appropriate shell configuration. 210 | 211 | - BASH: Add the following at the end of ~/.bashrc 212 | 213 | ```bash 214 | export PATH="$HOME/.local/bin:$PATH" 215 | ``` 216 | 217 | - ZSH: Add the following at the end of ~/.zshrc 218 | 219 | ```bash 220 | export PATH="$HOME/.local/bin:$PATH" 221 | ``` 222 | 223 | After adding these lines, either restart your terminal or run source on the respective configuration file to apply the changes. For example: 224 | 225 | ```bash 226 | source ~/.bashrc # For Bash 227 | source ~/.zshrc # For Zsh 228 | ``` 229 | 230 | This should add the path in your `shell-rc` file and you should be able to run.
231 | Note: If you are using some other shell like fish or any similar other, configure the settings accordingly. Using Fish is not recommended for this tool. 232 | 233 | # Documentation 234 | 235 | Cheatshh is an interactive, easy CLI tool to maintain your custom cheatsheets. You can check our the docs to see how to use cheatshh. 236 | 237 | # Check it out 238 | Check out my Yazi File manager plugin for cheatshh at [cheatshh.yazi](https://github.com/AnirudhG070/plugins-yazi/tree/main/cheatshh.yazi). You can save your yazi shell commands and easily access them within Yazi. 239 | 240 | # Contributing 241 | 242 | I would love to take contributions from the community! If you have suggestions for new cheatsheets, improvements to existing ones, or bug fixes, please feel free to submit a pull request. 243 | ### Contribution Guidelines 244 | 1) For contribution of a library, it should have a suitable folder name(max 3 words) with commands.json and groups.json, similar to the format in other libraries. The `group` field should be "yes", `bookmark` field should be "no". 245 | 2) For bug fixes, it will be great if you could discuss first in Issues before directly putting a PR. 246 | 3) It would be great to publish this in other package managers. So I would request help for publishing to different package managers. 247 | -------------------------------------------------------------------------------- /assets/issue1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AnirudhG07/cheatshh/c0f469864042f913d21cd15e73fd882930486c8b/assets/issue1.png -------------------------------------------------------------------------------- /assets/preview_cheatshh_1.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AnirudhG07/cheatshh/c0f469864042f913d21cd15e73fd882930486c8b/assets/preview_cheatshh_1.mov -------------------------------------------------------------------------------- /assets/preview_cheatshh_2.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AnirudhG07/cheatshh/c0f469864042f913d21cd15e73fd882930486c8b/assets/preview_cheatshh_2.mov -------------------------------------------------------------------------------- /cheatshh/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AnirudhG07/cheatshh/c0f469864042f913d21cd15e73fd882930486c8b/cheatshh/__init__.py -------------------------------------------------------------------------------- /cheatshh/cheats.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | NC='\033[0m' # No Color 4 | export NC 5 | 6 | ## Read from cheatshh.toml 7 | getConfigValue() { 8 | local section=$1 9 | local key=$2 10 | local config_file="$HOME/.config/cheatshh/cheatshh.toml" 11 | 12 | yq ".$section.$key" "$config_file" 13 | } 14 | copy_command=$(getConfigValue "settings" "copy_command") 15 | display_man=$(getConfigValue "settings" "man_pages") 16 | display_group_number=$(getConfigValue "settings" "display_group_number") 17 | cheatshh_home=$(getConfigValue "settings" "cheatshh_home") 18 | cheatshh_json="${cheatshh_home/#\~/$HOME}" 19 | notes=$(getConfigValue "settings" "notes") 20 | notes_name=$(echo "${notes}" | awk '{print $1}') # to extract the cheatsheet name like tldr from "tldr --color" 21 | 22 | full_display=$(getConfigValue "settings" "full_display") 23 | preview_width=$(getConfigValue "settings" "preview_width") 24 | 25 | title_color=$(getConfigValue "color_scheme" "title_color") 26 | about_color=$(getConfigValue "color_scheme" "about_color") 27 | 28 | # function for displaying group names when needed 29 | get_group_names() { 30 | group_names=$(jq -r 'keys[]' "$cheatshh_json/groups.json") 31 | group_names=$(echo "$group_names" | head -n $display_group_number | tr '\n' ',' | sed 's/,$//' | sed 's/,/, /g') 32 | 33 | if [ $(jq -r 'keys | length' "$cheatshh_json/groups.json") -gt $display_group_number ]; then 34 | group_names="$group_names, ..." 35 | fi 36 | 37 | echo "$group_names" 38 | } 39 | 40 | # Check for flags 41 | ### ADDITION ### 42 | addition(){ 43 | while true; do 44 | new_command=$(whiptail --inputbox "Enter new command: (Press TAB to select Ok/Cancel)" 8 78 --title "Add Command" 3>&1 1>&2 2>&3) 45 | 46 | exit_status=$? 47 | if [ $exit_status = 1 ]; then 48 | exit 1 49 | fi 50 | 51 | # Check if command is empty or contains spaces 52 | if [[ -z "$new_command" ]] || [[ "$new_command" =~ ^[[:space:]] ]]; then 53 | whiptail --msgbox "INVALID COMMAND ENTRY: $new_command\nThe command should not be \"\" or begin with \" \" character." 8 78 --title "Error" 54 | continue 55 | fi 56 | 57 | # Check if command already exists in the JSON file 58 | if jq --arg cmd "$new_command" 'has($cmd)' "$cheatshh_json/commands.json" | grep -q true; then 59 | if ! whiptail --yesno "Command already there. Would you like to re-enter?" 8 78 --title "Confirmation"; then 60 | exit 1 61 | fi 62 | continue 63 | fi 64 | 65 | # Ask if it is an alias 66 | if whiptail --yesno "Is the command an alias?" 8 78 --title "Confirmation"; then 67 | is_alias="yes" 68 | description=$(whiptail --inputbox "Enter description for the command: (use '\ n' for new line)" 8 78 --title "Add Command Description" 3>&1 1>&2 2>&3) 69 | else 70 | is_alias="no" 71 | # Check if $notes page for the command exists 72 | if ! $notes $new_command> /dev/null 2>&1; then 73 | # Check if man page for the command exists 74 | if ! man $new_command > /dev/null 2>&1; then 75 | whiptail --msgbox "Error: Neither man page nor $notes_name exists for the command: $new_command\nPlease add it as an alias." 8 78 --title "Error" 76 | continue 77 | fi 78 | fi 79 | description=$(whiptail --inputbox "Enter description for the command: (use '\ n' for new line)" 8 78 --title "Add Command Description" 3>&1 1>&2 2>&3) 80 | fi 81 | 82 | # Ask if the command should be added to a group 83 | if whiptail --yesno "Do you want to add the command to a group?" 8 78 --title "Confirmation"; then 84 | group=$(whiptail --inputbox "Enter the name of the group: (Press TAB to select Ok/Cancel)\n\nAvailable groups: $(get_group_names)" 12 78 --title "Add to Group" 3>&1 1>&2 2>&3) 85 | # Check if the group exists 86 | if [ "$(jq -r --arg group "$group" '.[$group]' "$cheatshh_json/groups.json")" != "null" ]; then 87 | # Add the command to the group 88 | jq --arg group "$group" --arg cmd "$new_command" '.[$group].commands += [$cmd]' "$cheatshh_json/groups.json" > "$cheatshh_json/temp.json" && mv "$cheatshh_json/temp.json" "$cheatshh_json/groups.json" 89 | # Update the commands.json file 90 | jq --arg cmd "$new_command" --arg desc "$description" --arg alias "$is_alias" '.[$cmd] = {"description": $desc, "alias": $alias, "group": "yes", "bookmark": "no"}' "$cheatshh_json/commands.json" > "$cheatshh_json/temp.json" && mv "$cheatshh_json/temp.json" "$cheatshh_json/commands.json" 91 | else 92 | whiptail --msgbox "Group does not exist: $group" 8 78 --title "Error" 93 | continue 94 | fi 95 | else 96 | # If not added to a group, update the commands.json file with group as "no" 97 | jq --arg cmd "$new_command" --arg desc "$description" --arg alias "$is_alias" '.[$cmd] = {"description": $desc, "alias": $alias, "group": "no", "bookmark": "no"}' "$cheatshh_json/commands.json" > "$cheatshh_json/temp.json" && mv "$cheatshh_json/temp.json" "$cheatshh_json/commands.json" 98 | fi 99 | 100 | break 101 | done 102 | } 103 | ### DELETION ### 104 | deletion_command() { 105 | cmd_name=$(whiptail --inputbox "Enter name of the command to delete:" 8 78 --title "Delete Command" 3>&1 1>&2 2>&3) 106 | 107 | exit_status=$? 108 | if [ $exit_status = 1 ]; then 109 | return 110 | fi 111 | 112 | # Check if the command exists 113 | if [ "$(jq -r --arg cmd "$cmd_name" '.[$cmd]' "$cheatshh_json/commands.json")" == "null" ]; then 114 | whiptail --msgbox "Command does not exist: $cmd_name" 8 78 --title "Error" 115 | exit 1 116 | fi 117 | 118 | # Check if the command is in any group 119 | if [ "$(jq -r --arg cmd "$cmd_name" '.[$cmd].group' "$cheatshh_json/commands.json")" == "no" ]; then 120 | # If the command is not in any group, ask for confirmation before deleting 121 | if (whiptail --yesno "Are you sure you want to delete the command: $cmd_name?" 8 78 --title "Confirmation"); then 122 | # Delete the command 123 | jq --arg cmd "$cmd_name" 'del(.[$cmd])' "$cheatshh_json/commands.json" > "$cheatshh_json/temp.json" && mv "$cheatshh_json/temp.json" "$cheatshh_json/commands.json" 124 | fi 125 | else 126 | # Get the list of group names 127 | group_name=$(whiptail --inputbox "Enter name of the group to delete the command from:\n\nAvailable groups: $(get_group_names)" 12 78 --title "Delete Command from Group" 3>&1 1>&2 2>&3) 128 | exit_status=$? 129 | if [ $exit_status = 1 ]; then 130 | return 131 | fi 132 | 133 | # Check if the group exists 134 | if [ "$(jq -r --arg group "$group_name" '.[$group]' "$cheatshh_json/groups.json")" == "null" ]; then 135 | whiptail --msgbox "Group does not exist: $group_name" 8 78 --title "Error" 136 | exit 1 137 | fi 138 | 139 | # Delete the command from the group 140 | jq --arg group "$group_name" --arg cmd "$cmd_name" '(.[$group].commands[] | select(. == $cmd)) = null | del(.[$group].commands[] | nulls)' "$cheatshh_json/groups.json" > "$cheatshh_json/temp.json" && mv "$cheatshh_json/temp.json" "$cheatshh_json/groups.json" 141 | fi 142 | } 143 | ### EDITING ### 144 | edit_command(){ 145 | exit_status=$? 146 | if [ $exit_status = 1 ]; then 147 | return 148 | fi 149 | exit_status=0 150 | while [ $exit_status -eq 0 ]; do 151 | edit_command=$(whiptail --inputbox "Enter command to edit: (Press TAB to select Ok/Cancel)" 8 78 --title "Edit Command" 3>&1 1>&2 2>&3) 152 | exit_status=$? 153 | 154 | # Check if command exists in the JSON file 155 | if [ $exit_status -eq 0 ]; then 156 | # Check if command exists in the JSON file 157 | if jq --arg cmd "$edit_command" 'has($cmd)' "$cheatshh_json/commands.json" | grep -q false; then 158 | whiptail --msgbox "Command not found: $edit_command" 8 78 --title "Error" 159 | continue 160 | fi 161 | 162 | OPTION=$(whiptail --title "Edit Command" --menu "Choose your option" 15 60 4 \ 163 | "1" "Change description" \ 164 | "2" "Change group" 3>&1 1>&2 2>&3) 165 | exit_status=$? 166 | 167 | # Check if the Cancel button was pressed 168 | if [ $exit_status -ne 0 ]; then 169 | continue 170 | fi 171 | fi 172 | 173 | case $OPTION in 174 | 1) 175 | # Change description 176 | current_description=$(jq -r --arg cmd "$edit_command" '.[$cmd].description' "$cheatshh_json/commands.json") 177 | new_description=$(whiptail --title "Edit Command Description" --inputbox "Current description: $current_description\n\nEnter new description for the command: (use '\ n' for new line)" 10 78 3>&1 1>&2 2>&3) 178 | exit_status=$? 179 | 180 | # Update the description in the JSON file only if the OK button was pressed 181 | if [ $exit_status -eq 0 ]; then 182 | jq --arg cmd "$edit_command" --arg desc "$new_description" '(.[$cmd].description) = $desc' "$cheatshh_json/commands.json" > tmp.json && mv tmp.json "$cheatshh_json/commands.json" 183 | fi 184 | ;; 185 | 2) 186 | 187 | new_group=$(whiptail --inputbox "Enter the new group for the command: (Press TAB to select Ok/Cancel)\n\nAvailable groups: $(get_group_names)" 12 78 --title "Edit Command Group" 3>&1 1>&2 2>&3) # Check if the group exists 188 | if [ "$(jq -r --arg group "$new_group" '.[$group]' "$cheatshh_json/groups.json")" == "null" ]; then 189 | whiptail --msgbox "Group does not exist: $new_group" 8 78 --title "Error" 190 | continue 191 | fi 192 | 193 | # Check if the command already exists in the group 194 | if jq --arg group "$new_group" --arg cmd "$edit_command" '.[$group].commands | index($cmd)' "$cheatshh_json/groups.json" | grep -q null; then 195 | # Update the group of the command in the commands.json file 196 | jq --arg cmd "$edit_command" --arg group "$new_group" '(.[$cmd].group) = $group' "$cheatshh_json/commands.json" > "$cheatshh_json/temp.json" && mv "$cheatshh_json/temp.json" "$cheatshh_json/commands.json" 197 | # Add the command to the new group in the groups.json file 198 | jq --arg group "$new_group" --arg cmd "$edit_command" '.[$group].commands += [$cmd]' "$cheatshh_json/groups.json" > "$cheatshh_json/temp.json" && mv "$cheatshh_json/temp.json" "$cheatshh_json/groups.json" 199 | else 200 | whiptail --msgbox "Command already exists in the group! Please recheck the group you want it to add in." 8 78 --title "Error" 201 | continue 202 | fi 203 | ;; 204 | esac 205 | done 206 | } 207 | 208 | edit_group() { 209 | # Get the list of group names 210 | group_names=$(jq -r 'keys[]' "$cheatshh_json/groups.json") 211 | 212 | # Limit the number of group names to display 213 | group_names=$(echo "$group_names" | head -n 10 | tr '\n' ',' | sed 's/,$//' | sed 's/,/, /g') 214 | 215 | if [ $(jq -r 'keys | length' "$cheatshh_json/groups.json") -gt 10 ]; then 216 | group_names="$group_names, ..." 217 | fi 218 | 219 | while true; do 220 | # Ask for the group name 221 | group_name=$(whiptail --inputbox "Enter group name to edit: (Press TAB to select Ok/Cancel)\n\nYour Groups:\n$group_names" 16 78 --title "Edit Group" 3>&1 1>&2 2>&3) 222 | 223 | # Check if the user pressed Cancel or entered an empty string 224 | if [ $? -ne 0 ] || [ -z "$group_name" ]; then 225 | return 226 | fi 227 | 228 | # Check if the group exists in the JSON file 229 | if [ "$(jq -r --arg group "$group_name" '.[$group]' "$cheatshh_json/groups.json")" == "null" ]; then 230 | whiptail --msgbox "Group does not exist: $group_name" 8 78 --title "Error" 231 | continue 232 | fi 233 | 234 | # Ask what the user wants to edit 235 | OPTION=$(whiptail --title "Edit Group" --menu "Choose your option" 15 60 4 \ 236 | "1" "Edit group name" \ 237 | "2" "Edit group description" 3>&1 1>&2 2>&3) 238 | 239 | exitstatus=$? 240 | if [ $exitstatus = 0 ]; then 241 | case $OPTION in 242 | 1) 243 | # Ask for the new group name 244 | new_group_name=$(whiptail --inputbox "Enter new group name:" 8 78 --title "Edit Group Name" 3>&1 1>&2 2>&3) 245 | # Update the group name in the JSON file 246 | jq --arg group "$group_name" --arg newGroup "$new_group_name" ' 247 | .[$newGroup] = .[$group] | 248 | del(.[$group])' "$cheatshh_json/groups.json" > "$cheatshh_json/temp.json" && mv "$cheatshh_json/temp.json" "$cheatshh_json/groups.json" 249 | ;; 250 | 2) 251 | # Get the current group description 252 | current_group_description=$(jq -r --arg grp "$group_name" '.[$grp].description' "$cheatshh_json/groups.json") 253 | 254 | # Ask for the new group description 255 | new_group_description=$(whiptail --title "Edit Group Description" --inputbox "Current description: $current_group_description\n\nEnter new description for the group: (use '\ n' for new line)" 10 78 3>&1 1>&2 2>&3) 256 | 257 | exitstatus=$? 258 | if [ $exitstatus = 0 ]; then 259 | # Update the group description in the JSON file 260 | jq --arg group "$group_name" --arg newDesc "$new_group_description" '(.[$group].description = $newDesc)' "$cheatshh_json/groups.json" > "$cheatshh_json/temp.json" && mv "$cheatshh_json/temp.json" "$cheatshh_json/groups.json" 261 | fi 262 | ;; 263 | esac 264 | else 265 | echo "You chose Cancel." 266 | fi 267 | 268 | # Ask if the user wants to edit another group 269 | if ! (whiptail --yesno "Do you want to edit another group?" 8 78 --title "Confirmation"); then 270 | break 271 | fi 272 | done 273 | } 274 | 275 | create_group() { 276 | group_name=$(whiptail --inputbox "Enter name of the new group:" 8 78 --title "Create Group" 3>&1 1>&2 2>&3) 277 | 278 | exit_status=$? 279 | if [ $exit_status = 1 ]; then 280 | return 281 | fi 282 | 283 | # Check if the group already exists 284 | if [ "$(jq -r --arg group "$group_name" '.[$group]' "$cheatshh_json/groups.json")" != "null" ]; then 285 | whiptail --msgbox "Group already exists: $group_name" 8 78 --title "Error" 286 | exit 1 287 | fi 288 | 289 | # Ask for the group description 290 | group_description=$(whiptail --inputbox "Enter description of the new group: (use '\ n' for new line)" 8 78 --title "Create Group" 3>&1 1>&2 2>&3) 291 | 292 | exit_status=$? 293 | if [ $exit_status = 1 ]; then 294 | return 295 | fi 296 | 297 | # Add the group to the groups.json file with the description 298 | jq --arg group "$group_name" --arg desc "$group_description" '.[$group] = {"description": $desc, "commands": []}' "$cheatshh_json/groups.json" > "$cheatshh_json/temp.json" && mv "$cheatshh_json/temp.json" "$cheatshh_json/groups.json" 299 | 300 | # Ask the user if they want to add a command to the group 301 | if whiptail --yesno "Do you want to add a command to the group?" 8 78 --title "Add Command to Group"; then 302 | while true; do 303 | new_command=$(whiptail --inputbox "Enter new command: (Press TAB to select Ok/Cancel)" 8 78 --title "Add Command" 3>&1 1>&2 2>&3) 304 | 305 | exit_status=$? 306 | if [ $exit_status = 1 ]; then 307 | exit 1 308 | fi 309 | 310 | # Check if command is empty or contains spaces 311 | if [[ -z "$new_command" ]] || [[ "$new_command" =~ ^[[:space:]] ]]; then 312 | whiptail --msgbox "INVALID COMMAND ENTRY: $new_command\nThe command should not be \"\" or begin with \" \" character." 8 78 --title "Error" 313 | continue 314 | fi 315 | 316 | # Ask if it is an alias 317 | if whiptail --yesno "Is the command an alias?" 8 78 --title "Confirmation"; then 318 | is_alias="yes" 319 | description=$(whiptail --inputbox "Enter description for the command: (use '\ n' for new line)" 8 78 --title "Add Command Description" 3>&1 1>&2 2>&3) 320 | # Update the commands.json file 321 | jq --arg cmd "$new_command" --arg desc "$description" --arg alias "$is_alias" '.[$cmd] = {"description": $desc, "alias": $alias, "group": "no", "bookmark": "no"}' "$cheatshh_json/commands.json" > "$cheatshh_json/temp.json" && mv "$cheatshh_json/temp.json" "$cheatshh_json/commands.json" 322 | else 323 | is_alias="no" 324 | # Check if $notes page for the command exists 325 | if ! $notes $new_command > /dev/null 2>&1; then 326 | # Check if man page for the command exists 327 | if ! man $new_command > /dev/null 2>&1; then 328 | whiptail --msgbox "Neither man page nor $notes_name exists for the command: $new_command" 8 78 --title "Error" 329 | continue 330 | fi 331 | fi 332 | description=$(whiptail --inputbox "Enter description for the command: (use '\ n' for new line)" 8 78 --title "Add Command Description" 3>&1 1>&2 2>&3) 333 | # Update the commands.json file 334 | jq --arg cmd "$new_command" --arg desc "$description" --arg alias "$is_alias" '.[$cmd] = {"description": $desc, "alias": $alias, "group": "no", "bookmark": "no"}' "$cheatshh_json/commands.json" > "$cheatshh_json/temp.json" && mv "$cheatshh_json/temp.json" "$cheatshh_json/commands.json" 335 | fi 336 | break 337 | done 338 | fi 339 | } 340 | 341 | delete_group() { 342 | # Ask for the group name 343 | group_name=$(whiptail --inputbox "Enter name of the group to delete:\n\nYour Groups:\n$(get_group_names)" 16 78 --title "Delete Group" 3>&1 1>&2 2>&3) 344 | 345 | exit_status=$? 346 | if [ $exit_status = 1 ]; then 347 | return 348 | fi 349 | 350 | # Check if the group exists 351 | if [ "$(jq -r --arg group "$group_name" '.[$group]' "$cheatshh_json/groups.json")" == "null" ]; then 352 | whiptail --msgbox "Group does not exist: $group_name" 8 78 --title "Error" 353 | exit 1 354 | fi 355 | 356 | # Ask for confirmation before deleting 357 | if (whiptail --yesno "Are you sure you want to delete the group: $group_name?" 8 78 --title "Confirmation"); then 358 | # Get the commands in the group 359 | group_commands=$(jq -r --arg group "$group_name" '.[$group].commands[]' "$cheatshh_json/groups.json") 360 | 361 | # Delete the group 362 | jq --arg group "$group_name" 'del(.[$group])' "$cheatshh_json/groups.json" > "$cheatshh_json/temp.json" && mv "$cheatshh_json/temp.json" "$cheatshh_json/groups.json" 363 | 364 | # Delete the commands in the group from commands.json, unless they are also in another group 365 | for cmd in $group_commands; do 366 | if ! jq -r --arg cmd "$cmd" 'to_entries[] | select(.value.commands[] == $cmd) | .key' "$cheatshh_json/groups.json" | grep -q .; then 367 | jq --arg cmd "$cmd" 'del(.[$cmd])' "$cheatshh_json/commands.json" > "$cheatshh_json/temp.json" && mv "$cheatshh_json/temp.json" "$cheatshh_json/commands.json" 368 | fi 369 | done 370 | 371 | # Go back to the fzf preview page 372 | display_preview 373 | fi 374 | } 375 | 376 | # Extract group_command from group_command/group_name 377 | extract_command() { 378 | local selected_item="$1" 379 | local max_index=$(awk -F"/" '{print NF-1}' <<< "$selected_item") 380 | local index=1 381 | local group_name="" 382 | local group_command="" 383 | local found=0 384 | 385 | while [ $index -le $max_index ] && [ $found -eq 0 ]; do 386 | # Construct group_name by joining parts with / 387 | group_name=$(cut -d'/' -f1-$index <<< "$selected_item") 388 | # Check if group_name exists in groups.json 389 | if jq -e --arg groupName "$group_name" '.[$groupName]' "$cheatshh_json/groups.json" &> /dev/null; then 390 | found=1 391 | # Extract group_command from the remaining part 392 | group_command=$(cut -d'/' -f$((index+1))- <<< "$selected_item") 393 | else 394 | ((index++)) 395 | fi 396 | done 397 | 398 | if [ $found -eq 1 ]; then 399 | echo "$group_command" 400 | else 401 | echo "$selected_item" # If no group_name found, return the original item 402 | fi 403 | } 404 | 405 | display_preview() { 406 | # Fetch commands that are bookmarked or not bookmarked and not part of a group 407 | if [ "$full_display" == "on" ]; then 408 | while IFS= read -r group_name; do 409 | # Step 2: For each group, fetch commands and format them as "group_name/command_name" 410 | jq -r --arg group_name "$group_name" '.[$group_name].commands[] | "\($group_name)/\(.)"' "$cheatshh_json/groups.json" 411 | done < <(jq -r 'keys[]' "$cheatshh_json/groups.json") > "${cheatshh_json}/grouped_commands.txt" 412 | 413 | # Fetch commands that are not part of any group (assuming commands.json structure and logic for this) 414 | commands=$(jq -r 'to_entries[] | select(.value.bookmark == "yes" or (.value.bookmark == "no" and .value.group == "no")) | .key' "$cheatshh_json/commands.json") 415 | 416 | # Fetch all group names (if needed separately) 417 | groups=$(jq -r 'keys[]' "$cheatshh_json/groups.json") 418 | 419 | # Combine commands, grouped_commands (from file), and groups 420 | display_feat=$(echo -e "$commands\n$groups\n$(cat "${cheatshh_json}/grouped_commands.txt")") 421 | elif [ "$full_display" == "off" ]; then 422 | commands=$(jq -r 'to_entries[] | select(.value.bookmark == "yes" or (.value.bookmark == "no" and .value.group == "no")) | .key' "$cheatshh_json/commands.json") groups=$(jq -r 'keys[]' "$cheatshh_json/groups.json") 423 | display_feat=$(echo -e "$commands\n$groups") 424 | else 425 | echo "Invalid value for full_display = $full_display in cheatshh.toml. Please set it to either 'on' or 'off'." 426 | exit 1 427 | fi 428 | selected_command=$(echo -e "$display_feat" | fzf --preview " 429 | item={}; 430 | if [[ \"\$item\" == */* ]]; then 431 | group_name=\$(echo \"\$item\" | cut -d'/' -f1) 432 | group_command=\$(echo \"\$item\" | cut -d'/' -f2) 433 | item=\$group_command 434 | fi 435 | 436 | alias=\$(jq -r --arg item \"\$item\" '.[\$item].alias' "$cheatshh_json/commands.json"); 437 | bookmark=\$(jq -r --arg item \"\$item\" '.[\$item].bookmark' "$cheatshh_json/commands.json"); 438 | echo -e \"${title_color}COMMAND/GROUP: ${about_color}\$item${NC}\n\"; 439 | 440 | if jq -e --arg item \"\$item\" '.[\$item]' "$cheatshh_json/groups.json" > /dev/null; then 441 | about=\$(jq -r --arg item \"\$item\" '.[\$item].description' "$cheatshh_json/groups.json"); 442 | 443 | echo -e \"${title_color}GROUP DESCRIPTION:${NC}\"; 444 | if [ -n \"\$about\" ]; then 445 | # fix length of preview to fit within terminal width 446 | terminal_width=\$(tput cols) 447 | preview_window_width=\$((terminal_width * "${preview_width}" / 100)) 448 | text_width=\$((preview_window_width - 4)) 449 | about=\$(echo \"\$about\" | fold -w \$text_width) 450 | echo -e \"${about_color}\$about${NC}\n\"; 451 | fi 452 | group_commands=\$(jq -r --arg item \"\$item\" '.[\$item].commands[]' "$cheatshh_json/groups.json"); 453 | echo -e \"${title_color}GROUP COMMANDS:${NC} \n\$group_commands\n\"; 454 | else 455 | about=\$(jq -r --arg item \"\$item\" '.[\$item].description' "$cheatshh_json/commands.json"); 456 | echo -e \"${title_color}ABOUT:${NC}\"; 457 | if [ -n \"\$about\" ]; then 458 | # fix length of preview to fit within terminal width 459 | terminal_width=\$(tput cols) 460 | preview_window_width=\$((terminal_width * "${preview_width}" / 100)) 461 | text_width=\$((preview_window_width - 4)) 462 | about=\$(echo \"\$about\" | fold -w \$text_width) 463 | echo -e \"${about_color}\$about${NC}\n\"; 464 | fi 465 | echo -e \"${title_color}ALIAS:${NC} \$alias\n\"; 466 | echo -e \"${title_color}BOOKMARK:${NC} \$bookmark\n\"; 467 | echo -e \"${title_color}$(echo "$notes_name" | tr '[:lower:]' '[:upper:]'):${NC}\"; 468 | echo \"Please wait while the $(echo "$notes_name" | tr '[:lower:]' '[:upper:]') page is being searched for...\"; 469 | $notes \$item; 470 | if $display_man; then 471 | echo -e \"\n${title_color}MAN PAGE: ${NC}\n\"; 472 | echo \"Please wait while the MAN page is being searched for...\"; 473 | if [ -z \"$LANG\" ]; then 474 | LANG=en_US.UTF-8 475 | fi 476 | man \$cmd | col -b 477 | fi 478 | fi" --preview-window=right,"${preview_width}"%) 479 | 480 | # If the user pressed escape, fzf will return an exit status of 130 481 | if [ $? -eq 130 ]; then 482 | # Return a special exit status to indicate that the user wants to exit 483 | return 1 484 | fi 485 | 486 | # If a command was selected run it 487 | if [ -n "$selected_command" ]; then 488 | selected=$(extract_command "$selected_command") # Use the function to get the command 489 | if jq -e --arg item "$selected" '.[$item]' "$cheatshh_json/groups.json" > /dev/null; then 490 | display_group_commands "$selected" 491 | else 492 | bookmark=$(jq -r --arg cmd "$selected" '.[$cmd].bookmark' "$cheatshh_json/commands.json") 493 | if [ "$bookmark" = "yes" ]; then 494 | # If it is, set the bookmark option to "Remove Bookmark" 495 | bookmark_option="Remove Bookmark" 496 | else 497 | # If it isn't, set the bookmark option to "Bookmark" 498 | bookmark_option="Bookmark" 499 | fi 500 | OPTION=$(whiptail --title "Command Menu" --menu "What would you like to do? The selected command is copied to clipboard." 15 60 4 \ 501 | "1" "Exit" \ 502 | "2" "Stay" \ 503 | "3" "$bookmark_option" 3>&1 1>&2 2>&3) 504 | 505 | exitstatus=$? 506 | printf "%s" "$selected" | $copy_command 507 | if [ $exitstatus = 0 ]; then 508 | case $OPTION in 509 | "1") 510 | exit 511 | ;; 512 | "2") 513 | # Go back to cheatshh preview 514 | ;; 515 | "3") 516 | # Check if the command is already bookmarked 517 | bookmark=$(jq -r --arg cmd "$selected" '.[$cmd].bookmark' "$cheatshh_json/commands.json") 518 | if [ "$bookmark" = "yes" ]; then 519 | # If it is, remove the bookmark 520 | jq --arg cmd "$selected" '.[$cmd].bookmark = "no"' "$cheatshh_json/commands.json" > "$cheatshh_json/tmp/commands.json" && mv "$cheatshh_json/tmp/commands.json" "$cheatshh_json/commands.json" 521 | else 522 | # If it isn't, add the bookmark 523 | jq --arg cmd "$selected" '.[$cmd].bookmark = "yes"' "$cheatshh_json/commands.json" > "$cheatshh_json/tmp/commands.json" && mv "$cheatshh_json/tmp/commands.json" "$cheatshh_json/commands.json" 524 | fi 525 | ;; 526 | esac 527 | fi 528 | fi 529 | fi 530 | } 531 | display_group_commands() { 532 | group=$1 533 | commands=$(jq -r --arg group "$group" '.[$group].commands[]' "$cheatshh_json/groups.json") 534 | selected=$(echo -e "$commands" | fzf --preview " 535 | cmd={}; 536 | about=\$(jq -r --arg cmd \"\$cmd\" '.[\$cmd].description' "$cheatshh_json/commands.json"); 537 | alias=\$(jq -r --arg cmd \"\$cmd\" '.[\$cmd].alias' "$cheatshh_json/commands.json"); 538 | bookmark=\$(jq -r --arg item \"\$cmd\" '.[\$item].bookmark' "$cheatshh_json/commands.json"); 539 | echo -e \"${title_color}COMMAND: ${about_color}\$cmd${NC}\n\"; 540 | echo -e \"${title_color}ABOUT:${NC}\"; 541 | if [ -n \"\$about\" ]; then 542 | # fix length of preview to fit within terminal width 543 | terminal_width=\$(tput cols) 544 | preview_window_width=\$((terminal_width * "${preview_width}" / 100)) 545 | text_width=\$((preview_window_width - 4)) 546 | about=\$(echo \"\$about\" | fold -w \$text_width) 547 | echo -e \"${about_color}\$about${NC}\n\"; 548 | fi 549 | echo -e \"${title_color}ALIAS:${NC} \$alias\n\"; 550 | echo -e \"${title_color}BOOKMARK:${NC} \$bookmark\n\"; 551 | echo -e \"${title_color}$(echo "$notes_name" | tr '[:lower:]' '[:upper:]'):${NC}\n\"; 552 | echo \"Please wait while the $(echo "$notes_name" | tr '[:lower:]' '[:upper:]') page is being searched for...\"; 553 | $notes \$cmd; 554 | if $display_man; then 555 | echo -e \"\n${title_color}MAN PAGE: ${NC}\n\"; 556 | echo \"Please wait while the MAN page is being searched for...\"; 557 | if [ -z \"$LANG\" ]; then 558 | LANG=en_US.UTF-8 559 | fi 560 | man \$cmd | col -b 561 | fi" --preview-window=right,"${preview_width}"%) 562 | # If a command was selected run it 563 | 564 | if [ -n "$selected" ]; then 565 | bookmark=$(jq -r --arg cmd "$selected" '.[$cmd].bookmark' "$cheatshh_json/commands.json") 566 | if [ "$bookmark" = "yes" ]; then 567 | # If it is, set the bookmark option to "Remove Bookmark" 568 | bookmark_option="Remove Bookmark" 569 | else 570 | # If it isn't, set the bookmark option to "Bookmark" 571 | bookmark_option="Bookmark" 572 | fi 573 | OPTION=$(whiptail --title "Command Menu" --menu "What would you like to do? The selected command is copied to clipboard." 15 60 4 \ 574 | "1" "Exit" \ 575 | "2" "Stay" \ 576 | "3" "$bookmark_option" 3>&1 1>&2 2>&3) 577 | 578 | exitstatus=$? 579 | printf "%s" "$selected" | $copy_command 580 | if [ $exitstatus = 0 ]; then 581 | case $OPTION in 582 | "1") 583 | exit 584 | ;; 585 | "2") 586 | # Go back to cheatshh preview 587 | ;; 588 | "3") 589 | # Check if the command is already bookmarked 590 | bookmark=$(jq -r --arg cmd "$selected" '.[$cmd].bookmark' "$cheatshh_json/commands.json") 591 | if [ "$bookmark" = "yes" ]; then 592 | # If it is, remove the bookmark 593 | jq --arg cmd "$selected" '.[$cmd].bookmark = "no"' "$cheatshh_json/commands.json" > "$cheatshh_json/tmp/commands.json" && mv "$cheatshh_json/tmp/commands.json" "$cheatshh_json/commands.json" 594 | else 595 | # If it isn't, add the bookmark 596 | jq --arg cmd "$selected" '.[$cmd].bookmark = "yes"' "$cheatshh_json/commands.json" > "$cheatshh_json/tmp/commands.json" && mv "$cheatshh_json/tmp/commands.json" "$cheatshh_json/commands.json" 597 | fi 598 | ;; 599 | esac 600 | fi 601 | fi 602 | } 603 | 604 | options(){ 605 | OPTIONS=("1" "Add command" 606 | "2" "Add group" 607 | "3" "Edit Command" 608 | "4" "Edit group" 609 | "5" "Delete Command" 610 | "6" "Delete group") 611 | 612 | # Use whiptail to present the options and capture the choice 613 | CHOICE=$(whiptail --title "Menu" --menu "Choose an option" 15 60 6 \ 614 | "1" "Add command" \ 615 | "2" "Add group" \ 616 | "3" "Edit Command" \ 617 | "4" "Edit group" \ 618 | "5" "Delete Command" \ 619 | "6" "Delete group" 3>&1 1>&2 2>&3) 620 | 621 | exitstatus=$? 622 | if [ $exitstatus = 0 ]; then 623 | # Output based on the choice 624 | case $CHOICE in 625 | 1) 626 | addition 627 | ;; 628 | 2) 629 | create_group 630 | ;; 631 | 3) 632 | edit_command 633 | ;; 634 | 4) 635 | edit_group 636 | ;; 637 | 5) 638 | deletion_command 639 | ;; 640 | 6) 641 | delete_group 642 | ;; 643 | esac 644 | fi 645 | } 646 | 647 | enter_loop=true 648 | 649 | help_text(){ 650 | echo "cheatshh - A cheatsheet scripted by you for you to help you remember commands and their usage." 651 | echo "Usage:" 652 | echo " cheatshh [OPTIONS]" 653 | echo " " 654 | echo "OPTIONS:" 655 | echo " -a, --add Add a new command to the cheatsheet" 656 | echo " -ec, --edit-command Edit an existing command's description or group in the cheatsheet" 657 | echo " -dc, --delete-command Delete an existing command from the cheatsheet" 658 | echo " -g, --group Create a new group" 659 | echo " -eg, --edit-group Edit an existing group's name or description in the cheatsheet" 660 | echo " -dg, --delete-group Delete an existing group and it's sub commands from commands.json file" 661 | echo " -o, --options Display a menu to add, edit, or delete commands and groups" 662 | echo " -m, --man Display man pages" 663 | echo " " 664 | echo "META OPTIONS" 665 | echo " -h, --help Display this help message" 666 | echo " -v, --version Display the version of cheatshh" 667 | echo " " 668 | echo "Note: 1) Add -m to display the man pages of the commands in addition to tldr(or anyother)." 669 | echo "2) Press Enter to select a command, which will be copied to your clipboard and exited " 670 | echo "3) Bookmark a command by selecting it and pressing 'Bookmark' in the preview window." 671 | echo "4) To change various configuration, edit the $HOME/.config/cheatshh/cheatshh.toml file." 672 | echo "For more information, please visit: https://github.com/AnirudhG07/cheatshhh" 673 | } 674 | 675 | case "$@" in 676 | *'-m'*|*'--man'*) 677 | display_man=true 678 | ;; 679 | *'-a'*|*'--add'*) 680 | addition 681 | ;; 682 | *'-ec'*|*'--edit-command'*) 683 | edit_command 684 | ;; 685 | *'-eg'*|*'--edit-group'*) 686 | edit_group 687 | ;; 688 | *'-dc'*|*'--delete-command'*) 689 | deletion_command 690 | ;; 691 | *'-g'*|*'--group'*) 692 | create_group 693 | ;; 694 | *'-dg'*|*'--delete-group'*) 695 | delete_group 696 | ;; 697 | *'-o'*|*'--options'*) 698 | options 699 | ;; 700 | *'-v'*|*'--version'*) 701 | echo "cheatshh --version 1.1.1" 702 | enter_loop=false 703 | ;; 704 | *'-h'*|*'--help'*) 705 | help_text 706 | enter_loop=false 707 | ;; 708 | *) 709 | if [ $# -gt 0 ]; then 710 | echo "Invalid option." 711 | help_text 712 | enter_loop=false 713 | fi 714 | ;; 715 | esac 716 | 717 | # Check the flag before entering the loop 718 | if $enter_loop ; then 719 | # Then, enter the display_preview loop 720 | while true; do 721 | display_preview 722 | # If display_preview returned the special exit status, break the loop to exit the script 723 | if [ $? -eq 1 ]; then 724 | break 725 | fi 726 | done 727 | fi 728 | -------------------------------------------------------------------------------- /cheatshh/cheatshh.toml: -------------------------------------------------------------------------------- 1 | ## Configuration file for cheatshh. This was setup on MacOS. Please read the comments carefully before making any changes. 2 | ## Do not change the Default values mentioned unless you know what you are doing. 3 | 4 | [settings] 5 | 6 | # Add the shell command for copying command like xclip, pbcopy, etc. (including flags if you like) 7 | ## Template: `printf "text"| $copy_command` 8 | copy_command = "pbcopy" # Default: "pbcopy" 9 | 10 | # Display the number of groups in whiptail dialog 11 | ## Keep the below number small enough to fit in whiptail dialog, else it may produce error. 12 | display_group_number = 10 # Default: 10 13 | 14 | # Automatically display man pages in preview without using the -m flag 15 | man_pages = false # Default: false 16 | 17 | ## Location of storage of commands.json & groups.json 18 | ### PLEASE NOTE: cheats.sh & cheatshh.toml will remain in ~/.config/cheatshh. Do not change it's PATH 19 | cheatshh_home = "~/.config/cheatshh" # Default: "~/.config/cheatshh" 20 | 21 | ## Other Cheatsheets(predownloaded) you would like to you use Apart from TLDR like cheat.sh, bropages, etc 22 | ## Template: `$ notes command_name`. Color flag is present in TLDR, add suitable flags for any other. 23 | notes = "tldr --color" # DEFAULT: "tldr --color" 24 | 25 | ## Allow full display of commands with groups in the fzf - ("on"/"off"). Example group_name/group_command 26 | full_display = "on" # Default: "on" 27 | 28 | ## Preview width - Changing the width of the preview window. It is recommended to not change this. 29 | preview_width = 70 # Default: 70 30 | 31 | [color_scheme] 32 | 33 | ## Define color codes, please use the color codes mentioned below(make sure they are supported by your terminal 34 | # CYAN='\\033[0;36m' 35 | # YELLOW='\\033[0;33m' 36 | # RED='\\033[0;31m' 37 | # GREEN='\\033[0;32m' 38 | # BLUE='\\033[0;34m' 39 | # MAGENTA='\\033[0;35m' 40 | # WHITE='\\033[0;37m' 41 | # BLACK='\\033[0;30m' 42 | # PURPLE='\\033[0;35m' 43 | # ORANGE='\\033[0;33m' 44 | # If you would like some other color, please add their color code on your own. Thank you! 45 | 46 | # Color for the title in preview 47 | title_color = "\\033[0;36m" # Default: "\\033[0;36m" 48 | # Color for About and Command/Group name in preview 49 | about_color = "\\033[0;33m" # Default: "\\033[0;33m" 50 | -------------------------------------------------------------------------------- /cheatshh/commands.json: -------------------------------------------------------------------------------- 1 | { 2 | "your_alias_command": { 3 | "description": "This command will be visible only inside the group. TLDR page will be automatically be visible when this will be a valid non-aliased command, and if tldr exists for it too.", 4 | "alias": "yes", 5 | "group": "yes", 6 | "bookmark": "no" 7 | }, 8 | "your_first_command": { 9 | "description": "Your CUSTOM description here. It can be anything. Dont forget to use break line character to add a new line in the description of command. Don't forget to delete this command using $ cheatshh -dc.", 10 | "alias": "yes", 11 | "group": "no", 12 | "bookmark": "no" 13 | } 14 | } -------------------------------------------------------------------------------- /cheatshh/groups.json: -------------------------------------------------------------------------------- 1 | { 2 | "group_init":{ 3 | "description":"Welcome to your first group. This group contains dummy commands you can see and. Press Enter to see more.\nDon't forget to delete this group using $ cheatshh -dg", 4 | "commands":[ 5 | "your_alias_command" 6 | ] 7 | } 8 | } -------------------------------------------------------------------------------- /cheatshh/main.py: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | import shutil 4 | import sys 5 | import argparse 6 | from importlib import resources 7 | 8 | def post_install(): 9 | config_path = os.path.join(os.path.expanduser('~'), '.config', 'cheatshh') 10 | try: 11 | # Check if the directory exists 12 | if not os.path.exists(config_path): 13 | # If not, create it 14 | os.makedirs(config_path) 15 | # Copy the files from the package to the new config path 16 | files_to_copy = ['cheats.sh', 'groups.json', 'commands.json', 'cheatshh.toml'] 17 | for file_name in files_to_copy: 18 | with resources.path('cheatshh', file_name) as file_path: 19 | shutil.copy2(file_path, os.path.join(config_path, file_name)) 20 | # Make cheats.sh executable 21 | subprocess.call(['chmod', '+x', os.path.join(config_path, 'cheats.sh')]) 22 | except: 23 | print("Error: Could not create {} directory. Please retry or report issue to official Github page.".format(config_path)) 24 | return 25 | 26 | def cheatshh(args): 27 | try: 28 | subprocess.call([os.path.join(os.path.expanduser('~'), '.config', 'cheatshh', 'cheats.sh')] + args) 29 | except Exception as e: 30 | print(f"Error: {e}.\n Could not run cheatshh.") 31 | 32 | def main(): 33 | """ 34 | Cheatshh main function simply calls cheats.sMh function which is the main function of cheats.sh. 35 | It is a simple wrapper around cheats.sh using python. 36 | This function will also create $HOME/.config/cheatshh directory if it does not exist. 37 | """ 38 | post_install() 39 | cheatshh(sys.argv[1:]) 40 | 41 | return -------------------------------------------------------------------------------- /docs/cheatshh_configurations.md: -------------------------------------------------------------------------------- 1 | # Cheatshh Configuration setup Manual 2 | Cheatshh uses a configuration file `cheatshh.toml` to store its various settings and color schemes for user customization. The configuration file is located at `$HOME/.config/cheatshh/config.toml` and is downloaded automatically when you run `cheatshh` for the first time. 3 | 4 | `cheatshh.toml` has a lot of comments to guide you through the customization. This document will provide a more detailed explanation of the various settings that you can customize in the configuration file. 5 | 6 | # Settings 7 | There are several settings that you can customize in the configuration file. 8 | ## 1. copy_command 9 | This setting allows the terminal to copy the selected command text. The default is set to `pbcopy` for MacOS, but you can change it to `xclip` for Linux, etc. The template of how the command is executed is - 10 | ```bash 11 | printf "text"| $copy_command 12 | ``` 13 | If you would like to add any flags for your clipboard command, you are very welcome to do so. 14 | 15 | ## 2. display_group_number 16 | When you are prompted to select a group where you want to add the command into, you are presented with a list of groups for reference. The number of groups to be displayed is set by defualt to 10(maximum value). You can change the number as you like. But remember, the more groups you display, the more cluttered the screen will be. 17 | ```bash 18 | display_group_number = 10 19 | ``` 20 | It is recommended you keep the number between 10-20. 21 | 22 | ## 3. man_pages 23 | This enables automatic display of man pages for the selected command in the preview. You can also allow the visibility of man pages using the `--man` or `-m` flag. The default value is set to `false`. 24 | ```bash 25 | man_pages = false 26 | ``` 27 | You can set it to `true` or `false` depending on your preference. 28 | 29 | ## 4. cheatshh_home ** 30 | This is VERY IMPORTANT SETTING. This sets the path to the directory where cheatshh stores its data. The default value is set to `~/.config/cheatshh`. You can change it to any directory you like. 31 | ```bash 32 | cheatshh_home = "~/.config/cheatshh" 33 | ``` 34 | **NOTE:** Please provide the ABSOLUTE PATH to avoid crashing. 35 | 36 | ## 5. notes 37 | This allows you to choose not just TLDR, but any other cheatsheet command you would like to choose like `cheat.sh`, `bropages`, `Cheat`, etc. Here is a list of commands you can input in the configuration file. 38 | ```bash 39 | ## TLDR PAGES 40 | notes="tldr --color" 41 | 42 | ## Cheat 43 | notes="cheat" 44 | 45 | ## cheat.sh 46 | notes="curl cheat.sh" 47 | 48 | ## eg 49 | notes="eg" 50 | 51 | ## kb 52 | notes="kb" # OR 53 | notes="kb list" 54 | 55 | ## bropages 56 | notes="bro" 57 | ``` 58 | The template of the command usage is - 59 | ```bash 60 | notes command_name 61 | ``` 62 | You can input flags/parameters for them as well. 63 | 64 | ## 6. full_display 65 | This setting allows you to change display in the main preview. The default value is set to `on`. If you set it as `on`, you will see the below commands/groups in order- 66 | 1. ungrouped commands and bookmarked commands 67 | 2. groups 68 | 3. group_name/group_command 69 | 70 | If you set it as `off`, you will see the below commands/groups in order- 71 | 1. ungrouped commands and bookmarked commands 72 | 2. groups 73 | 74 | ```bash 75 | full_display = "on" 76 | ``` 77 | You can set it to `on` or `off` depending on your preference. 78 | 79 | ## 7. preview_width 80 | The preview width is the space on % of the screen the preview will take. The default value is set to `70`. It is highly recommended to NOT CHANGE THIS. But if you want to, you can change it to any value you like. 81 | ```bash 82 | preview_width = 70 83 | ``` 84 | 85 | # Color Schemes 86 | We provide only two color configurations for now. To set the color, `cheatshh.toml` contains the colors and their respective values to input. Please use them exactly as they are else the shell script will show errors. 87 | ```bash 88 | # CYAN='\\033[0;36m' 89 | # YELLOW='\\033[0;33m' 90 | # RED='\\033[0;31m' 91 | # GREEN='\\033[0;32m' 92 | # BLUE='\\033[0;34m' 93 | ``` 94 | Input the colors as in the configuration file as shown below. 95 | ```bash 96 | example_color="\\033[0;32m" # For GREEN Color 97 | ``` 98 | You can add colors not mentioned in the `cheatshh.toml` file. But make sure you input the correct color code. 99 | 100 | ## 1. title_color 101 | The title color represents the color of all the titles in the preview. You can change it as you wish. The default value is `CYAN`. 102 | ```bash 103 | title_color="\\033[0;36m" 104 | ``` 105 | 106 | ## 2. about_color 107 | This denotes the color of the `ABOUT` (description) of the command or group in the preview. The default value is `YELLOW`. 108 | ```bash 109 | about_color="\\033[0;33m" 110 | ``` 111 | You can change these as you like. 112 | **NOTE:** Changing the color text of MANPAGES might not be possible. For TLDR or any other notes tool, you can set some flags to change the color(if they exist). 113 | 114 | ### Conclusion 115 | If you can issues with any of these settings or would like to add more, please feel free to raise an issue on the GitHub repository. 116 | :q -------------------------------------------------------------------------------- /docs/man/cheatshh.1: -------------------------------------------------------------------------------- 1 | .TH Cheatshh 1 "May 2024" "Cheatshh Manual" "Cheatshh Manual Page" 2 | NAME 3 | cheatshh - A shell script for managing command cheatsheets 4 | 5 | SYNOPSIS 6 | cheatshh [OPTION] 7 | cheatshh -v, --version 8 | 9 | DESCRIPTION 10 | cheatshh is an interactive command-line interface for managing command line cheatsheets. 11 | It allows you to add, edit, and delete commands, as well as create, edit and delete groups of commands. 12 | You can bookmark commands to easily access them in main preview. 13 | 14 | OPTIONS 15 | -a, --add 16 | Add a new command to the cheatsheet. 17 | 18 | -ec, --edit-command 19 | Edit an existing command's description or group in the cheatsheet. 20 | 21 | -dc, --delete-command 22 | Delete an existing command from the cheatsheet. 23 | 24 | -g, --group 25 | Create a new group. 26 | 27 | -eg, --edit-group 28 | Edit an existing group's name or description in the cheatsheet. 29 | 30 | -dg, --delete-group 31 | Delete an existing group and it's sub commands from commands.json file. 32 | 33 | -o, --options 34 | Display a menu to add, edit or delete commands and groups. 35 | 36 | -m, --man 37 | Display man pages after tldr in the preview. 38 | 39 | FILES 40 | By default, cheatshh will create a folder in ~/.config/cheatshh where all the files and codes are stored. 41 | You can access it and change settings as it suits you. 42 | 43 | Cheatshh contains two previews pages, the main preview and the group preview. The non-bookmarked commands 44 | will appear in/outside groups but bookmarked commands will appear in both places. 45 | 46 | Cheatshh reads its configurations from 3 files mainly: 47 | 48 | cheats.sh 49 | This file is the main source code for the display, addition, deletion, grouping and editing. 50 | 51 | commands.json 52 | This file stores all the commands with their respective description and properties. 53 | 54 | groups.json 55 | This file stores all the groups made with their respective descriptions and sub-commands. 56 | 57 | cheatshh.toml 58 | This file contains the default configurations for Cheatshh and can be customized. 59 | 60 | You can download pre-made groups through the main github page at https://github.com/AnirudhG07/cheatshh. 61 | Simply copy paste them into your commands.json and groups.json file to make them visible. 62 | 63 | NOTES 64 | Cheatshh assumes every command is unique and you cannot have more than one command with the same name. 65 | 66 | Deleting a group will only delete the commands of that group. If a command is common in other groups, then 67 | the command will not be deleted from other groups. 68 | Deleting a command has optional delete from a particular group or throughout the cheatsheet. 69 | 70 | Select a group or a command by pressing Enter. Go back or quit the cheatshh by pressing Escape. 71 | On selection of a group, you will be able to see the commands present in it with custom set descriptions and 72 | tldr page. 73 | On selection of a command, it will be copied to your clipboard automatically, and you will be prompted to exit. 74 | 75 | Bookmarking: You can bookmark commands by pressing enter and selecting `Bookmark` in(out)side groups such that 76 | they will be appear in the main preview even if they were present in a group. 77 | Hence they could be easily accessed within and outside it's group. You can always remove bookmark of some command. 78 | 79 | Configuration: You can change various configuration in cheatshh.toml like color schemes, automatic man page display, 80 | terminal copy command to be used and even what cheatsheet you are using like tldr, cheats.sh, bropages, etc. 81 | 82 | EXAMPLES 83 | To add a new command 84 | 85 | $ cheatshh -a 86 | 87 | To edit an existing command 88 | 89 | $ cheatshh -e 90 | 91 | To delete a command 92 | 93 | $ cheatshh -dc 94 | 95 | To create a new group 96 | 97 | $ cheatshh -g 98 | 99 | To edit a group 100 | 101 | $ cheatshh -eg 102 | 103 | To delete a group 104 | 105 | $ cheatshh -dg 106 | 107 | To display menu bar 108 | $ cheatshh -o 109 | 110 | To display the man pages in addition with tldr. 111 | 112 | $ cheatshh -m 113 | 114 | DEPENDENCIES 115 | For cheatshh to function properly, make sure you have fzf(fuzzy finder) and whiptail installed through your 116 | package manager. 117 | 118 | AUTHOR 119 | Cheatshh was written by Anirudh Gupta. 120 | Visit for more information. 121 | 122 | -------------------------------------------------------------------------------- /docs/tldr/cheatshh.md: -------------------------------------------------------------------------------- 1 | # cheatshh 2 | 3 | > CLI cheatsheet with customized descriptions, tldr and groups, to look into for your reference. 4 | > Press Enter to a command to copy it to your clipboard and exit. 5 | > More information: . 6 | 7 | - [a]dd a new command to the cheatsheet: 8 | 9 | `cheatshh --add` 10 | 11 | - Edit ([ec]) an existing command's description or group in the cheatsheet: 12 | 13 | `cheatshh --edit-command` 14 | 15 | - Delete ([dc]) an existing command from the cheatsheet: 16 | 17 | `cheatshh --delete-command` 18 | 19 | - Create a new [g]roup: 20 | 21 | `cheatshh --group` 22 | 23 | - Edit ([eg]) an existing group's name or description in the cheatsheet: 24 | 25 | `cheatshh --edit-group` 26 | 27 | - Delete ([dg]) an existing group and it's sub commands from commands.json file: 28 | 29 | `cheatshh --delete-group` 30 | 31 | - Display [m]an pages after tldr in the preview: 32 | 33 | `cheatshh --man` 34 | -------------------------------------------------------------------------------- /library/Games/commands.json: -------------------------------------------------------------------------------- 1 | { 2 | "ninvaders": { 3 | "description": "Space Invaders. It's actually pretty hard you know", 4 | "alias": "no", 5 | "group": "yes", 6 | "bookmark": "no" 7 | }, 8 | "moon-buggy": { 9 | "description": "Moon Buggy game in terminal. You don't wanna crash on moon, cause then there is no way back home!", 10 | "alias": "no", 11 | "group": "yes", 12 | "bookmark": "no" 13 | }, 14 | "nethack": { 15 | "description": "Just like Dungeons and Dragons, but of the terminal world. It's a classic.", 16 | "alias": "no", 17 | "group": "yes", 18 | "bookmark": "no" 19 | }, 20 | "pacman4console": { 21 | "description": "Console version of the popular arcade game Pac-Man.", 22 | "alias": "no", 23 | "group": "yes", 24 | "bookmark": "no" 25 | }, 26 | "bsdgames": { 27 | "description": "Collection of classic text games like tetris, snake, pong, hangman, and adventure.", 28 | "alias": "no", 29 | "group": "yes", 30 | "bookmark": "no" 31 | }, 32 | "greed": { 33 | "description": "A game of consumption and survival on a grid.", 34 | "alias": "no", 35 | "group": "yes", 36 | "bookmark": "no" 37 | }, 38 | "bastet": { 39 | "description": "A notoriously difficult version of Tetris.", 40 | "alias": "no", 41 | "group": "yes", 42 | "bookmark": "no" 43 | }, 44 | "crawl": { 45 | "description": "Dungeon Crawl Stone Soup, a fun and highly addictive roguelike game.", 46 | "alias": "no", 47 | "group": "yes", 48 | "bookmark": "no" 49 | } 50 | } -------------------------------------------------------------------------------- /library/Games/groups.json: -------------------------------------------------------------------------------- 1 | { 2 | "games":{ 3 | "description": "Games you can play in the terminal.", 4 | "commands": [ 5 | "ninvaders", 6 | "moon-buggy", 7 | "nethacks", 8 | "pacman4console", 9 | "bastet", 10 | "greed", 11 | "crawl", 12 | "bsdgames" 13 | ] 14 | } 15 | } -------------------------------------------------------------------------------- /library/General Commands/commands.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": { 3 | "description": "Open Visual Studio Code. You can use code . for current directory.", 4 | "alias": "no", 5 | "group": "yes", 6 | "bookmark": "no" 7 | }, 8 | "nvim": { 9 | "description": "Open Neovim. You can use nvim for opening file in neovim. Or nvim to enter neovim.", 10 | "alias": "no", 11 | "group": "yes", 12 | "bookmark": "no" 13 | }, 14 | "tmux": { 15 | "description": "Terminal multiplexer. Create tmux session with $ tmux new -s . Use $ tmux attach -t to attach to session.", 16 | "alias": "no", 17 | "group": "yes", 18 | "bookmark": "no" 19 | }, 20 | "less": { 21 | "description": "Less is more. It's a pager. You can use less to open file in less. ", 22 | "alias": "no", 23 | "group": "yes", 24 | "bookmark": "no" 25 | }, 26 | "rm": { 27 | "description": "Remove files. rm *. will delete all kinds of files. You can use rip instead of rm.", 28 | "alias": "no", 29 | "group": "yes", 30 | "bookmark": "no" 31 | }, 32 | "rmdir": { 33 | "description": "Remove directory. rmdir will remove empty directory. For non-empty directory, use rm -rf .", 34 | "alias": "no", 35 | "group": "yes", 36 | "bookmark": "no" 37 | }, 38 | "mkdir": { 39 | "description": "Make directory. mkdir will create a directory with name dir.", 40 | "alias": "no", 41 | "group": "yes", 42 | "bookmark": "no" 43 | }, 44 | "touch": { 45 | "description": "Create a file. touch will create a file with name file.", 46 | "alias": "no", 47 | "group": "yes", 48 | "bookmark": "no" 49 | }, 50 | "mv": { 51 | "description": "Move files. mv will move file to directory. mv will rename file1 to file2.", 52 | "alias": "no", 53 | "group": "yes", 54 | "bookmark": "no" 55 | }, 56 | "cp": { 57 | "description": "Copy files. cp will copy file to directory.", 58 | "alias": "no", 59 | "group": "yes", 60 | "bookmark": "no" 61 | }, 62 | "cat": { 63 | "description": "Cat stands for concatenate. Cat will show file contents. cat will concatenate file1 and file2.", 64 | "alias": "no", 65 | "group": "yes", 66 | "bookmark": "no" 67 | }, 68 | "echo": { 69 | "description": "Echo. echo will print string. echo 'string' > will write string to file.", 70 | "alias": "no", 71 | "group": "yes", 72 | "bookmark": "no" 73 | }, 74 | "grep": { 75 | "description": "Grep. grep will search for pattern in file.", 76 | "alias": "no", 77 | "group": "yes", 78 | "bookmark": "no" 79 | }, 80 | "find": { 81 | "description": "Find. find -name will search for file in directory.", 82 | "alias": "no", 83 | "group": "yes", 84 | "bookmark": "no" 85 | }, 86 | "ls": { 87 | "description": "List. ls will list files in directory. ls -a will list all files including hidden files.", 88 | "alias": "no", 89 | "group": "yes", 90 | "bookmark": "no" 91 | }, 92 | "cd": { 93 | "description": "Change directory. cd will change directory to dir. cd .. will go to parent directory.", 94 | "alias": "no", 95 | "group": "yes", 96 | "bookmark": "no" 97 | }, 98 | "pwd": { 99 | "description": "Print working directory. pwd will show current directory.", 100 | "alias": "no", 101 | "group": "yes", 102 | "bookmark": "no" 103 | }, 104 | "clear": { 105 | "description": "Clear screen. clear will clear the terminal screen. It basically jumps down but you can always scroll up to see previous commands and work.", 106 | "alias": "no", 107 | "group": "yes", 108 | "bookmark": "no" 109 | }, 110 | "exit": { 111 | "description": "Exit. exit will close the terminal.", 112 | "alias": "no", 113 | "group": "yes", 114 | "bookmark": "no" 115 | }, 116 | "whoami": { 117 | "description": "Who am I. whoami will show the current user.", 118 | "alias": "no", 119 | "group": "yes", 120 | "bookmark": "no" 121 | }, 122 | "man": { 123 | "description": "Manual for each command. It provides a detailed view of the command.", 124 | "alias": "no", 125 | "group": "yes", 126 | "bookmark": "no" 127 | } 128 | } -------------------------------------------------------------------------------- /library/General Commands/groups.json: -------------------------------------------------------------------------------- 1 | { 2 | "General-Commands":{ 3 | "description": "Work-flow general commands I use in my terminal.", 4 | "commands": [ 5 | "code", 6 | "nvim", 7 | "vim", 8 | "tmux", 9 | "less", 10 | "rm", 11 | "rmdir", 12 | "mkdir", 13 | "touch", 14 | "mv", 15 | "cp", 16 | "cat", 17 | "echo", 18 | "grep", 19 | "find", 20 | "ls", 21 | "cd", 22 | "pwd", 23 | "clear", 24 | "exit", 25 | "whoami", 26 | "man" 27 | ] 28 | } 29 | } -------------------------------------------------------------------------------- /library/Pypi Publishing/commands.json: -------------------------------------------------------------------------------- 1 | { 2 | "pip install twine": { 3 | "description": " STEP 0: Install twine for uploading packages to pypi if you don't have.", 4 | "alias": "no", 5 | "group": "yes", 6 | "bookmark": "no" 7 | }, 8 | "python setup.py sdist bdist_wheel": { 9 | "description": "STEP 1: Create a source distribution.", 10 | "alias": "no", 11 | "group": "yes", 12 | "bookmark": "no" 13 | }, 14 | "twine upload dist/*": { 15 | "description": "STEP 2: Upload the distribution to PyPI. Add API token or username and password, if asked.", 16 | "alias": "no", 17 | "group": "yes", 18 | "bookmark": "no" 19 | } 20 | } -------------------------------------------------------------------------------- /library/Pypi Publishing/groups.json: -------------------------------------------------------------------------------- 1 | { 2 | "Pypi publish":{ 3 | "description": "Commands to use in order to publish a python package to pypi.", 4 | "commands": [ 5 | "pip install twine", 6 | "python setup.py sdist bdist_wheel", 7 | "twine upload dist/*" 8 | ] 9 | } 10 | } -------------------------------------------------------------------------------- /library/README.md: -------------------------------------------------------------------------------- 1 | # Libraries 2 | 3 | These are pre-made libraries which you can add in your groups and commands.
4 | These groups are very broad based and not broken finely for networking, files, permission based, etc. 5 | 6 | ## How to add them in your cheatshh 7 | 8 | These will be either present in your main directory `~/.config/cheatshh` or you'll have to download it through the github page. 9 | 10 | 1. Open the main directory using the following command 11 | 12 | ```bash 13 | cd; cd ~/.config/cheatshh/library 14 | ``` 15 | 16 | 2. Open the directory of suitable name and its `groups.json`, copy the group whichever you like. Then paste it in `~/.config/cheatshh/groups.json`. 17 | 18 | 3. It is very important to copy the commands present in the `commands.json` of the same directory as you chose. Then paste it in `~/.config/cheatshh/commands.json`. 19 | 20 | ## Note 21 | 22 | - If you see yellow lines under a command or a group, this means that the name is previously present in `commands.json` and you'll have to remove it since it's duplicate. 23 | - You can always change the description in the `commands.json` and `groups.json`, or using the built-in options- 24 | 25 | ```bash 26 | cheatshh -ec 27 | # OR 28 | cheatshh -eg 29 | ``` 30 | 31 | - You might see NEW and COOL terminal commands you might never have even heard of. Well some of them are my personal favourites and I would highly recommend you to download them as well. (They are Linux/MacOS based mostly.) 32 | 33 | - Feel free to post your personal favourite libraries by forking the repository and creating a pull request. I'll be happy to expand this library and see more and more cool terminal utilities. 34 | 35 | -------------------------------------------------------------------------------- /library/Terminal Show off/commands.json: -------------------------------------------------------------------------------- 1 | { 2 | "cmatrix": { 3 | "description": "Matrix style terminal effects. So cool!", 4 | "alias": "no", 5 | "group": "yes", 6 | "bookmark": "no" 7 | }, 8 | "sl": { 9 | "description": "Train passing through terminal", 10 | "alias": "no", 11 | "group": "yes", 12 | "bookmark": "no" 13 | }, 14 | "fortune": { 15 | "description": "Random fortune or a funny quote", 16 | "alias": "no", 17 | "group": "yes", 18 | "bookmark": "no" 19 | }, 20 | "cowsay": { 21 | "description": "Cow says something you want it to say. Try out various styles of cow", 22 | "alias": "no", 23 | "group": "yes", 24 | "bookmark": "no" 25 | }, 26 | "figlet": { 27 | "description": "ASCII text banner", 28 | "alias": "no", 29 | "group": "yes", 30 | "bookmark": "no" 31 | }, 32 | "toilet": { 33 | "description": "ASCII art in terminal", 34 | "alias": "no", 35 | "group": "yes", 36 | "bookmark": "no" 37 | }, 38 | "lolcat": { 39 | "description": "Colorful painter in terminal by a cat.", 40 | "alias": "no", 41 | "group": "yes", 42 | "bookmark": "no" 43 | }, 44 | "asciiquarium": { 45 | "description": "Miss fishing? Well you can sure see fishes in terminal getting fished.", 46 | "alias": "no", 47 | "group": "yes", 48 | "bookmark": "no" 49 | }, 50 | "pipes.sh": { 51 | "description": "Pipes in terminal", 52 | "alias": "no", 53 | "group": "yes", 54 | "bookmark": "no" 55 | }, 56 | "hollywood": { 57 | "description": "Hollywood style effects in terminal. Makes you a pro instantly!", 58 | "alias": "no", 59 | "group": "yes", 60 | "bookmark": "no" 61 | }, 62 | "edex-ui": { 63 | "description": "A cross-platform, customizable science fiction terminal emulator with advanced monitoring & touchscreen support. Make an alias to run the software.", 64 | "alias": "yes", 65 | "group": "yes", 66 | "bookmark": "no" 67 | }, 68 | "bb": { 69 | "description": "Runs an ASCII art demo with music.", 70 | "alias": "no", 71 | "group": "yes", 72 | "bookmark": "no" 73 | }, 74 | "nyancat": { 75 | "description": "Shows an animated ASCII Nyan Cat.", 76 | "alias": "no", 77 | "group": "yes", 78 | "bookmark": "no" 79 | } 80 | } -------------------------------------------------------------------------------- /library/Terminal Show off/groups.json: -------------------------------------------------------------------------------- 1 | { 2 | "cool things": { 3 | "description": "Cool show off things you can always try and chill out with.", 4 | "commands": [ 5 | "cmatrix", 6 | "sl", 7 | "fortune", 8 | "cowsay", 9 | "figlet", 10 | "toilet", 11 | "lolcat", 12 | "asciiquarium", 13 | "pipes.sh", 14 | "hollywood", 15 | "edex-ui", 16 | "bb", 17 | "nyancat" 18 | ] 19 | } 20 | } -------------------------------------------------------------------------------- /library/Terminal Utilities/commands.json: -------------------------------------------------------------------------------- 1 | { 2 | "btop": { 3 | "description": "A better top command. It is a task manager. ", 4 | "alias": "no", 5 | "group": "yes", 6 | "bookmark": "no" 7 | }, 8 | "neofetch": { 9 | "description": "A command line system information tool. It displays information about your system next to an image, your operating system logo, or any ASCII file of your choice.", 10 | "alias": "no", 11 | "group": "yes", 12 | "bookmark": "no" 13 | }, 14 | "ncdu": { 15 | "description": "A disk usage analyzer with an ncurses interface.", 16 | "alias": "no", 17 | "group": "yes", 18 | "bookmark": "no" 19 | }, 20 | "fdupes": { 21 | "description": "A program for identifying or deleting duplicate files residing within specified directories.", 22 | "alias": "no", 23 | "group": "yes", 24 | "bookmark": "no" 25 | }, 26 | "df": { 27 | "description": "A command-line utility for reporting file system disk space usage.", 28 | "alias": "no", 29 | "group": "yes", 30 | "bookmark": "no" 31 | }, 32 | "zoxide": { 33 | "description": "A faster way to navigate your filesystem. It acts as replacement for cd command.", 34 | "alias": "no", 35 | "group": "yes", 36 | "bookmark": "no" 37 | }, 38 | "eza": { 39 | "description": "A simple and fast command-line file manager. It is a replacement for ls command.", 40 | "alias": "no", 41 | "group": "yes", 42 | "bookmark": "no" 43 | }, 44 | "fzf": { 45 | "description": "A command-line fuzzy finder. It is used to search and open files. It is AMAZING once setup properly with key bindings and previews.", 46 | "alias": "no", 47 | "group": "yes", 48 | "bookmark": "no" 49 | }, 50 | "bat": { 51 | "description": "A cat clone with wings. It is used to display file contents with syntax highlighting.", 52 | "alias": "no", 53 | "group": "yes", 54 | "bookmark": "no" 55 | }, 56 | "wget": { 57 | "description": "A command-line utility for downloading files from the web.", 58 | "alias": "no", 59 | "group": "yes", 60 | "bookmark": "no" 61 | }, 62 | "procs": { 63 | "description": "A modern replacement for ps written in Rust.", 64 | "alias": "no", 65 | "group": "yes", 66 | "bookmark": "no" 67 | }, 68 | "rip": { 69 | "description": "You use rip instead of rm. You can recover files deleted by rip. Although later you can permanent delete too.", 70 | "alias": "no", 71 | "group": "yes", 72 | "bookmark": "no" 73 | }, 74 | "gping": { 75 | "description": "A ping tool with a graph.", 76 | "alias": "no", 77 | "group": "yes", 78 | "bookmark": "no" 79 | }, 80 | "cmus": { 81 | "description": "A small, fast and powerful console music player for Unix-like operating systems.", 82 | "alias": "no", 83 | "group": "yes", 84 | "bookmark": "no" 85 | }, 86 | "hexdump": { 87 | "description": "A command-line utility that displays the contents of a file in hexadecimal, decimal, octal, or ASCII format.", 88 | "alias": "no", 89 | "group": "yes", 90 | "bookmark": "no" 91 | }, 92 | "objdump": { 93 | "description": "Display information from object files. Mainly wanna use this for binary files like `objdump -d `", 94 | "alias": "no", 95 | "group": "yes", 96 | "bookmark": "no" 97 | }, 98 | "file": { 99 | "description": "Determine file type and more information which is a must when reverse engineering binary files.", 100 | "alias": "no", 101 | "group": "yes", 102 | "bookmark": "no" 103 | }, 104 | "exiftool": { 105 | "description": "Read meta information in files. It is very handy.", 106 | "alias": "no", 107 | "group": "yes", 108 | "bookmark": "no" 109 | }, 110 | "chmod": { 111 | "description": "Change file permissions. You can use chmod +x to make it executable.", 112 | "alias": "no", 113 | "group": "yes", 114 | "bookmark": "no" 115 | }, 116 | "chown": { 117 | "description": "Change file owner and group.", 118 | "alias": "no", 119 | "group": "yes", 120 | "bookmark": "no" 121 | }, 122 | "strings": { 123 | "description": "Print the strings of printable characters in files. It is very useful for reverse engineering.", 124 | "alias": "no", 125 | "group": "yes", 126 | "bookmark": "no" 127 | } 128 | } -------------------------------------------------------------------------------- /library/Terminal Utilities/groups.json: -------------------------------------------------------------------------------- 1 | { 2 | "Terminal-Utilities":{ 3 | "description": "Tools for terminal you have which you love.", 4 | "commands": [ 5 | "btop", 6 | "neofetch", 7 | "ncdu", 8 | "fdupes", 9 | "df", 10 | "zoxide", 11 | "eza", 12 | "fzf", 13 | "bat", 14 | "wget", 15 | "procs", 16 | "rip", 17 | "gping", 18 | "cmus", 19 | "hexdump", 20 | "objdump", 21 | "file", 22 | "exiftool", 23 | "chmod", 24 | "chown", 25 | "strings" 26 | ] 27 | } 28 | } -------------------------------------------------------------------------------- /library/docker/commands.json: -------------------------------------------------------------------------------- 1 | { 2 | "docker": { 3 | "description": "docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package.", 4 | "alias": "no", 5 | "group": "yes", 6 | "bookmark": "no" 7 | }, 8 | "docker --version": { 9 | "description": "Display the version of Docker that is installed on the system.", 10 | "alias": "no", 11 | "group": "yes", 12 | "bookmark": "no" 13 | }, 14 | "docker run hello-world": { 15 | "description": "This command is used to verify that Docker is installed correctly and that you can run containers.", 16 | "alias": "no", 17 | "group": "yes", 18 | "bookmark": "no" 19 | }, 20 | "docker images": { 21 | "description": "This command is used to list all of the images that are stored on the system.", 22 | "alias": "no", 23 | "group": "yes", 24 | "bookmark": "no" 25 | }, 26 | "docker ps": { 27 | "description": "This command is used to list all of the containers that are currently running on the system.", 28 | "alias": "no", 29 | "group": "yes", 30 | "bookmark": "no" 31 | }, 32 | "docker ps -a": { 33 | "description": "This command is used to list all of the containers that are currently running on the system, including those that are stopped.", 34 | "alias": "no", 35 | "group": "yes", 36 | "bookmark": "no" 37 | }, 38 | "docker run ": { 39 | "description": "This command is used to run a container from an image.", 40 | "alias": "no", 41 | "group": "yes", 42 | "bookmark": "no" 43 | }, 44 | "docker rmi ": { 45 | "description": "This command is used to remove an image from the system.", 46 | "alias": "no", 47 | "group": "yes", 48 | "bookmark": "no" 49 | }, 50 | "docker rm ": { 51 | "description": "This command is used to remove a container of id `container-id` from the system.", 52 | "alias": "no", 53 | "group": "yes", 54 | "bookmark": "no" 55 | }, 56 | "docker stop ": { 57 | "description": "This command is used to stop a container of id `container-id`.", 58 | "alias": "no", 59 | "group": "yes", 60 | "bookmark": "no" 61 | }, 62 | "docker start ": { 63 | "description": "This command is used to start a container of id `container-id`.", 64 | "alias": "no", 65 | "group": "yes", 66 | "bookmark": "no" 67 | }, 68 | "docker exec -it /bin/bash": { 69 | "description": "This command is used to open a shell inside a running container of id `container-id`.", 70 | "alias": "no", 71 | "group": "yes", 72 | "bookmark": "no" 73 | }, 74 | "docker build -t .": { 75 | "description": "This command is used to build an image from a Dockerfile. The -t flag is used to tag the image with a name.", 76 | "alias": "no", 77 | "group": "yes", 78 | "bookmark": "no" 79 | }, 80 | "docker push ": { 81 | "description": "This command is used to push an image to a registry such as Docker Hub.", 82 | "alias": "no", 83 | "group": "yes", 84 | "bookmark": "no" 85 | }, 86 | "docker pull ": { 87 | "description": "This command is used to pull an image from a registry such as Docker Hub.", 88 | "alias": "no", 89 | "group": "yes", 90 | "bookmark": "no" 91 | }, 92 | "docker tag ": { 93 | "description": "This command is used to tag an image with a new name.", 94 | "alias": "no", 95 | "group": "yes", 96 | "bookmark": "no" 97 | }, 98 | "docker login": { 99 | "description": "This command is used to log in to a Docker registry such as Docker Hub.", 100 | "alias": "no", 101 | "group": "yes", 102 | "bookmark": "no" 103 | }, 104 | "docker logout": { 105 | "description": "This command is used to log out of a Docker registry such as Docker Hub.", 106 | "alias": "no", 107 | "group": "yes", 108 | "bookmark": "no" 109 | }, 110 | "docker network ls": { 111 | "description": "This command is used to list all of the networks that are available on the system.", 112 | "alias": "no", 113 | "group": "yes", 114 | "bookmark": "no" 115 | }, 116 | "docker network inspect ": { 117 | "description": "This command is used to inspect a network of name `network-name`.", 118 | "alias": "no", 119 | "group": "yes", 120 | "bookmark": "no" 121 | } 122 | } -------------------------------------------------------------------------------- /library/docker/groups.json: -------------------------------------------------------------------------------- 1 | { 2 | "docker":{ 3 | "description": "Docker is a platform for developers and sysadmins to develop, ship, and run applications. Docker lets you quickly assemble applications from components and eliminates the friction that can come when shipping code. Docker lets you get your code tested and deployed into production as fast as possible.", 4 | "commands": [ 5 | "docker", 6 | "docker --version", 7 | "docker run hello-world", 8 | "docker images", 9 | "docker ps", 10 | "docker ps -a", 11 | "docker run ", 12 | "docker rmi ", 13 | "docker rm ", 14 | "docker stop ", 15 | "docker start ", 16 | "docker exec -it /bin/bash", 17 | "docker build -t .", 18 | "docker push ", 19 | "docker pull ", 20 | "docker tag ", 21 | "docker login", 22 | "docker logout", 23 | "docker network ls", 24 | "docker network inspect " 25 | ] 26 | } 27 | } -------------------------------------------------------------------------------- /library/git/commands.json: -------------------------------------------------------------------------------- 1 | { 2 | "git": { 3 | "description": "The stupid content tracker", 4 | "alias": "no", 5 | "group": "yes", 6 | "bookmark": "no" 7 | }, 8 | "git init": { 9 | "description": "Create an empty Git repository or reinitialize an existing one", 10 | "alias": "no", 11 | "group": "yes", 12 | "bookmark": "no" 13 | }, 14 | "git clone": { 15 | "description": "Clone a repository into a new directory", 16 | "alias": "no", 17 | "group": "yes", 18 | "bookmark": "no" 19 | }, 20 | "git add": { 21 | "description": "Add file contents to the index", 22 | "alias": "no", 23 | "group": "yes", 24 | "bookmark": "no" 25 | }, 26 | "git commit": { 27 | "description": "Record changes to the repository", 28 | "alias": "no", 29 | "group": "yes", 30 | "bookmark": "no" 31 | }, 32 | "git push": { 33 | "description": "Update remote refs along with associated objects", 34 | "alias": "no", 35 | "group": "yes", 36 | "bookmark": "no" 37 | }, 38 | "git pull": { 39 | "description": "Fetch from and integrate with another repository or a local branch", 40 | "alias": "no", 41 | "group": "yes", 42 | "bookmark": "no" 43 | }, 44 | "git log": { 45 | "description": "Show commit logs", 46 | "alias": "no", 47 | "group": "yes", 48 | "bookmark": "no" 49 | }, 50 | "git status": { 51 | "description": "Show the working tree status", 52 | "alias": "no", 53 | "group": "yes", 54 | "bookmark": "no" 55 | }, 56 | "git branch": { 57 | "description": "List, create, or delete branches", 58 | "alias": "no", 59 | "group": "yes", 60 | "bookmark": "no" 61 | }, 62 | "git checkout": { 63 | "description": "Switch branches or restore working tree files", 64 | "alias": "no", 65 | "group": "yes", 66 | "bookmark": "no" 67 | }, 68 | "git merge": { 69 | "description": "Join two or more development histories together", 70 | "alias": "no", 71 | "group": "yes", 72 | "bookmark": "no" 73 | }, 74 | "git rebase": { 75 | "description": "Reapply commits on top of another base tip", 76 | "alias": "no", 77 | "group": "yes", 78 | "bookmark": "no" 79 | }, 80 | "git reset": { 81 | "description": "Reset current HEAD to the specified state", 82 | "alias": "no", 83 | "group": "yes", 84 | "bookmark": "no" 85 | }, 86 | "git revert": { 87 | "description": "Revert some existing commits", 88 | "alias": "no", 89 | "group": "yes", 90 | "bookmark": "no" 91 | }, 92 | "git stash": { 93 | "description": "Stash the changes in a dirty working directory away", 94 | "alias": "no", 95 | "group": "yes", 96 | "bookmark": "no" 97 | }, 98 | "git tag": { 99 | "description": "Create, list, delete or verify a tag object signed with GPG", 100 | "alias": "no", 101 | "group": "yes", 102 | "bookmark": "no" 103 | }, 104 | "git fetch": { 105 | "description": "Download objects and refs from another repository", 106 | "alias": "no", 107 | "group": "yes", 108 | "bookmark": "no" 109 | }, 110 | "git remote": { 111 | "description": "Manage set of tracked repositories", 112 | "alias": "no", 113 | "group": "yes", 114 | "bookmark": "no" 115 | }, 116 | "git diff": { 117 | "description": "Show changes between commits, commit and working tree, etc", 118 | "alias": "no", 119 | "group": "yes", 120 | "bookmark": "no" 121 | }, 122 | "git blame": { 123 | "description": "Show what revision and author last modified each line of a file", 124 | "alias": "no", 125 | "group": "yes", 126 | "bookmark": "no" 127 | }, 128 | "git show": { 129 | "description": "Show various types of objects", 130 | "alias": "no", 131 | "group": "yes", 132 | "bookmark": "no" 133 | }, 134 | "git grep": { 135 | "description": "Print lines matching a pattern", 136 | "alias": "no", 137 | "group": "yes", 138 | "bookmark": "no" 139 | }, 140 | "git bisect": { 141 | "description": "Use binary search to find the commit that introduced a bug", 142 | "alias": "no", 143 | "group": "yes", 144 | "bookmark": "no" 145 | }, 146 | "git reflog": { 147 | "description": "Manage reflog information", 148 | "alias": "no", 149 | "group": "yes", 150 | "bookmark": "no" 151 | }, 152 | "git cherry-pick": { 153 | "description": "Apply the changes introduced by some existing commits", 154 | "alias": "no", 155 | "group": "yes", 156 | "bookmark": "no" 157 | }, 158 | "lazygit": { 159 | "description": "Simple terminal UI for git commands. You use this for git no matter what!", 160 | "alias": "no", 161 | "group": "no", 162 | "bookmark": "no" 163 | } 164 | } -------------------------------------------------------------------------------- /library/git/groups.json: -------------------------------------------------------------------------------- 1 | { 2 | "git":{ 3 | "description": "Version control system Git. These are some commands you use in often.", 4 | "commands":[ 5 | "git", 6 | "lazygit", 7 | "git init", 8 | "git clone", 9 | "git add", 10 | "git commit", 11 | "git push", 12 | "git pull", 13 | "git log", 14 | "git status", 15 | "git log", 16 | "git branch", 17 | "git checkout", 18 | "git merge", 19 | "git rebase", 20 | "git reset", 21 | "git revert", 22 | "git stash", 23 | "git tag", 24 | "git fetch", 25 | "git remote", 26 | "git diff", 27 | "git blame", 28 | "git show", 29 | "git grep", 30 | "git bisect", 31 | "git reflog", 32 | "git cherry-pick" 33 | ] 34 | } 35 | } -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["poetry-core>=1.0.0"] 3 | build-backend = "poetry.core.masonry.api" 4 | 5 | [tool.poetry] 6 | name = "cheatshh" 7 | version = "1.1.1" 8 | description = "Interactive CLI for managing command line cheatsheets, written in shell script." 9 | authors = ["Anirudh Gupta"] 10 | readme = "Pypi_README.md" 11 | classifiers=[ 12 | "Development Status :: 5 - Production/Stable", 13 | "Intended Audience :: Developers", 14 | "License :: OSI Approved :: Apache Software License", 15 | "Topic :: System :: Shells", 16 | "Programming Language :: Python :: 3.9", 17 | "Programming Language :: Python :: 3.10", 18 | "Programming Language :: Python :: 3.11", 19 | "Programming Language :: Python :: 3.12", 20 | "Operating System :: POSIX", 21 | "Operating System :: MacOS", 22 | ] 23 | homepage = "https://github.com/AnirudhG07/cheatshh" 24 | keywords=["cheatsheet", "cheat", "command-line", "CLI", "shell-script"] 25 | 26 | [tool.poetry.dependencies] 27 | python = "^3.9" 28 | fuzzyfinder = "^2.0.0" 29 | whiptail = "^0.2.0" 30 | setuptools = "^70.1.0" 31 | fzf-bin = "^0.55.0" 32 | 33 | [tool.poetry.dev-dependencies] 34 | 35 | [tool.poetry.scripts] 36 | cheatshh = "cheatshh.main:main" 37 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | fzf-bin 2 | whiptail 3 | yq 4 | jq 5 | --------------------------------------------------------------------------------