Sponsored Content
Full Discussion: Using color in scripts
Operating Systems Linux Ubuntu Using color in scripts Post 303033773 by wisecracker on Thursday 11th of April 2019 01:34:29 PM
Old 04-11-2019
Some of these terminal escape codes even 'tput' can't do.
All work on CygWin's 'mintty' terminal too.
Code:
#!/bin/sh

# For those that do not have tput.
# Some of these cannot even be done using tput!
# All work on the majority of terminals but some terminals can't do them all.

# Resize the terminal on the fly, even works on CygWin's mintty, this resizes to 30 rows by 86 columns.
echo "Resize terminal to 30 x 86."
printf "%b" "\033[8;30;86t"
sleep 2
# And resize to a standard size of 24 rows by 80 columns.
echo "Resize terminal to 24 x 80."
printf "%b" "\033[8;24;80t"

# Reset terminal for machines that do not have it.
echo "Reset the terminal."
sleep 2
printf "%b" "\033c\033[0m\033[2J\033[H"

# Clear the screen.
echo "Clear the screen."
sleep 1
printf "%b" "\033[2J\033[H"
echo "Alternate clear screen."
sleep 1
# OR...
printf "%b" "\033[2J\033[1;1f"

# Clear the terminal current buffer only.
printf "%b" "\033[3J"

# Write into the terminal title bar.
printf "%b" "\033]0;Barry Walker.\007"
sleep 2
# And clear it again.
printf "%b" "\033]0;\007"

Enjoy lads and lassies...

Last edited by wisecracker; 04-11-2019 at 02:45 PM..
This User Gave Thanks to wisecracker For This Post:
 

2 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to change the background color in the init 3 mode(not line color)

Hello, I am using RHEL 6.1 on VMware I am searching for a way to change background color (not line by line color wich one can using tput command) basically changing the color of the whole screen to white instead of the default black and changing font color to black and alos would like to... (2 Replies)
Discussion started by: Dexobox
2 Replies

2. UNIX for Beginners Questions & Answers

Text color in Linux scripts via putty

hi Folks, Can anyone help with changing the color of the words in a linux shell script? I get how to change default background etc in putty, but for some reason the text in the script has different colors for different parts of the cript. Is there a way to have one color in a linux shell... (5 Replies)
Discussion started by: jonnyd
5 Replies
tput(1) 						      General Commands Manual							   tput(1)

NAME
tput - query terminfo database SYNOPSIS
type] capname... type] capname [parms...] DESCRIPTION
The command uses the database to make terminal-dependent capabilities and information available to the shell (see terminfo(4)). The com- mand outputs a string if the attribute (capname) is of type string, or an integer if the attribute is of type integer. If the attribute is of type boolean, simply sets the exit code for TRUE, for FALSE), and produces no output. Command-line Arguments The command recognizes the following command-line arguments: Indicates the type of terminal. Normally this flag is unnecessary because the default is taken from the environment variable capname Indicates the attribute from the database. See terminfo(4). In addition, the following capnames are supported: Echo the clear-screen sequence for the current terminal. Echo the initialize sequence for the current terminal. Echo the sequence that will reset the current terminal. parms If the capname takes optional numeric parameters, the parms will be placed in the string output by The capnames are read from stdin and multiple capnames are allowed. Only one capname is allowed per line when reading from stdin. EXTERNAL INFLUENCES
Environment Variables determines the locale to use. This overrides settings of other environment variables. determines the language to use for messages. determines the terminal type if the option is not specified. EXAMPLES
Echo clear-screen sequence for the current terminal. Print the number of columns for the current terminal. Print the number of columns for the 70092 terminal. Set shell variable to stand-out-mode sequence for current terminal. This might be followed by a prompt: Set exit code to indicate if current terminal is a hard copy terminal. Clear the screen, move the cursor to line 10, column 20 and turn on bold. RETURN VALUE
If capname is of type boolean, then the exit code is set to for true and for false. If capname is not of type boolean and fails, an error message is printed, and exit code is set to one of the following depending on the failure: The capability name is of type integer and does not exist. Usage error. Unknown terminal type. Unknown capability name. An error occurred. If the exit code is a is printed if a capability name of type integer is requested for a terminal that has no entry for that capability name in the database (such as FILES
Terminfo data base Definition files SEE ALSO stty(1), untic(1M), terminfo(4). STANDARDS CONFORMANCE
tput(1)
All times are GMT -4. The time now is 06:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy