Questions tagged [tput]

The tput utility uses the terminfo database to make the values of terminal-dependent capabilities and information available to the shell (see sh(1)), to initialize or reset the terminal, or return the long name of the requested terminal type.

52 questions
141
votes
6 answers

tput setaf color table? How to determine color codes?

I am in the process of colorizing my terminal’s PS1. I am setting color variables using tput; for example, here’s purple: PURPLE=$(tput setaf 125) Question: How do I find the color codes (e.g. 125) of other colors? Is there a color table…
mhulse
  • 1,729
  • 2
  • 15
  • 12
24
votes
4 answers

Getting console width using a bash script

I'm encountering an issue where I am trying to get the size of a terminal by using scripts. Normally I would use the command tput cols inside the console, however I want to be able to accomplish this feature by strictly using scripts. As of now I am…
sirgeezer21
  • 343
  • 1
  • 2
  • 7
24
votes
3 answers

What is the difference between tput's 'setf' and 'setaf'?

The command tput has two different options for setting color, setf and setaf, yet both of them seem to work just fine on my computer: $ tput setf 2 && echo 'Hello world!' $ tput setaf 2 && echo 'Hello world!' There seems to be a similar duality…
IQAndreas
  • 10,145
  • 21
  • 59
  • 79
23
votes
1 answer

Hide and unhide cursor with tput

tput civis successfully hides the cursor. tput cvvis should unhide it, but it doesn't. Any idea what the problem might be?
Petr Skocik
  • 28,176
  • 14
  • 81
  • 141
17
votes
1 answer

Full list of tput options

I wanted to hide the cursor, and I was aware of tput command. I did search its man page. On searching the Internet, I found $ tput civis # to hide the cursor $ tput cnorm # to bring back the cursor These work perfectly, but these options are not…
mtk
  • 26,802
  • 35
  • 91
  • 130
16
votes
4 answers

Clear half of the screen from the command-line

Is there some way clear the terminal but instead of leaving the prompt at the top of the screen leaves it in the middle? It looks like clear basically ignores all command-line parameters. I thought there would be some way to do this with tput but…
fizzyh2o
  • 263
  • 2
  • 6
16
votes
4 answers

Is there any objective benefit to escape sequences over tput?

In people's '.*rc' files I see online or in various code, I tend to see a lot of people who manually use ANSI escape sequences instead of using tput. I had the understanding that tput is more universal/safe, so this makes me wonder: Is there any…
Captain Man
  • 1,156
  • 3
  • 12
  • 25
11
votes
5 answers

bash script , echo output in box

I have created this function, which prints the output as seen in the example image. But, the implementation of this function seems too complex. Is there a way that I can improve it or implement an alternative solution? #!/bin/bash function…
Rahul Patil
  • 24,281
  • 25
  • 80
  • 96
9
votes
6 answers

How can I print a variable with padded center alignment?

How can I print $myvar padded so that it is in the center of the terminal, and to either side are = to the edge of the screen?
Wildcard
  • 35,316
  • 26
  • 130
  • 258
8
votes
2 answers

tput: No value for $TERM and no -T specified

I am trying to run a bash script I have via cron, and I am getting the following error at the beginning of the execution: tput: No value for $TERM and no -T specified Here is what is in my crontab: 0 8 * * 1-5 cd /var/www/inv/ &&…
ComputerLocus
  • 183
  • 1
  • 5
7
votes
2 answers

Is it possible to change font colors in the terminal, without impacting printf's "%*s" padding format?

I have a function in a bash script: message_offset which is used to print the status of a bash script. i.e. you would call it passing a message into it and a status, like this message_offset "install font library" "[ OK ]" and it would print…
the_velour_fog
  • 11,840
  • 16
  • 64
  • 109
5
votes
2 answers

tput ed is empty

The output of tput ed is empty and I can't figure out why. Other capabilities work fine. Also ed is not missing from infocmp output so tput should match, right? $ printf '%q' "$(tput ed)" '' $ printf '%q' "$(tput home)" $'\033'\[H I'm using zsh on…
cambunctious
  • 198
  • 8
5
votes
1 answer

How to use the Meta/Alt Key with tput?

I want to redefine keybindings for the commandline of a lisp dialect. The commandline is actually modeled after Vi and implemented with tput/terminfo. I want an alternative version with Emacs keybindings, and I would like to give it a try without…
user17106
  • 153
  • 3
5
votes
3 answers

Print console colors

Wrote a bash function to display the console colors. But, it seems some of the colors are not possible to show that way! (?) Also, note the strange "bright black"! (Note: The below screendump is of xterm, but this is meant to be used in console…
Emanuel Berg
  • 6,763
  • 7
  • 43
  • 65
5
votes
2 answers

Outputting a string in the bottom right corner of the terminal

How do I output a string in the bottom right corner of the terminal?
Petr Skocik
  • 28,176
  • 14
  • 81
  • 141
1
2 3 4