Questions tagged [tput]

The tag has no usage guidance, but it has a tag wiki.

Filter by
Sorted by
Tagged with
1 vote
1 answer
119 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 ...
user avatar
0 votes
1 answer
39 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); } ...
user avatar
0 votes
1 answer
37 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 ...
user avatar
1 vote
1 answer
117 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) # ...
user avatar
0 votes
1 answer
49 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 ...
user avatar
  • 403
0 votes
1 answer
43 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 ...
user avatar
  • 403
0 votes
1 answer
212 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.
user avatar
  • 317
0 votes
2 answers
51 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) ...
user avatar
  • 317
-1 votes
1 answer
34 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 ...
user avatar
  • 604
2 votes
2 answers
144 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 ...
user avatar
  • 2,468
2 votes
3 answers
307 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)" ...
user avatar
  • 32.6k
0 votes
1 answer
109 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 ...
user avatar
0 votes
2 answers
114 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;...
user avatar
  • 1,773
4 votes
2 answers
316 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)" '' $ ...
user avatar
0 votes
1 answer
310 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/...
user avatar
  • 10.9k
0 votes
1 answer
126 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. ...
user avatar
3 votes
1 answer
330 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 ...
user avatar
3 votes
1 answer
20k 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 ...
user avatar
2 votes
1 answer
4k 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?
user avatar
  • 24.6k
-1 votes
2 answers
344 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 ...
user avatar
1 vote
1 answer
358 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 ...
user avatar
  • 2,087
1 vote
0 answers
135 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 ...
user avatar
  • 4,391
3 votes
1 answer
1k 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 ...
user avatar
  • 332
0 votes
4 answers
4k 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 ...
user avatar
  • 10.9k
2 votes
1 answer
2k 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 ...
user avatar
  • 10.9k
3 votes
3 answers
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 ...
user avatar
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 ...
user avatar
0 votes
3 answers
542 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 ...
user avatar
  • 193
21 votes
4 answers
18k 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 ...
user avatar
14 votes
4 answers
6k 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 ...
user avatar
  • 243
2 votes
0 answers
268 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 ...
user avatar
  • 33.5k
13 votes
4 answers
3k 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 ...
user avatar
  • 1,066
119 votes
6 answers
113k 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)...
user avatar
  • 1,499
9 votes
4 answers
11k 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?
user avatar
  • 33.5k
5 votes
2 answers
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?
user avatar
  • 26.1k
0 votes
1 answer
734 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: ...
user avatar
  • 170
16 votes
1 answer
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 ...
user avatar
  • 24.1k
19 votes
1 answer
14k 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?
user avatar
  • 26.1k
6 votes
1 answer
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: ...
user avatar
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 ...
user avatar
  • 3
1 vote
1 answer
508 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 -...
user avatar
  • 6,603
20 votes
3 answers
13k 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 &&...
user avatar
  • 9,503
3 votes
1 answer
780 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 ...
user avatar
10 votes
5 answers
17k 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 ...
user avatar
  • 22.7k
2 votes
2 answers
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 ...
user avatar
  • 1,584
5 votes
1 answer
328 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 ...
user avatar
  • 153
4 votes
3 answers
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 ...
user avatar
  • 6,406