Utility to make the values of terminal-dependent capabilities and information available to the shell. Often used to set shell color.
Questions tagged [tput]
72 questions
2
votes
2 answers
Obtain cursor color in terminal
Is there any way to determine what the color of the cursor is in a terminal running something like vim? I know that you can use tput cols and tput rows to determine the height and width of the terminal, are there similar tools for cursor…

Grioip
- 31
- 2
2
votes
1 answer
Unable to execute `tput` command with std::io::process::Command
When I run tput cols in my terminal, it prints out the number of columns just fine. But when I run the following Rust program:
use std::io::process::{Command, ProcessOutput};
fn main() {
let cmd = Command::new("tput cols");
match…

Kurtis Nusbaum
- 30,445
- 13
- 78
- 102
2
votes
2 answers
How do I get colored output to a file from a bash script running in crontab?
When I run a bash script manually, the output appends my log file in the color specified using tput. When I run the bash script as a cronjob, the output loses the color. Thanks.

Ralph Shinevar
- 21
- 2
2
votes
1 answer
PHP tput: No value for $TERM and no -T specified
I'm having the following error when using the exec() function:
string(25) "/etc/init.d/mast list-log"
array(1) { [0]=> string(44) "tput: No value for $TERM and no -T specified" }
tput: No value for $TERM and no -T specified
My command is…

Édouard Lopez
- 40,270
- 28
- 126
- 178
1
vote
1 answer
tput ed doesn't work once terminal starts scrolling
I'm writing an interactive bash script, which needs to keep editing its own output. For the sake of example let's say it looks like this:
tput sc # Store the cursor position.
while true; do
tput rc # Restore the cursor position.
tput ed…

Verpous
- 588
- 3
- 7
1
vote
1 answer
Inline Printing For Zsh Autosuggestions adding extra space when deleting
I am working to create a zsh script that gives auto completions and I am trying to do inline suggestions using tput and echoing the expected rest of the input. It works fine for when adding a character but when deleting there is an extra space where…

BigWinnz101
- 61
- 1
- 5
1
vote
2 answers
Can I push/pop attributes with tput?
In the answer to this question, it uses the following (simplified):
echo "this is $(tput bold)bold$(tput sgr0) but this isn't"
But that tput sgr0 resets all of the text attributes.
I'd like to output coloured text, with only some of it in bold. So…

Roger Lipscombe
- 89,048
- 55
- 235
- 380
1
vote
1 answer
why does ''tput ed'' delete lines, instead of just clearing one line?
i want to rewrite first line but tput is removing all lines instead of first line
im testing this
cl=$(tput ed)
tput sc
echo 'line1____'
echo 'line2____'
echo 'line3____'
sleep 1
tput rc
echo "abc$cl"
echo ''
echo ''
sleep 1
when done it should…

stuffy
- 48
- 1
- 5
1
vote
3 answers
Parallel subshells doing work and report status
I am trying to do work in all subfolders in parallel and describe a status per folder once it is done in bash.
suppose I have a work function which can return a couple of statuses
#param #1 is the folder
# can return 1 on fail, 2 on sucess, 3 on…

Joel
- 1,725
- 3
- 16
- 34
1
vote
1 answer
Python3 + How to change the output color when using print command
as maybe some of you know and regarding to shell scripts - tput is utility uses the terminfo database to make the values of terminal-dependent capabilities and information available to the shell
in my python script I have the following example: (…

jessica
- 2,426
- 24
- 66
1
vote
1 answer
tput: No value for $TERM and no -T specified while using Ruby Net:SSH
I'm using the Ruby Net:SSH lib to do a ssh connection to a remote PC and then execute a remote cmd.
When I start my SSH connection I have no issue but sometimes, not everywhere, when I use the exec! I have an error returned into the stderr which is…

Frage
- 13
- 4
1
vote
1 answer
How to make a blinking printf command (using tput) stop manually after a while in bash (Ubuntu 18.04)?
I know that I can use the below command to blink a prinf or an echo command but how to stop it after a while or after a process is complete? I am writing a script and the blinking would indicate a process is being executed, once it stopped the user…

Mithun Kinarullathil
- 97
- 1
- 6
1
vote
1 answer
Terminal-agnostic color printing in C without using ncurses
I'm writing a C program that outputs test results, and I'd like it to print them in color so it's easier to scan through the results. I initially just used ANSI color codes (per https://stackoverflow.com/a/23657072/4954731), but a code reviewer…

sheesania
- 237
- 3
- 8
1
vote
0 answers
Quarkus: How to print logs in a specific color?
I have a multi-module Gradle project with Quarkus services. I run them all together and I would like to be able to distinguish logs by color. I want different services print logs in different colors (so that I could distinguish them easily).
I am…

Sasha Shpota
- 9,436
- 14
- 75
- 148
1
vote
2 answers
Redirecting stderr changes the output of tput but only when capturing the output to a variable?
I'm trying to get the width of the current terminal window in a script and use 80 as a fallback in case that isn't possible. I thought that's pretty simple:
cols=$( tput cols || echo 80 ) ; echo $cols
# -> 100
100 is correct, I made the terminal…

Mecki
- 125,244
- 33
- 244
- 253