Search notes:

Shell command: tput

Print at specific coordinates

With cup, it's possible to echo a string at specific coordinates:
function print_at {
  x=$1
  y=$2
  text=$3

# Note: first the row, then the column:
  tput cup $y $x; printf "$text (x=$x, y=$y)"

}

clear
print_at  5 10 "hello world"
print_at  8  3 "twenty-four"
print_at 30  8 "bit to the left"
print_at 50  6 "more to the left"
print_at  0 20 "finish"
Github repository shell-commands, path: /tput/cup-coordinates.sh

Colors

for fg_color in {0..7}; do
for bg_color in {0..7}; do

  tput setaf $fg_color; # set foreground color
  tput setab $bg_color; # set background color
  printf "fg=$fg_color, bg=$bg_color"

  tput sgr0 # reset attributes
  printf "\n"

done;
done
Github repository shell-commands, path: /tput/colors.sh
See also ANSI escape sequences

Decorating text

Text can be decorated with a bold or underlined attribute:
y=2

function display_text {
  capname=$1

  tput sgr0  # Turn off all attributes

  tput cup $y 3; printf "This is ";
  tput $capname; printf $capname;

  y=$((y+2)) # move y coordinate downj

}

clear

display_text bold
display_text smul  # underlined text. Can be ended with rmul.
display_text blink # should blink. Does not always work.
display_text invis # invisible text
Github repository shell-commands, path: /tput/decorate-text.sh

See also

Shell commands

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Linux/sh...', 1758200352, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Linux/shell/commands/tput(103): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78