chubin / cheat.sh

the only cheat sheet you need
https://cheat.sh/
MIT License
38.14k stars 1.78k forks source link

paging #158

Open iomari opened 5 years ago

iomari commented 5 years ago

Is there a setting for output pagination other than piping to less?

sentientmachine commented 4 years ago

You are asking about the presentation layer between your browser/terminal and your computer monitor. So no, a programmer can't do this server-side. cheat.sh returns you a long stackoverflow answer, for example this multi-page response here: http://cht.sh/python/rmse/0/1

It is the user's responsibility then, to place that long output into a file, then open it with pagination abilities, and then open it with an appropriate editor.

So pipe the output to a file, then open it up with your favorite editor, like sublime, Notepad, Eclipse, or Emacs, or any of a thousand other editors.

So instead of curl cht.sh/python/rmse/0/1 | less

Try this: curl cht.sh/python/rmse/0/1 > /tmp/myoutput.txt; sublime /tmp/myoutput.txt;

Replacing the word sublime with your editor of choice, be it notepad, textedit, visual studio, xcode, emacs, or any of a thousand other editors. Another approach is using page-up features on your terminal.

This issue should be closed.

chubin commented 4 years ago

@sentientmachine Eric, I am not sure, maybe @iomari means not the service itself (and the case where curl is used directly) but the console client cht.sh. In that case it makes perfect sense, because it could be great to have different options here: less, more, cat etc.

ogaida commented 4 years ago

first of all, what a nice tool !!!

if i pipe the output to less with cht.sh ansible deploy vmware guest|less than there are many ESC-charactes. Is it possible to disable this escaping and print clean text instead?

ESC[38;5;246m# Deploy massive VM guest on VmWare with ansible playbookESC[39m
ESC[38;5;246m# ESC[39m
ESC[38;5;246m# I prefer to use inventories only for configuration management. You canESC[39m
ESC[38;5;246m# do that way but how do you keep track of changes or how do you add newESC[39m
ESC[38;5;246m# item to the stack?ESC[39m
ESC[38;5;246m# ESC[39m
ESC[38;5;246m# From my point of view, the best way is using a yaml configuration fileESC[39m
ESC[38;5;246m# like this:ESC[39m

kind regards Oliver

chubin commented 4 years ago

@ogaida Sure you can, just use the ?T option:

$ cht.sh ansible deploy vmware guest?T

Another option, make less interpret ANSI sequences with -R:

$ cht.sh ansible deploy vmware guest | less -R
ogaida commented 4 years ago

@chubin thank you very much!