A nice way to use the console in full screen without forget the current time. you can too add other infos like cpu and mem use. Show Sample Output
Displays an animated hourglass for x amount of seconds Show Sample Output
hypnotizing pendulum
Very useful for interactive scripts where you would like to return the terminal contents to its original state before the script was run. This would be similar to how vi exits and returns you to your original terminal screen.
Save and clear the terminal contents with:
tput smcup
Execute some commands, then restore the saved terminal contents with:
tput rmcup
You will see it on the corner of your running terminal. Show Sample Output
Generates a TV noise alike output in the terminal. Can be combined with https://www.commandlinefu.com/commands/view/9728/make-some-powerful-pink-noise
Print a row of characters across the terminal. Uses tput to establish the current terminal width, and generates a line of characters just long enough to cross it. In the example '#' is used.
It's possible to use a repeating sequence by dividing the columns by the number of characters in the sequence like this:
seq -s'~-' 0 $(( $(tput cols) /2 )) | tr -d '[:digit:]'
or
seq -s'-~?' 0 $(( $(tput cols) /3 )) | tr -d '[:digit:]'
You will lose chararacters at the end if the length isn't cleanly divisible.
Show Sample Output
Gives not only date but also some interesting status about the System Show Sample Output
Depending on the TERM, the terminfo version, ncurses version, etc.. you may be using a varied assortment of terminal escape codes. With this command you can easily find out exactly what is going on.. This is terminal escape zen!
( 2>&2 strace -f -F -e write -s 1000 sh -c 'echo -e "initc\nis2\ncnorm\nrmso\nsgr0" | tput -S' 2>&1 ) | grep -o '"\\[^"]*"' --color=always
"\33]4;%p1%d;rgb:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\33\\\33[!p\33[?3;4l\33[4l\33>\33[?12l\33[?25h\33[27m\33(B\33[m"
Lets say you want to find out what you need to echo in order to get the text to blink..
echo -e "`tput blink`This will blink`tput sgr0` This wont"
Now you can use this function instead of calling tput (tput is much smarter for portable code because it works differently depending on the current TERM, and tput -T anyterm works too.) to turn that echo into a much faster executing code. tput queries files, opens files, etc.. but echo is very strait and narrow.
So now you can do this:
echo -e "\33[5mThis will blink\33(B\33[m This wont"
More at http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
Show Sample Output
This one-liner fills the screen with randomly colored lines.
Same as original, but works in bash
A simple way yo do a progress bar like wget. Show Sample Output
when your terminal session seems unrensponsive (this normally happen after outputting some binary data directly on your standard output) it may me saned by hitting: CTRL+J tput sgr0 CTRL+J Note: don't press the Enter key, just ctrl+j
function echox { echo `tput cup $(($(tput lines))) $(( ($(tput cols) - $(echo "${#1}"))/2 ))`"$1"`tput cup $(tput lines) $(( $(tput cols)-1 ))`; }
echox prints given argument on bottom line center screen in terminal
function echoxy { echo `tput cup $(($(tput lines)/2)) $(( ($(tput cols) - $(echo "${#1}"))/2))`"$1"`tput cup $(tput lines) $(( $(tput cols)-1 ))`; }
exhoxy prints given argument center screen
function echos { echo `tput cup $(($(tput lines)-2)) $(($(tput cols)-$(echo ${#1})))&&tput sc`"$1"`tput cup $(($(tput lines)-2)) 0 && tput rc`; }
while [ 1 ]; do echos "`date`"; done
echos prints date and time on second from last line (used as status message)
you can easily use these functions by placing them in your .bashrc file, make sure to source your .bashrc once you do
Show Sample Output
This is like ping -a, but it does the opposite. It alerts you if the network is down, not up. Note that the beep will be from the speaker on the server, not from your terminal. Once a second, this script checks if the Internet is accessible and beeps if it is not. I define the Net as being "UP", if I can ping Google's public DNS server (8.8.8.8), but of course you could pick a different static IP address. I redirect the beep to /dev/console so that I can run this in the background from /etc/rc.local. Of course, doing that requires that the script is run by a UID or GID that has write permissions to /dev/console (usually only root). Question: I am not sure if the -W1 flag works under BSD. I have only tested this under GNU/Linux using ping from iputils. If anybody knows how portable -W is, please post a comment.
There's been a similar Futurama thing around for a while, which grabs a quote from the /. headers [curl -Ism3 slashdot.org | egrep "^X-(F|B|L)" | cut -d \- -f 2- | fmt -w $(tput cols)]. Same deal, but more likely to stop working when someone forgets to pay the bill on the domain. Until then: Cave Johnson! Show Sample Output
Checks your gmail account every 30 seconds and display the number of new messages in the top right corner of the terminal. A kind of CLI "Gmail notifier" if you will. :-) This is a mashup of http://www.commandlinefu.com/commands/view/7916/put-a-console-clock-in-top-right-corner and http://www.commandlinefu.com/commands/view/3386/check-your-unread-gmail-from-the-command-line
This will change your terminal foreground colour.Depending on the system, tput uses the terminfo or termcap database, as well as looking into the environment for the terminal type. You can use "setb" to set terminal background colour
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
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.
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
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: