less, Powerful Not-So-CLI (:-) Text Viewer and Launcher

Miscellaneous tools
Message
Author
User avatar
tallboy
Posts: 1760
Joined: Tue 21 Sep 2010, 21:56
Location: Drøbak, Norway

#31 Post by tallboy »

Late (from me) but good: Thank you Keef! :D
There was an interesting comment in response to the link you posted on libtinfo:
Alice Chapman Says:
December 24th, 2009 at 5:11 pm

The lack of libtinfo.so is not so much a specific Ubuntu oddity, some other distributions don’t provide it either. The default behaviour when building NCurses is not to produce a separate libtinfo.so. It is only done when adding the –with-termlib switch to the NCurses configure script when building NCurses.

I do agree that linking libtinfo.so explicitly is broken behaviour, as it will not exist with a default shared library build of NCurses.

The same issue can arise with libtic.so, which can also be built as a separate library from libncurses.so by use of the –with-ticlib switch.
musher0, it may be something to remember if ncurses is used in later versions of puppy, a recompile will solve the problem(s). I have run into the problem before, but I cannot recall which program that refused to open.
Keef wrote:This is the important bit:
Code:
cd /usr/lib
ln -s libncurses.so.5 libtinfo.so.5
ln -s libtinfo.so.5 libtinfo.so
When browsing my /lib and /usr/lib in my LupuPlus 5.2.8_005-1., I discovered something very odd.

In my /lib:
libncurses.so.5 -> libncurses.so.5.7

In my /usr/lib:
libncurses.so -> /lib/libncurses.so.5
libncurses.so.5 -> libtermcap.so What the h...??
and then
libtermcap.so -> libncurses.so More what the h...??
So I made symlinks in /lib and /usr/lib:

Code: Select all

cd /lib
ln -s libncurses.so.5.7 libtinfo.so.5
cd /usr/lib
ln -s /lib/libncurses.so.5.7 libtinfo.so.5
It works! Now I have to find out what the mysterious libtermcap.so link is intended for! I have installed lynx, xpdf and pdftk, and I suspect one of them needed that link.

Finally my old $LESS:

Code: Select all

export LESS='-Ij20Wsz-5M'
You have to check out the option list for that one! :D

EDIT: If you install the companion .pet, right-clicking on a bin-file let you choose view-with-less.sh, which open the text in a urxvt window. The problem is that you get the question: This file seem to be a bin file, open anyway? If yes, lots of unreadable code! If you open a terminal instead and write less /bin/somefile, it open as a normal readable file would do. Something is wrong here, musher0.

tallboy
True freedom is a live Puppy on a multisession CD/DVD.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#32 Post by musher0 »

Hello, Tallboy.

I don't have the problem you mention viewing executables. For ex. I have attached a
picture of less "viewing" the wmx executable, with a search for the word "menu".

When less loaded it, there was a line at top saying "==append to filename" and some
other words, and then less picked up the ASCII characters (but not the machine code)
in the file and displayed them. I don't think there is anything wrong. I use that feature
sometimes to see if there are some undocumented commands in an executable.

The only other executable "viewer" I know in Linux is joe ("joe's own editor"), which has
a hex mode. (But I don't have lots of experience with hex editors.)

There is also a hook for less to see "odt" files, and there you will see "garbage" mixed in
with other information, such as word count or paragraph count. Yeah it's not pretty to
look at, but it does not bite ! :)

Again, I find this helpful when I want to refresh my memory about word count and such.
Using less is instantaneous, no need to wait for OpenOffice to load. You type "/" and the
word "count", and you soon know !

As to the extra libraries, I had similar surprises as you had, but I'll have to back-track
what I did. Keef's short message was extremely helpful in this.

If I remember correctly, I cleaned up the libs. I believe I had ncurses-blabla-
so-version in /lib and /usr/lib, which is unnecessary. Only one copy is necessary, of
course.

BFN

musher0
Attachments
less-viewing-exec.jpg
(56.86 KiB) Downloaded 700 times
Inside-an-odt-file.jpg
(80.13 KiB) Downloaded 785 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#33 Post by musher0 »

Hi, Puppyists.

I believe this could be another interesting tool in the less toolbox:
http://murga-linux.com/puppy/viewtopic. ... ost#815375
It's for viewing pdf files in plain text format. It uses pdftotext and less. Might be useful
for taking a quick glance at what a pdf is about. I find it a little faster than epdfview, if
I may say so.

BFN.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#34 Post by musher0 »

The new less-470 has been out for a few months now, so here you go! :) Enjoy! :)
Attachments
less-470.pet
Should be a drop-in replacement for any of the earlier versions above. The "view-with-less"
script works fine with it, at least on this Slacko-6.0b Puppy.
(106.09 KiB) Downloaded 488 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#35 Post by musher0 »

Hello, people!

I've uploaded a new less script to follow errors while developing scripts or configuring at:
http://murga-linux.com/puppy/viewtopic. ... ost#821855

Enjoy!

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
tallboy
Posts: 1760
Joined: Tue 21 Sep 2010, 21:56
Location: Drøbak, Norway

#36 Post by tallboy »

Thank you, musher0!
Less 470 works!

tallboy
True freedom is a live Puppy on a multisession CD/DVD.

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#37 Post by step »

I'm on Fatdog64 most of the time, so I can't use your pets, but - as a long-time less fan - I still want to thank you for your less posts!
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#38 Post by musher0 »

step wrote:I'm on Fatdog64 most of the time, so I can't use your pets, but - as a long-time less fan - I still want to thank you for your less posts!
Hi, step.

Can't you? Have you tried? Sixty-four-bit machines are advertised as being able to
run 32-bit programs without a sweat, are they not ? :shock:

And thanks for the thanks, of course! My pleasure! :)

BFN.

musher0
Last edited by musher0 on Thu 29 Jan 2015, 06:12, edited 1 time in total.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#39 Post by step »

musher0 wrote:
step wrote:I'm on Fatdog64 most of the time, so I can't use your pets, but - as a long-time less fan - I still want to thank you for your less posts!
Hi, step.

Can't you? Have you tried? Sixty-four--bit machines are advertised as being able to
run 32-bit programs without a sweat, are they not ? :shock:

And thanks for the thanks, of course! My pleasure! :)

BFN.

musher0
No I haven't tried yours. Fatdog64 already includes less, albeit an older version. The thing is that I've been nailed on Windows for a few days, and will continue to be so for awhile. I don't get enough play time on my fav linux desktop. :(
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#40 Post by musher0 »

Hi, folks.

Sorry for not referring to the paragraph directly, but the page has no subdivision or
"tag", in html parlance, to refer to.

It's from the less FAQ at http://www.greenwoodsoftware.com/less/faq.html#tricks
Cool less tricks

New users of less sometimes find that less doesn't behave exactly the way they
expect. If this is the case, don't despair. Less has an enormous number of options
(perhaps too many) which let you change the way it behaves. Chances are, there is a
way to make less do what you want. A complete description of all these features is in
the less man page, but here's a summary of some of the more popular ones.

Quit at end-of-file
To make less automatically quit as soon as it reaches the end of the file (so you don't
have to hit "q"), set the -E option.

Verbose prompt
To see a more verbose prompt, set the -m or -M option. You can also design your own
prompt; see the man page for details.

Clear the whole screen
To make less clear and repaint the screen rather than scrolling when you move to a
new page of text, set the -C option.

Case-less searches
To treat upper-case and lower-case letters the same in searches, set the -I option.

Start at a specific place in the file
To start at a specific line number, say line 150, use "less +150 filename". To start
where a specific pattern first appears, use "less +/pattern filename". To start at the
end of the file, use "less +G filename".

Scan all instances of a pattern in a set of files
To search multiple files, use "/*pattern" instead of just "/pattern". To do this from the
command line, use "less '+/*pattern' ...". Note that you may need to quote the "+/
*pattern" argument to prevent your shell from interpreting the "*".

Watch a growing file
Use the F command to go to the end of the file and keep displaying more text as the
file grows. You can do this from the command line by using "less +F ...".

Change keys
The lesskey program lets you change the meaning of any key or sequence of keys. See
the lesskey man page for details.

Save your favorite options
If you want certain options to be in effect whenever you run less, without needing to
type them in every time, just set your "LESS" environment variable to the options you
want. (If you don't know how to set an environment variable, consult the
documentation for your system or your shell.) For example, if your LESS environment
variable is set to "-IE", every time you run less it will do case-less searches and quit at
end-of-file.
BFN.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#41 Post by musher0 »

Hi.

I couldn't get j4-dmenu to compile. There was a message about the
compiler not being able to connect to the j4-dmenu github site properly.
I got the same message with any archive variant of j4-dmenu. So I
used less to take my revenge! :wink:

Using less, I wrote a pseudo-dmenu to list the executables buried in the
*.desktop files at /usr/share/applications.

Image

It works like this: you launch the list, you find the app you want to
launch in the list, then you type <!application > on the line provided by
less. You can alternatively highlight the name of the app in the list, copy
it with the middle button of your mouse, and then type exclamation
mark, Shift-Insert and Return.

To return to the list immediately after the program is launched, you can
add space+ampersand to the name of the executable.

For example, to launch dillo and return to the list immediately:

Code: Select all

!dillo &
Another usage note, from the script itself:
(...)
# Usage: from CLI you can limit the display to a subset, like so:
# menu-share-apps.sh p will list all p*.desktop files.
# From the launcher, lists all *.desktop files.(...)
So you can also work this script selectively from the command line
terminal and ask for a reduced listing, for the a*.desktop files or
the p*.desktop files, for example.

If you use the launcher, all entries are displayed. This script launcher is
also in the zip archive below.

Finally, the entries are numbered. Numbering makes it easier for you to
find your way around in the list. Power users can easily have up to 300
*.desktop files in /usr/share/applications. So, numbering is good.

Caveat 1: please check your *.desktop files for any composite line at
< Exec= >, make those into executable wrappers in a suitable folder,
and replace the composite line with the name of the wrapper. Same
with < java -jar etc. > commands, and with lines containing a "%" sign.
This is not a frivolous request. If you don't do that, the list will become
jaggered, and the program <> category concordance will be off.

Caveat 2: launching programs through less exposes their errors in the
alternate panel that opens in less... Users, do not be surprised,
although you will be, undoubtedly. Some well-known apps are full of
errors, you'll see... and they run in spite of them, God knows why!

Programmers: I didn't do this on purpose, less has always been like
that, and launching an app from any terminal shows the same. So
please double-check, triple-check, quadruple-check your work if you
don't want to lose face???!!! :oops:

TODO: a *.desktop file for this script! :wink: (hehe)

In short, I wrote this script out of spite, but by golly, it turned out to
be almost as good as dmenu, and it has its own pluses. So I decided to
keep it! Enjoy!

musher0
Attachments
menu-shareapps.sh.zip
To use, unpack this zip file in /root/my-applications/bin and make the two
scripts executable.
(1.55 KiB) Downloaded 353 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#42 Post by musher0 »

Hello.

This is for those who prefer viewing the *.desktop list by category.
Same idea as above, except that the category column appears first.
Has its own launcher as well.

Useful tips once in less:
* the / key starts a search
* the n key continues it
* typing h brings up the help page.

BFN.

musher0
Attachments
menu-shareapps-cat.zip
Unzip in /root/my-applications/bin so the two scripts will be in your path.
Make executable to run.
(1.76 KiB) Downloaded 325 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#43 Post by musher0 »

User note

If you intend to close the category list after having launched a program
from it, launch the program like so:

Code: Select all

!nohup program
(Found on an archlinux forum thread. Starting at # 10 on that page.)

The < nohup program > command sort of breaks the relationship
between the launcher and the program and frees the program from the
launcher. (My weak understanding.) Otherwise, if you simply launch the
program with

Code: Select all

!program
and you later exit the category list by typing 'q', the program you just
launched will close too. Save yourself the frustration and launch your
program with:

Code: Select all

!nohup program
Bye for now.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#44 Post by musher0 »

Hello, all.

Here is an enriched version of the menu-ShareApps-cat script above.
  • * Has two additional help lines at the bottom explaining how to
    __ launch a listed app using the middle-button of your mouse
    * Integrates info in previous post
    * Contains its own desktop file
    * Smaller footprint on screen
    * Presented as a *.pet file.
Enjoy! BFN.

musher0
Attachments
menu-ShareApps-cat_2015-03-27.jpg
Running here under wmx-8, but may used with any window manager.
(31.12 KiB) Downloaded 300 times
menu-ShareApps-cat-0.2.pet
(6.97 KiB) Downloaded 394 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
tallboy
Posts: 1760
Joined: Tue 21 Sep 2010, 21:56
Location: Drøbak, Norway

#45 Post by tallboy »

It works like this: you launch the list, you find the app you want to
launch in the list, then you type <!application > on the line provided by
less. You can alternatively highlight the name of the app in the list, copy
it with the middle button of your mouse, and then type exclamation
mark, Shift-Insert and Return.
Hmmm, I actually use lynx to the same effect, but I usually start by navigating the hierarchy to find a document that I want to open in the application of my choise. Less is one of the applications I use most frequently, and is set in the preferences. Most lynx functions are reached with only the 4 arrow keys. Very fast! 8)

tallboy
True freedom is a live Puppy on a multisession CD/DVD.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#46 Post by musher0 »

Hello, tallboy.

Hmm... Got to check that. But I'm using links2 as my secondary browser.

So you're using lynx to open documents -- html docs I presume?
Also to launch applications? I'm not sure I fully understand your post.

BFN.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
tallboy
Posts: 1760
Joined: Tue 21 Sep 2010, 21:56
Location: Drøbak, Norway

#47 Post by tallboy »

Hi musher0. Although lynx is a text-based web-browser, I mainly use it as a local file browser, because it is so very fast to navigate through a file hierarchy, with three fingers on the arrow keys. When I am in a directory and see the file I want to open, I navigate down the list of files, and when I reach the file, I click the right arrow to open it, in the background if an external program is used. Lynx uses the mime repository to find a suitable application, or a list of applications, your choise! Clicking the left arrow bring you back into the directory, and you can navigate to find other files. Lynx is extremely configurable, you can for example set less to open text documents, if you like that, and there are lots of key shortcuts to use.

I will come back to this matter later, I have a lot of personal family matters which take up much of my time right now. In the meantime, you should download lynx and play! :D

tallboy
Attachments
lynx-1.jpg
Command 'lynx /', and navigating with the down arrow key, right arrow key to enter root/
(54.97 KiB) Downloaded 536 times
lynx-2.jpg
Navigating with the down and right arrow keys
(53.85 KiB) Downloaded 545 times
lynx-3.jpg
Navigating with the down and right arrow key to enter root/my-applications/bin
(31.39 KiB) Downloaded 525 times
lynx-4.jpg
In bin, you want to view the contents of AppStarter by clicking the right arrow key
(49.01 KiB) Downloaded 523 times
lynx-5.jpg
View the content, click left arrow key to close file and get back to the directory
(56.72 KiB) Downloaded 525 times
lynx-6.jpg
Choose the next file, click the right arrow key to open it
(48.93 KiB) Downloaded 522 times
lynx-7.jpg
After this view, click the left arrow to go back to the directory, and then use the up and left arrow keys to navigate back up the hierarchy of directories.
(45.14 KiB) Downloaded 558 times
True freedom is a live Puppy on a multisession CD/DVD.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#48 Post by musher0 »

Hello, all.

I've been busy with another type of launch base | menu based on the less
file pager, the latest version of which is here. It's a bilingual EN & FR version:
it defaults to English if the system language variable ($LANG) is not
French. The script doesn't use any external utility to number entries, but
does include the very nice Anka Coder Condensed font from the Open
Font Library (-- https://fontlibrary.org/en/font/anka-coder-condensed --).

In short, you can use the numbers in the list as well as regular copy-and-
paste to run the apps, from a list generated from the *.desktop files.

I intend to introduce it properly in English in its own thread, but in the
meantime, a couple of tests by brave pioneers would be appreciated.
Thanks in advance.

~~~~
On a more technical front, I've been trying to compile the latest version
of less, v. 481, and I get an error message concerning sed towards the
end of the configure part. I tried to compile it in various Puppies
(librepup, Puppy Precise 5.4.3, Racy 5.5) and the message remains the
same. I never got this message before, so if you know what it's about,
I'd be grateful. There exists an archlinux binary of less-481, but it lacks
some libs to run on our Puppies.

BFN.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#49 Post by musher0 »

Hello all.

The latest less, less version 481, was published 16 Oct 2015.

I compiled it on upupRaring-3.9.9.2 with "local" regex-comp.

The release notes are here.

Enjoy!

mushero
Attachments
less-481.pet
As usual, remove or disable any previous version before installing this one.
(103.12 KiB) Downloaded 404 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Keef
Posts: 987
Joined: Thu 20 Dec 2007, 22:12
Location: Staffordshire

#50 Post by Keef »

musher0

There looks to be a slight error in this section:

Code: Select all

Aide="\t   \E[1;33mType '!appl\. &' or '!nohup appl\. &' AND <Return>,
\t     \E[1;33mor '!0', <Return> and the number of the app, OR
\t\t \E[1;second33m'!0' 'number of the app' and <Return>."
- duplication of the last bit.

I like the idea of terminal app launchers, and this looks good. The method of input does seem a little awkward though. Also, the '!' does not appear until I type it, so the instructions do not tally with what is on the screen
(this is on the latest Slacko 6.3.0).

Post Reply