Search

Learn to Program with a Terminal Utility

A Cheat Sheet via the command line.


Learn to Program with a Terminal Utility

Cheat.sh is a command line utility based on a concise documentation repository dedicated to learning programming languages ​​from scratch. You have access to Cheat Sheet for 58 programming languages, covering all popular languages ​​and more.

Installation

To use it is very simple, you will need to have [curl](https://en.terminalroot.com.br/12-tips-for-you-to-use-commando-curl-as-a-ninja/ installed and then just run the command below:

curl cheat.sh

On the “home page” you already get a quick guide to use. And to use quick help, just rotate:

curl cht.sh/:help

Using

Well, the use is as intuitive as the home page, but let’s look at examples. Assuming you are studying the Lua programming languages ​​, just run the command:

curl cht.sh/lua

Before that you need to have the dependencies installed, they are: xsel and rlwrap, use your distro’s package manager (apt, dnf, pacman, …). As I use Gentoo, Portage allows me to search both dependencies on one line and install them:

Gentoo Portage cheat.sh

And then just install them:

sudo emerges xsel rlwrap

GENTOO TIP If you also use Gentoo and are currently compiling some other software, don’t wait for it to finish, Portage doesn’t use locks .lock like APT that only allow a single instance, you can compile/install several parallel programs.

Of course, this will only be a brief introduction. But to go further, I recommend you get the utility on your system, for this: download and install globally with the commands:

mkdir -p ~/.local/bin
curl https://cht.sh/:cht.sh > ~/.local/bin/cht.sh
chmod +x ~/.local/bin/cht.sh
echo 'export PATH="${PATH}:${HOME}/.local/bin"' | tee -a ~/.bashrc
source ~/.bashrc

This procedure is for BASH if you use ZSH, FISH or any other Shell change the configuration file ~/.bashrc by the corresponding file of your Shell, example for ZSH: ~/.zshrc

Command Line Use

Continuing with our example of programming languages ​​Lua. You can enter a subshell directly from the prompt, example, starting the shell inside the language directory:

cht.sh --shell
cd lua

The output will be similar to this image:

cht.sh shell cd lua

Within the subshell you can search for any content you want to get information, for example, search on Lua reverse lists:

Example:

cht.sh/lua> reverse list
- [[
   [iterator - How to iterate Lua table from end?
   [
   [Thank you, @Piglet, for useful link.
   ]]

local function reversedipairsiter (t, i)
    i = i - 1
    if i ~ = 0 then
        return i, t [i]
    end
end
function reversedipairs (t)
    return reversedipairsiter, t, #t + 1
end

- Actually, I figured out an easier way may be to

local mytable = {'a', 'b', 'c'}
for i = #mytable, 1, -1 do
    value = mytable [i]
    print (i .. ":" .. value)
end
cht.sh/lua>

To exit, just type: exit.

Cool, right ?!

Conclusion

I particularly use this utility a lot and I wanted to share it with you, because I believe that the readers of this blog are very similar to me and are studying several things today! :)

Remembering that there are several subjects and languages ​​in cht.sh for more details visit the website: cheat.sh and GitHub from them.

Thanks and see you next time!


terminal programming commands


Share



Comments