Skip to content

Latest commit

 

History

History
106 lines (74 loc) · 4 KB

README.md

File metadata and controls

106 lines (74 loc) · 4 KB

TermCheat: your terminal cheat sheet

Synopsis

TermCheat is a searchable library of commands that you can copy remix and extend.

TermCheat screenshot

Usage

term-cheat

Even better if you add a keyboard shortcut to start TermCheat e.g. Ctrla

Add this to your .bashrc or .zshrc or ...

bindkey -s '^A' 'term-cheat --filter^M'
  • -s simulate keyboard input
  • ^A Ctrla
  • ^M Enter key to run the command

Keyboard Shortcuts

In list mode

  • enter execute command
  • / to fuzzy filter / search for a command
  • a add new command
  • e edit selected command
  • d delected the selected command

In edit mode

  • esc to leave edit mode without saving
  • ctrl o to save the command to your database

In filter mode

  • esc to clear the filter

Installation

While the package is waiting for approval from the snap store you can install it by downloading it from here and installing it with snap.

curl -OL https://github.com/select/term-cheat/releases/download/0.1.11/term-cheat-0.1.11_amd64.snap
sudo snap install --classic --dangerous term-cheat-0.1.11_amd64.snap

To install it from source do the following.

git clone https://github.com/select/term-cheat.git
cd term-cheat
pipenv install
pipenv shell
python3 term-cheat-app

Related Tools and Projects

Reveser History Search
Search through your shell history with CtrlR

Alias
Create a file that contains aliases for your most used commands. Create a the aliases file with touch ~/.aliases and add some aliases like

alias lt='ls -ltr'
alias df='pydf -h -B'

now source the file in your .bashrc or .zshrc

source $HOME/.aliases

You could write all aliases directly in you rc file but this way it's more portable if you switch from e.g. bash to zsh.

Another trick is to sort your history for the commands you use the most and created aliases for these commands to save you time. Here is a command to get your top ten most used commands:

history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl |  head -n10

Autosuggestions
If you are using zsh there is a neat plugin called zsh-autosuggestions which will automatically show you suggestions of commands you used before that you can complete using the right arrow key.

More Related Projects \

If you got other suggestions I would love to include them here.

Motivation

There are two reasons why I created TermCheat. First of all I love using the terminal and lately I have been learning more things like systemd and just could not remember all the commands on the first go. While I use the zsh-autosuggestions plugin and reverse history search (ctrlr) I still had sometimes problems to recall commands. Furthermore both of these options to not give any additional information about the commands. Most modern editors (sublime-text, atom, ...) now have the option to search for commands with ctrl p which I find super helpful.

The second reason which is even more important for me is that I find text base user interface (tui) very cool. They give you a proper hacker feeling and if done right are beautiful and fast. I wanted to challenge myself and see if I could build such an interface, and voila two weekends later I had the first version of TermCheat running. After working many years on web based interfaces building a tui is a really nice experience because it's pure minimalism.

License

TermCheat is released under the MIT License.