Questions tagged [tput]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
31 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. ...
2
votes
1answer
77 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 ...
0
votes
1answer
3k 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
660 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
139 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
161 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
52 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 ...
2
votes
1answer
437 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
550 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
682 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
619 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 ...
1
vote
3answers
308 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 ...
14
votes
4answers
8k 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 ...
10
votes
3answers
3k 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
128 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 ...
9
votes
3answers
1k 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 ...
75
votes
5answers
56k 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)...
5
votes
2answers
4k 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
1k 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
409 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: ...
11
votes
1answer
892 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 ...
7
votes
1answer
5k 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?
3
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 ...
2
votes
1answer
350 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
9k 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
471 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 ...
6
votes
3answers
8k views

bash script , echo output in box

I have created this Function , which generate below output on terminal , but this function seems complex, So I posted here for any improvement or for same alternate solution. #!/bin/bash function ...
2
votes
2answers
1k 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 ...
4
votes
1answer
225 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
1k 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 ...