Commands matching tput (64)

  • tput rmam will disable line wrapping so that long lines are truncated to width of the terminal ($COLUMNS). tput smam will re-enable wrapping. I've always used tput in bash scripts but I guess it works on the command line too. Doesn't work in all terminals. See http://www.gnu.org/software/termutils/manual/termutils-2.0/html_chapter/tput_1.html


    0
    tput rmam
    kennyld · 2014-02-26 07:06:37 6
  • Don't want to open up an editor just to view a bunch of XML files in an easy to read format? Now you can do it from the comfort of your own command line! :-) This creates a new function, xmlpager, which shows an XML file in its entirety, but with the actual content (non-tag text) highlighted. It does this by setting the foreground to color #4 (red) after every tag and resets it before the next tag. (Hint: try `tput bold` as an alternative). I use 'xmlindent' to neatly reflow and indent the text, but, of course, that's optional. If you don't have xmlindent, just replace it with 'cat'. Additionally, this example shows piping into the optional 'less' pager; note the -r option which allows raw escape codes to be passed to the terminal. Show Sample Output


    0
    xmlpager() { xmlindent "$@" | awk '{gsub(">",">'`tput setf 4`'"); gsub("<","'`tput sgr0`'<"); print;} END {print "'`tput sgr0`'"}' | less -r; }
    hackerb9 · 2015-07-12 09:22:10 11
  • Good for use in your ~/.bash_profile or a script. Show Sample Output


    0
    BOLD=$(tput bold); NORM=$(tput sgr0)
    thrifus · 2015-10-12 15:53:12 38
  • A function for retrieving and displaying a list of synonyms for a German word or phrase. Show Sample Output


    0
    desyno(){ wget -q -O- https://www.openthesaurus.de/synonyme/search\?q\="$*"\&format\=text/xml | sed 's/>/>\n/g' | grep "<term term=" | cut -d \' -f 2 | paste -s -d , | sed 's/,/, /g' | fold -s -w $(tput cols); }
    lordtoran · 2019-02-09 05:06:42 32

  • 0
    tput rmso
    hansgruber · 2017-07-13 20:01:42 17
  • This will use tput to place the command (date %T in this case) in the upper right corner of the terminal


    0
    while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-11));echo -e "\e[31m`date +%T`\e[39m";tput rc;done &
    x3mboy · 2017-11-16 18:07:39 19
  • Here is an alternative that support unicodes, using echo: It is using the \c flag, meaning no new line for the echo option -e. You can replace the = with any unicode character. Or to do the same into a PHP bash script: shell = system("tput cols"); for( $i= 0 ; $i < $shell ; $i++ ){ echo "█"; } Show Sample Output


    0
    for ((i=0; i<$(tput cols); i++)); do echo -e "=\c" ;done
    K33st · 2018-03-19 19:37:02 27
  • For vi(m) users : Add it in your ~/.bashrc Add an "exit" @ the end if you are masochist ;) Show Sample Output


    -1
    alias :q='tput setaf 1; echo >&2 "this is NOT vi(m) :/"; tput sgr0'
    sputnick · 2009-12-08 12:59:44 3
  • For BSD-based systems, including OS X, that don't have seq. This version provides a default using tput in case $COLUMNS is not set: jot -b '#' -s '' ${COLUMNS:-$(tput cols)} Show Sample Output


    -1
    jot -b '#' -s '' $COLUMNS
    dennisw · 2010-04-13 22:03:39 6
  • hb(){ sed "s/\($*\)/`tput setaf 2;tput setab 0;tput blink`\1`tput sgr0`/gI"; } hb blinks, hc does a reverse color with background.. both very nice. hc(){ sed "s/\($*\)/`tput setaf 0;tput setab 6`\1`tput sgr0`/gI"; } Run this: command ps -Hacl -F S -A f | hc ".*$PPID.*" | hb ".*$$.*" Your welcome ;) From my bash profile - http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html Show Sample Output


    -2
    hb(){ sed "s/\($*\)/`tput setaf 2;tput setab 0;tput blink`\1`tput sgr0`/gI"; }
    AskApache · 2010-04-07 08:45:26 4
  • apt install toilet toilet-fonts # replace 'tput setaf 1' with 'tput setaf 9' to change color


    -3
    tput setaf 1;tput rev;h=$(tput lines);w=$[$(tput cols)/6];c=$(seq -ws '_____|' $[$w+1]|tr -d "0-9");for a in $(seq $[$h/2]);do echo $c;echo ${c//|___/___|};done;tput cup 0;toilet -t -f bigmono12 "?LOVE";tput cup $h
    knoppix5 · 2020-11-01 13:31:31 375
  • Matrix Screen HPUX


    -4
    while :; do integer i=0; COL=$((RANDOM%$(tput cols))); ROW=$((RANDOM%$(tput cols))); while (( i <= COL)) do tput cup $i $ROW; echo "\033[1;34m" $(cat /dev/urandom | head -1 | cut -c1-1) 2>/dev/null; i=$(expr $i + 1); done done
    mfrancime · 2010-05-28 11:17:43 3

  • -4
    Ctrl+l
    bakhru · 2011-04-13 21:15:37 6

  • -4
    tput clear
    mpb · 2019-06-12 17:51:31 34
  •  < 1 2 3

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

Selecting a random file/folder of a folder
Also looks in subfolders

Find removed files still in use via /proc
Oracle DBA remove some logfiles which are still open by the database and he is complaining the space has not been reclaimed? Use the above command to find out what PID needs to be stopped. Or alternatively recover the file via: $ cp /proc/pid/fd/filehandle /new/file.txt

FInd the 10 biggest files taking up disk space
This combines the above two command into one. Note that you can leave off the last two commands and simply run the command as "find /home/ -type f -exec du {} \; 2>/dev/null | sort -n | tail -n 10" The last two commands above just convert the output into human readable format.

Monitor memory without top or htop
It repeats a command, such as free, every five seconds and highlights the differences

Look for IPv4 address in files.
It finds a SNMP OID too :-(

Install pip with Proxy
Installs pip packages defining a proxy

Find removed files still in use via /proc
Oracle DBA remove some logfiles which are still open by the database and he is complaining the space has not been reclaimed? Use the above command to find out what PID needs to be stopped. Or alternatively recover the file via: $ cp /proc/pid/fd/filehandle /new/file.txt

Convert multiple pdf's to jpg in linux using the convert command

Find usb device
I often use it to find recently added ou removed device, or using find in /dev, or anything similar. Just run the command, plug the device, and wait to see him and only him

Force an fsck on reboot
Force an fsck on reboot. Useful on a system where / has mounted read-only because of file system issues.


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: