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
DAPTUP(8)						      System Manager's Manual							 DAPTUP(8)

NAME
daptup - wrapper script on 'apt-get update' SYNOPSIS
daptup [ --pre | --post | --last ] [ -h | --help ] [ --nocolor ] OPTIONS
--pre Do only 'pre' stage: collect info that will be used as 'old'. Usually need to be specified only in apt hooks. --post If appropriate option is enabled in config file, do only 'post' stage: collect 'new' info and output changes. Otherwise do nothing. Usually need to be specified only in apt hooks. --last Output changes only. This option is supposed to be specified when you want to see changes made in the last update. Note that list of outdated packages, if daptup is configured to output it, will be rebuilt. -h --help prints the help --nocolor Disables color output, useful for scripts or when output is not terminal. Now works only with --last option, however, you can dis- able color globally in configuration file. daptup is a script that runs "apt-get update" inside and outputs list of packages recently entered to repo, list of packages which got new updates, list of changes in 'watched' packages and, optionally, list of outdated packages. Starting with 0.8.0 version, daptup uses apt hooks and you don't need to explicitly call it if you use 'apt-get update'. TROUBLESHOOTING
If daptup was interrupted while building the lists, the cached lists can stay in inconsistent state, which is inappropriate if you want to use --last option before the new update. There is nothing to do if interrupt was occured at the moment when old lists were building (besides running the new update). However, if interrupt was occured when the new lists were building, you can easily redo this stage by calling 'daptup --post'. FILES
/etc/daptup.conf self-documented configuration file /var/spool/daptup/outdated cached file with info about outdated packages SEE ALSO
apt-get(8), aptitude(8), apt-show-versions(1p) AUTHOR
daptup was written by Eugene V. Lyubimkin. This manual page was written by Eugene V. Lyubimkin <jackyf.devel@gmail.com>, for the Debian project (but may be used by others). Oct 15, 2008 DAPTUP(8)
All times are GMT -4. The time now is 05:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy