LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-10-2024, 05:17 AM   #1
jt1122
Member
 
Registered: Apr 2021
Posts: 140

Rep: Reputation: Disabled
Changing formatting strings used by man


Hi,

Code:
LESS_TERMCAP_md=$'\e[1;38;5;82m' man -P "less" ls
would show a coloured man page for ls.

As I understand man embeds the TERMCAP code into the text sent to less.

Can I change this TERMCAP code to some else, e.g. "ABC", which will be embedded in the resulting text?.

I tried
Code:
LESS_TERMCAP_md=$'ABC' man -P "less" ls >o
doesn't show ABC anywhere in the file o.

Thanks
 
Old 02-11-2024, 02:29 PM   #2
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,138
Blog Entries: 6

Rep: Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827
You are not understanding.

Code:
echo $'\e[1;38;5;82m'
 
Old 02-11-2024, 02:33 PM   #3
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,138
Blog Entries: 6

Rep: Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827
Code:
#!/usr/bin/bash

# Term color chart. Term need to be 90 char wide.

for i in 38 48; do
    printf "\n%25s" | tr ' ' .
    printf " %s " "printf '\e[${i};5;<num>\e[0m'"
    printf "%25s\n\n" | tr ' ' .
    for color in {0..255}; do
        if ((color <= 9)); then
            c=""$color"  "
        elif ((color >= 10 && color <= 99)); then
            c=""$color" "
        elif ((color >= 100 && color <= 300)); then
            c="$color"
        fi

        if [ "$i" = 38 ]; then
            printf "\e[${i};5;%sm  %3s  \e[0m" ${color} "FG ${c} ABC"
        elif [ "$i" = 48 ]; then
            printf "\e[${i};5;%sm  %3s  \e[0m" ${color} "BG ${c} ABC"
        fi
        
        if [ $((($color + 1) % 6)) == 0 ]; then
            printf '\n'
        fi
    done
    printf '\n\n'
done
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Do you remember program, which made database of all strings inside file hierarchy, so one could search strings? zimon Linux - Software 7 10-05-2022 12:28 AM
replace strings in a file using strings from another file xpto09 Linux - Newbie 3 01-28-2016 06:11 PM
BASH: replace strings in on file by the strings in another one cristalp Programming 5 10-28-2011 09:47 AM
[SOLVED] Searching and replacing strings in a file with strings in other files xndd Linux - Newbie 16 07-29-2010 02:40 PM
how to find duplicate strings in vertical column of strings markhod Programming 7 11-02-2005 04:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration