Questions tagged [tput]
55 questions
2
votes
1
answer
135
views
How can I get tput to fill the whole background without leaving a border?
I'm using bash in cygwin on a Windows laptop. I'd like to be able to change the background color of my terminal to green (actual color irrelevant) and to do that I can use either of these commands:
...
2
votes
1
answer
93
views
How to "render" ouput from a command playing with tput so only the final terminal-postprocessed result is kept? [duplicate]
I captured the output of a script that uses tput to draw certain things on screen. When I perform cat myoutput then everything is well seen (looks like terminal reinterprets it from beginning), but ...
-1
votes
1
answer
168
views
The Command tput sgr0 Changes my Terminal Font and Text Colour, how to Stop This? Any echo After tput sgr0 Outputs as Bold White
When I do tput sgr0 it changes my terminal font and colour to white (should be black) and looks blocky.
Please see screenshot:
How do I stop this?
To be more concise, any echo after tput sgr 0 seems ...
1
vote
2
answers
843
views
bash script to get current line and row not working
ive written the following script to print out the current line and row every time it changes aka every time i press up,down,left or right but the output is always the same:
row:43:col:141
i believe ...
1
vote
2
answers
132
views
Adding a newline above PS1 that survives prepending
In OBSD ksh, I had a PS1 which prepended a blank line:
PS1="\n[\u@\h] \w\n\$"
The problem with this was that pyenv prepends the name of a virtual environment when that environment is ...
0
votes
2
answers
134
views
Not enough arguments for capability `setaf` in OpenBSD
I want to change the text colour in a shell. I can use tput to get the correct escape codes. For example,
echo "$(tput setaf 5)My text$(tput sgr0)"
outputs My text in a pink-ish tone.
This ...
0
votes
1
answer
372
views
How does `tput` detect color support
I am trying to make my shell script supporting as much terminals as possible, that is, adding ANSI colors, bold and dim only when supported. However, I want to detect the number of colors supported. ...
1
vote
0
answers
154
views
Use altscreen like vim with screen with Ubuntu XTerm
When I exit a screen, I want to be able to return to the terminal looking as I left it. But right now, all I can do is have it clear the screen and put the terminal at the top or the bottom through ...
4
votes
1
answer
5k
views
How to check if a terminal can display undercurl from within a bash/zsh script?
How to check if a terminal can display undercurl from within a bash/zsh script?
In a recent project I used undercurl escape sequence for output printed by a zsh script. It works well in modern ...
1
vote
1
answer
406
views
terminfo/termcap `tput bold`/`tput md`: portability of bold text
Suppose I have the following color support in one of my portable shell scripts:
#!/bin/sh
set -o nounset
tput_init_linux () { set_fg_color='tput setaf'; reset_color=$(tput sgr0 2>/dev/null); }
...
0
votes
1
answer
52
views
tput from initrd
I have a script that uses tput and runs in a initrd. Specifically I'm using tput -T linux [sc|rc|ed] > /dev/tty0 to overwrite multiple lines.
When I run in a qemu vm, it works perfectly. When I run ...
2
votes
1
answer
490
views
Setting LESS_TERMCAP_* variables with $(tput ...) in ~/.profile not working
This is my ~/.bashrc:
# ...unnecessary lines skipped...
# man colors
LESS_TERMCAP_mb=$(tput blink) # start bold
LESS_TERMCAP_md=$(tput setaf 2 ; tput bold) # start bold
LESS_TERMCAP_me=$(tput sgr0) # ...
0
votes
1
answer
164
views
How to keep/restore stderr after `tput smcup`
Given the following contrived example which intent is to only erase the subcommand's /dev/tty:
result="$(
tput smcup > /dev/tty
tput cup 0 0 > /dev/tty
echo 'meh' > /dev/tty
echo ...
0
votes
1
answer
163
views
How to have a bash subcommand clear its modifications to TTY?
Given the following contrived example (proper example would be guiding the user through a series of questions and echoing to stdout the computed results from the user's answers), how can I have it so ...
1
vote
1
answer
1k
views
Deciphering the meaning of the `sgr` variable in `tput`
Does anybody know what sgr stands for when using tput? It is supposed to reset the colour scheme to its default colour.
0
votes
2
answers
256
views
Showing background 256 colours with tput
I am display the 256 colors for tput by colouring tho background colour using the following bash function.
tput-bgcolours ()
{
for color in {0..255}; do
bg=$(tput setab $color)
...
-1
votes
1
answer
450
views
How can the following line be specified using `tput`
How can the following line in Python, which adds colors to the text, be reproduced using tput?
print('\x1b[1;34m::\x1b[0;1m Do you want to remove all other packages from cache? [Y/n] \x1b[0m')
I ...
1
vote
2
answers
357
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 ...
3
votes
3
answers
877
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
1
answer
312
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
2
answers
224
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;...
5
votes
2
answers
683
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)"
''
$ ...
0
votes
1
answer
554
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
1
answer
193
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
1
answer
557
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 ...
3
votes
1
answer
30k
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 ...
6
votes
1
answer
7k
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
2
answers
511
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
1
answer
568
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
0
answers
224
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
1
answer
2k
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 ...
1
vote
4
answers
8k
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 ...
3
votes
1
answer
4k
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
...
4
votes
3
answers
2k
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
2
answers
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 ...
1
vote
3
answers
808
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 ...
24
votes
4
answers
26k
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 ...
16
votes
4
answers
9k
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
0
answers
276
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 ...
18
votes
4
answers
4k
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 ...
151
votes
7
answers
162k
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)...
10
votes
6
answers
16k
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
2
answers
3k
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
1
answer
957
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:
...
17
votes
2
answers
3k
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
...
23
votes
1
answer
19k
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?
8
votes
2
answers
4k
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
2
answers
2k
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
1
answer
594
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 -...
25
votes
3
answers
16k
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 &&...