Questions tagged [tput]
38
questions
2
votes
2answers
89 views
Get terminal status for termcap capabilities
How can one retrieve status of terminal settings like smam and rmam ?
Reason is that I set rmam by:
tput rmam
in script, then proceed to set smam on exit:
tput smam
But if terminal has rmam set when ...
2
votes
2answers
119 views
How to use column with tput colors?
Using tput colors seems to disturb the output of column. Why does this happen and more importantly is there a way around it?
$ {
echo "$(tput bold)foo$(tput sgr0)" "$(tput bold)bar$(tput sgr0)"
...
0
votes
1answer
40 views
BSD (& Linux) tput - basic interoperable color setup
Can anyone on *BSD with GUI please confirm, that the below works on a BSD system correctly or not?
I was trying to create a virtual *BSD test box, but ended up unsuccessful. So, I drained some ...
0
votes
2answers
50 views
Can tput be used with combined capabilities?
For example, if I want the prefix for bold green, I might do Green=$(tput bold; tput setaf 2). This would set $Green to "\E[1m\E[32m". But on an Ansi terminal, it could just as easily have been "\E[1;...
3
votes
2answers
151 views
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)"
''
$ ...
-1
votes
1answer
173 views
tput in a cron job does not output bolded text [duplicate]
I comeback with a very strange behavior
when we run this command on Linux redhat machine
echo "$(tput bold)" start write to log "$(tput sgr0)" >> /tmp/log.txt
we get ended bold text in /tmp/...
0
votes
1answer
75 views
Exit alternate screen after crashed ssh-tmux session
After I get disconnected from my tmux session over ssh (I have to use the ssh ~. command to exit), the mouse start displaying control characters like 80;31M65;80;31M65; when I click or turn the wheel.
...
3
votes
1answer
223 views
All-round 100% portable terminal color support check
Test for terminal color support using tput
#!/bin/sh
colors_supported()
{
command -v tput > /dev/null 2>&1 && tput setaf 1 > /dev/null 2>&1
}
I am currently using ...
1
vote
1answer
13k views
How to set the background color of the Linux console screen?
Note: I reworked the question to clarify the issues. This is a trivial question that can be answered in several parts because the question has several attributes.
Unfortunately, the question may be ...
1
vote
1answer
2k views
What is the ANSI escape equivalent of `tput sgr0`?
To avoid a subshell, what are the ANSI escape equivalents of tput sgr0 for an ANSI-compatible terminal?
-1
votes
2answers
249 views
Why is tput failing silently on TERM=vt100
I'm using zsh with iTerm as my terminal emulator on macOS and my environment has TERM=xterm-256color by default.
If I run tput setaf 3 it exits with code 0.
If I set TERM=vt100 and run tput setaf 3 ...
1
vote
1answer
275 views
tput command doesn't work in if statement
I'm trying to use the tput command in a bash script if statement but for some reason it's behaving unexpectedly. When running the command and then checking the exit code only in the if statement ...
1
vote
0answers
108 views
Less is broken inside GNU Screen
When using less or git log, about the first 30+ lines are missing. I'm using GNU screen in a 2x2 grid, less is running in the bottom right pane.
tput lines returns 65, but that's the total number of ...
3
votes
1answer
871 views
Prevent tput escape sequences when redirecting script output to a file
I have a shell function that colorizes a filename using tput.
color=$( tput setaf 1 )
normal=$( tput sgr0 )
colorize() {
echo "${color}$1$(normal)"
}
When I call the function, the terminal ...
0
votes
2answers
2k views
linux + tput: No value for $TERM and no -T specified
I use in my bash script the tput command in order to colored the text
as
tput setaf 2
when I run the script from putty or console every thing is ok
but when I run some external WIN application ...
2
votes
1answer
1k views
linux + how to use the tput bold in echo command
we have the follwing array - list1 and list2
list1="node23 node76 node 34"
list2="node02 node2 node9 node21"
we want to bold the list2 so list1 will printed without bold and list2 with bold
example
...
2
votes
3answers
1k views
Is multi-line alignment possible with tput?
I would like to position the cursor at a specific row/column and print a multi-line file/command that stays aligned to its first coordinate, so that
tput clear
tput cup 5 15
ping www.google.com
...
7
votes
2answers
1k views
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 ...
0
votes
3answers
469 views
bash: clear string between two positions
I need to clear string in terminal between two positions (not the beginning or end of line). For example, delete all starting from tput cup 5 10 and till tput cup 5 69. One line.
Yes, it's possible ...
18
votes
4answers
13k views
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 ...
11
votes
4answers
5k views
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 ...
2
votes
0answers
237 views
Portable color codes with printf? [duplicate]
There is a color codes script on GitHub suitable for sourcing, which I am modifying for my own purposes.
Background
I have an odd mix of environments to work in, from a Mac OS terminal, to various ...
12
votes
3answers
2k views
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 ...
104
votes
5answers
86k views
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)...
6
votes
2answers
8k views
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?
5
votes
2answers
2k views
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?
0
votes
1answer
607 views
Colorization of BASH script output with tput - how to select good colors? [closed]
I would like to colorize output of one long complex interactive BASH script to make it easier for the user to work with it. I have learned how to use tput, but my question is more matter of design:
...
13
votes
1answer
1k views
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
...
14
votes
1answer
10k views
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?
5
votes
1answer
3k views
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
votes
2answers
1k views
bash scripting tput getting errors [closed]
I need to figure out what is wrong with this tput menu.
#!/bin/bash
tput setb 3
tput clear
function main_menu
{
option=0
until [ "$option" = "4" ]; do
echo " 1.) Monitor existing processes "
echo ...
1
vote
1answer
463 views
tput command + how to locate dialog window on the top of the screen
Is it possible to use the tput command in order to place the dialog window on the top of the screen ?
For example
The following dialog command display the log is running by tail command
dialog -...
18
votes
3answers
12k views
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 &&...
3
votes
1answer
655 views
Cursor movement related tput commands under zsh: can the 'clear' behavior be configured?
Using the zsh shell, I've noticed a difference in the behavior of the tput command compared to bash. For instance With zsh, if you have many things output to a terminal emulator window and you're at ...
9
votes
4answers
13k views
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 ...
2
votes
2answers
2k views
screen buffer and dialog
I was trying to use different screen buffer for my script using tput. Below is small script that I am running.
tput smcup
clear
dialog --yesno "Do you want to continue?" 0 0
rc=$?
clear
tput rmcup
if ...
5
votes
1answer
272 views
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 ...
4
votes
3answers
2k views
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 ...