d3pd
d3pd

Reputation: 8315

BASH: how can the terminal be set to flash?

I want to get a BASH terminal flashing. The goal is to get the terminal to flash between two colours, say white and black, substantially, using standard Linux utilities. I don't mind if the terminal is filled with characters and cleared in order to do this. A rough picture of what this could look like is as follows:

Upvotes: 5

Views: 6069

Answers (4)

Simon
Simon

Reputation: 191

Here's a tiny bash script i use for this purpose. It also resets the terminal when you ctrl-c.

#!/usr/bin/env bash
set -e

trap ctrl_c INT

function ctrl_c() {
    printf '\e[?5l'
}

while true; do
    printf '\e[?5h'
    sleep 0.5
    printf '\e[?5l'
    sleep 0.5
done

Upvotes: 5

am70
am70

Reputation: 729

You can can call Python inline from Bash as follows

 python -c 'import curses ; w=curses.initscr() ; curses.flash() ; curses.endwin() '

Upvotes: 1

chepner
chepner

Reputation: 531808

You can toggle between normal and reverse video with the following shell commands:

printf '\e[?5h'  # Turn on reverse video
printf '\e[?5l'  # Turn on normal video

Upvotes: 11

Serge Ballesta
Serge Ballesta

Reputation: 149075

What you are asking is called the visible bell. It can be enabled on major terminal emulators like xterm (Ctrl + middle button menu) or putty( Settings/Terminal/Bell). Unfortunately, there is no general way to do it.

But once it has been done, echo Ctrl+G causes the terminal to flash instead of beeping.

Upvotes: 1

Related Questions