How can I get tput to fill the whole background without leaving a border?
2
votes
1
answer
288
views
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:
1.
The
but it does not change the area of the background that was set by
I can just use the
tput setb 2; echo
2. printf '\e]11;#00FF00\a'
For more info on what that printf
is doing, see [how-to-set-the-background-color-of-the-linux-console-screen](https://unix.stackexchange.com/questions/474502/how-to-set-the-background-color-of-the-linux-console-screen/474924#474924) and the specific use of 11
for background is documented on page 34 of https://invisible-island.net/xterm/ctlseqs/ctlseqs.pdf (Ps = 1 0 → Change VT100 text foreground color to Pt.
and Ps = 1 1 → Change VT100 text background color to Pt.
)
The printf
immediately changes the bacground of the whole terminal while the tput
just sets the color for what is typed next, hence the echo
to start on the next empty line, but I don't care much about that. What I do most care about is the following:
The tput
leaves a small border in the original background color (pale beige, set by the "Options" GUI I get by clicking on the top-left of the terminal) as can be seen in this image (the pale grey around the left/bottom of the image is my Windows desktop color):

printf
changes the color of the border (it's a lighter shade of green from tput
's but that's irrelevant):

tput
unless I first re-initialize what my original tput
did with tput init; echo
and then execute the printf
:

printf
to get what I want as long as I don't use tput setb
first but I'd prefer to **only** use tput setb
if I can for portability so - why is tput
leaving a small border of the existing background color and is there any way to tell tput
to set the background color in a way that does not leave that small border?
I'd also like to know if there's a way to have tput
set the whole terminal background immediately, as the printf
does, rather than after the next string I type, but that's not nearly as important as getting rid of that border.
Additional info now that [@MarcusMüller](https://unix.stackexchange.com/users/106650/marcus-m%c3%bcller) gave me the hint [in a comment](https://unix.stackexchange.com/questions/780532/how-can-i-get-tput-to-fill-the-whole-background-without-leaving-a-border?noredirect=1#comment1493703_780532) that this might be a mintty
issue -
I see this same behavior when I use git bash
from Windows on a different machine. They apparently both use mintty
as the terminal emulator. Since I have to log into many different Windows machines and use cygwin
or git bash
, I'd like to be able to solve this problem without having to change terminal emulator every time I use one of those machines (I'm not even sure if/how I could do that). In fact, if it came down to changing terminal emulator to solve the tput
problem, I'd just use the printf
approach instead.
I found at [set-border-width-for-mintty-window-on-cygwin-windows-10](https://stackoverflow.com/a/67448126/1745001) a way to control the border width from ~/.minttyrc
by setting the Padding
variable and if I update it to say:
Padding=0
then that does work around the above tput
problem but
1. That'd mean I'd have to change the .minttyrc
on every machine I log into and restart the terminal afterwards, and
2. When I open the "Options" GUI to change anything about the terminal then save it, it overwrites that .minttyrc
file and removes the Padding
setting
so I still would like to find some way to simply tell tput
to fill that "padding" area just like it does the rest of the background.
[@Vilinkameni](https://unix.stackexchange.com/users/367454/vilinkameni) also points out [in a comment](https://unix.stackexchange.com/questions/780532/how-can-i-get-tput-to-fill-the-whole-background-without-leaving-a-border#comment1493719_780532) that with the above tput
in a mintty
and MSYS2 MINGW64
terminal, any ANSI SGR color switching by a subsequent ls --color
or other command that uses colors will effectively reset the color again. That does not happen if I use the above printf
so I may ask about that in a subsequent question.
See also "Changing colours" towards the bottom https://code.google.com/archive/p/mintty/wikis/Tips.wiki#Changing_colours for more information on the above printf
and other things related to mintty
. My $TERM
value is xterm
.
Asked by Ed Morton
(35459 rep)
Jul 21, 2024, 12:32 PM
Last activity: Jul 26, 2024, 11:46 AM
Last activity: Jul 26, 2024, 11:46 AM