Tag Info

Hot answers tagged

11

Terminal parameters are stored as $LINES and $COLUMNS variables. Additionally you can use special term-operation programm, for example tput: tput lines # outputs the number of lines of the present terminal window. tput cols # outputs the number of columns of the present terminal window.


6

This command should give you the number of lines on the terminal: stty size | cut '-d ' -f1 Some systems might not implement stty size so you might need something like this instead: stty -a | tr \; \\012 | grep rows | tr -d ' rows'


2

Use tput to get the control sequences (if they exist) for the user's terminal: red="`tput setaf 1`" green="`tput setaf 2`" cyan="`tput setaf 6`" bold="`tput bold`" norm="`tput sgr0`" echo "${red}invalid entries${norm}" echo "valid entries" echo "valid entry"


1

It's called blink mode. If your terminal supports it, syntax is echo -e "Normal \e[5mBlink" Bash tips: Colors and formatting ANSI/VT100 Control sequences


1

echo -e "\e[31minvalid entries\e[0m" Reference: Bash tips: Colors and formatting (ANSI/VT100 Control sequences)


1

Have you got specific operations in mind? Here is an example of using standout mode, which on many terminals will give a strong visible result: tput smso; echo hello, world; tput rmso If you were to pipe the sequence to, say, cat, the highlighting would become an empty operation because a pipe isn't a device that understands standout mode: ( tput smso; ...


1

Actually it is possible to inquire DEC terminals (and their clones and emulations, including xterm) about their capabilities; just not about individual escape sequence support (or its completeness). UNIX generally doesn't use this feature, relying on termcap/terminfo databases (which document the quirks as well). For reference, the sequences are DA ...



Only top voted, non community-wiki answers of a minimum length are eligible