Skip to content

A Bash Creativity Showcase by wuseman

Unleash the creativity of your terminal with a unique collection of custom screensavers crafted by Wuseman. This guide features a variety of screensavers, from simple doodles to complex dynamic matrix effects, all designed to transform your command line interface into a canvas of digital art

Dive into the world of Bash scripting with these innovative screensaver examples, and discover how you can bring life, movement, and color to your terminal

Doodle Screensaver
HEIGHT=$(tput lines)
WIDTH=$(tput cols)

while true; do
    printf "\033[2J"  # Clear the screen
    for ((i = 0; i < $((HEIGHT - 1)); i++)); do
        for ((j = 0; j < $((WIDTH - 1)); j++)); do
            if ((RANDOM % 10 == 0)); then
                printf "\033[%d;%dH" $i $j
                printf "█"
            fi
        done
    done
    sleep 0.1
done
Matrix Screensaver (onetimer)
#!/bin/bash

put setaf 2
put setab 0

 IDTH=$(tput cols)
 EIGHT=$(tput lines)

 Generate random binary digits
 enerate_binary() {
   if ((RANDOM % 2 == 0)); then
       echo -n "0"
   else
       echo -n "1"
   fi


### Create the binary digits wall
reate_binary_wall() {
   for ((row = 0; row < HEIGHT; row++)); do
       for ((col = 0; col < WIDTH; col++)); do
           binary=$(generate_binary)
           echo -n "$binary"
       done
       echo ""
   done

put clear
put civis
reate_binary_wall
put cnorm
Matrix Screensaver (forever)
#!/bin/bash

tput setaf 2
tput setab 0

WIDTH=$(tput cols)
HEIGHT=$(tput lines)

generate_binary() {
    if ((RANDOM % 2 == 0)); then
        echo -n "0"
    else
        echo -n "1"
    fi
}

create_binary_wall() {
    while true; do
        for ((row = 0; row < HEIGHT; row++)); do
            for ((col = 0; col < WIDTH; col++)); do
                binary=$(generate_binary)
                echo -n "$binary"
            done
            echo ""
        done
        sleep 0.1  
        tput cup 0 0 
    done
}

tput clear
tput civis
create_binary_wall
Matrix Screensaver (colorchanger)
#!/bin/bash

# Get the terminal size
WIDTH=$(tput cols)
HEIGHT=$(tput lines)

# Generate random binary digits
generate_binary() {
    if ((RANDOM % 2 == 0)); then
        echo -n "0"
    else
        echo -n "1"
    fi
}

generate_color() {
    RED=$((RANDOM % 256))
    GREEN=$((RANDOM % 256))
    BLUE=$((RANDOM % 256))
    echo -ne "\033[38;2;${RED};${GREEN};${BLUE}m"
}

create_matrix_screensaver() {
    while true; do
        color=$(generate_color)
        for ((row = 0; row < HEIGHT; row++)); do
            for ((col = 0; col < WIDTH; col++)); do
                binary=$(generate_binary)
                echo -ne "$color$binary"
            done
            echo ""
        done
        sleep 0.1  # Adjust the sleep duration to control the speed
        tput cup 0 0  # Move the cursor to the top-left corner of the screen
    done
}

tput clear
tput civis

for ((i = 0; i < 10; i++)); do
    create_matrix_screensaver
    tput clear
done

tput cvvis
ASCII Art Matrix Screensaver
#!/bin/bash

# Get the terminal size
WIDTH=$(tput cols)
HEIGHT=$(tput lines)

# Create the ASCII art matrix screensaver
create_ascii_matrix_screensaver() {
    while true; do
        for ((row = 0; row < HEIGHT; row++)); do
            for ((col = 0; col < WIDTH; col++)); do
                if ((RANDOM % 2 == 0)); then
                    echo -ne "\u2588"
                else
                    echo -ne " "
                fi
            done
            echo ""
        done
        sleep 0.1  # Adjust the sleep duration to control the speed
        tput cup 0 0  # Move the cursor to the top-left corner of the screen
    done
}

tput clear
tput civis
create_ascii_matrix_screensaver
Colorized Matrix Screensaver
#!/bin/bash

WIDTH=$(tput cols)
HEIGHT=$(tput lines)

create_colorized_matrix_screensaver() {
    while true; do
        for ((row = 0; row < HEIGHT; row++)); do
            for ((col = 0; col < WIDTH; col++)); do
                color=$((RANDOM % 8 + 30))
                echo -ne "\033[0;"$color"m\u2588"
            done
            echo ""
        done
        sleep 0.1  # Adjust the sleep duration to control the speed
        tput cup 0 0  # Move the cursor to the top-left corner of the screen
    done
}

tput clear

tput civis

create_colorized_matrix_screensaver
Falling Characters Matrix Screensaver
#!/bin/bash

WIDTH=$(tput cols)
HEIGHT=$(tput lines)

characters=("@" "#" "$" "%" "&" "*")

create_falling_characters_matrix_screensaver() {
    while true; do
        for ((col = 0; col < WIDTH; col++)); do
            for ((row = 0; row < HEIGHT; row++)); do
                character=${characters[$((RANDOM % ${#characters[@]}))]}
                echo -ne "\033[$((row+1));$((col+1))H$character"
                sleep 0.01  
            done
        done
        tput cup 0 0
        sleep 0.5 
        tput clear  
    done
}

tput civis

create_falling_characters_matrix_screensaver
Expanding Matrix Screensaver
#!/bin/bash

WIDTH=$(tput cols)
HEIGHT=$(tput lines)

create_expanding_matrix_screensaver() {
    for ((radius = 0; radius < WIDTH || radius < HEIGHT; radius++)); do
        for ((row = 0; row < HEIGHT; row++)); do
            for ((col = 0; col < WIDTH; col++)); do
                if ((col >= WIDTH/2 - radius && col <= WIDTH/2 + radius && row >= HEIGHT/2 - radius && row <= HEIGHT/2 + radius)); then
                    echo -ne "\u2588"
                else
                    echo -ne " "
                fi
            done
            echo ""
        done
        sleep 0.1 
        tput cup 0 0 
    done
}

tput clear
tput civis
create_expanding_matrix_screensaver
Random Block Matrix Screensaver
#!/bin/bash

WIDTH=$(tput cols)
HEIGHT=$(tput lines)

create_random_block_matrix_screensaver() {
    while true; do
        for ((row = 0; row < HEIGHT; row++)); do
            for ((col = 0; col < WIDTH; col++)); do
                if ((RANDOM % 2 == 0)); then
                    echo -ne "\u2588"
                else
                    echo -ne " "
                fi
            done
            echo ""
        done
        sleep 0.1  
        tput cup 0 0
    done
}

tput clear
tput civis
create_random_block_matrix_screensaver
Create a visually twisted effect by alternating the direction of the "staples" effect vertically.
while :; do for ((i=0;i<$(tput cols);i++));do clear;for ((j=0;j<$(tput lines);j++));do printf \
"\e[48;5;$((RANDOM%256))m%*s\e[0m\n" $(((j+i)%2?$(tput cols)-i:i)) "";done;sleep 0.05;done;done
Wobbly line
while :; do 
    printf "\e[32m%*s\e[0m" $(tput cols) $(shuf -e {0..1} -n $(($(tput lines) * $(tput cols)))); 
    sleep 0.1; 
done
while true; do 
    printf "\e[32m%*s\e[0m" $(tput cols) $(shuf -e {0..1} -n $(tput cols))
    sleep 0.1; 
done
Color filler vertically
while :; do 
    for ((i = 0; i < $(tput cols); i++)); do clear; 
    for ((j = 0; j < $(tput lines); j++)); do 
    printf "\e[48;5;$((RANDOM % 256))m%*s\e[0m\n" $i ""; 
    done; 
    sleep 0.05; 
    done; 
done
Binary screensaver
#!/bin/bash

rows=$(tput lines)
cols=$(tput cols)

while true; do
    clear
    for ((i = 0; i < rows; i++)); do
        tput cup $i $((RANDOM % cols))
        printf "%01d" $((RANDOM % 2))
    done
    sleep 0.05
done
Retro screensaver
color_codes=("31" "32" "33" "34" "35" "36")

while true; do
    clear
    for ((i = 0; i < $(tput lines); i++)); do
        tput cup $i $((RANDOM % $(tput cols)))
        color=${color_codes[$((RANDOM % ${#color_codes[@]}))]}
        printf "\033[${color}m#\033[0m"
    done
    sleep 0.1
done
Starfield screensaver
#!/bin/bash

rows=$(tput lines)
cols=$(tput cols)

while true; do
    clear
    for ((i = 0; i < rows; i++)); do
        tput cup $i $((RANDOM % cols))
        printf "*"
    done
    sleep 0.05
done
Digital clock screensaver
#!/bin/bash

rows=$(tput lines)
cols=$(tput cols)

while true; do
    clear
    tput cup $((rows / 2)) $((cols / 2 - 8))
    printf "%(%H:%M:%S)T"
    sleep 1
done
Snake Screensaver
#!/bin/bash

WIDTH=$(tput cols)
HEIGHT=$(tput lines)

snake_x=$((WIDTH / 2))
snake_y=$((HEIGHT / 2))
dx=1
dy=0

create_snake_matrix_screensaver() {
    while true; do
        tput cup $snake_y $snake_x
        echo -ne "\u2588"  # Print the snake character
        
        snake_x=$((snake_x + dx))
        snake_y=$((snake_y + dy))

        if ((snake_x <= 0 || snake_x >= WIDTH - 1 || snake_y <= 0 || snake_y >= HEIGHT - 1)); then
            snake_x=$((WIDTH / 2))
            snake_y=$((HEIGHT / 2))
        fi

        sleep 0.1
        tput clear 
    done
}

tput civis
create_snake_matrix_screensaver
Snake Screensaver v2
#!/bin/bash

WIDTH=$(tput cols)
HEIGHT=$(tput lines)

snake_x=0
snake_y=$((HEIGHT - 1))
dx=1

create_snake_screensaver() {
    while true; do
        tput clear

        tput cup $snake_y $snake_x
        echo -ne "---->"

        snake_x=$((snake_x + dx))

        # Check for wall collisions
        if ((snake_x >= WIDTH - 5)); then
            snake_x=0
        fi

        sleep 0.1 
    done
}

tput civis

create_snake_screensaver
Fish Screensaver
#!/bin/bash

WIDTH=$(tput cols)
HEIGHT=$(tput lines)

fish_x=$((WIDTH / 2))
fish_y=$((HEIGHT / 2))
dx=1
dy=1

fish_layouts=("><(((°>" "<°)))><" "><(((°>")
num_layouts=${#fish_layouts[@]}
create_fish_screensaver() {
    while true; do
        # Clear the screen
        tput clear

        layout_index=$((fish_x % num_layouts))
        fish_layout=${fish_layouts[$layout_index]}

        tput cup $fish_y $fish_x
        echo -e "$fish_layout"

        fish_x=$((fish_x + dx))
        fish_y=$((fish_y + dy))

        if ((fish_x >= WIDTH - 8)); then
            dx=-1
        elif ((fish_x <= 0)); then
            dx=1
        fi

        if ((fish_y >= HEIGHT - 1)); then
            dy=-1
        elif ((fish_y <= 0)); then
            dy=1
        fi

        sleep 0.1 
    done
}

tput civis
create_fish_screensaver
Shark hunting and eating fish
#!/bin/bash

WIDTH=$(tput cols)
HEIGHT=$(tput lines)

fish_x=$((WIDTH / 2))
fish_y=$((HEIGHT / 2))
dx=1
dy=0

shark_x=$((WIDTH / 2 - 10))
shark_y=$((HEIGHT / 2))
shark_dx=1
shark_dy=0

create_fish_screensaver() {
    while true; do
        tput clear
        tput cup $fish_y $fish_x
        echo -e "><(((°>"

        tput cup $shark_y $shark_x
        echo -e "▄▄▄▄▄▄▄▄▄▄▄▄▄▄"

        fish_x=$((fish_x + dx))
        fish_y=$((fish_y + dy))

        if ((fish_x > shark_x)); then
            shark_dx=1
        elif ((fish_x < shark_x)); then
            shark_dx=-1
        else
            shark_dx=0
        fi

        if ((fish_y > shark_y)); then
            shark_dy=1
        elif ((fish_y < shark_y)); then
            shark_dy=-1
        else
            shark_dy=0
        fi

        shark_x=$((shark_x + shark_dx))
        shark_y=$((shark_y + shark_dy))

        sleep 0.1
    done
}

tput civis
create_fish_screensaver
Shark hunting fish 2, multiple fishes
#!/bin/bash

WIDTH=$(tput cols)
HEIGHT=$(tput lines)

fish_count=5
declare -a fish_x
declare -a fish_y
declare -a fish_dx
declare -a fish_dy
for ((i = 0; i < fish_count; i++)); do
    fish_x[$i]=$((RANDOM % (WIDTH - 9) + 1))
    fish_y[$i]=$((RANDOM % (HEIGHT - 1) + 1))
    fish_dx[$i]=$((RANDOM % 2 * 2 - 1))
    fish_dy[$i]=$((RANDOM % 2 * 2 - 1))
done

shark_x=$((WIDTH / 2 - 20))
shark_y=$((HEIGHT / 2))
shark_dx=1
shark_dy=0

create_fish_screensaver() {
    while true; do
        # Clear the screen
        tput clear

        # Print the fish
        for ((i = 0; i < fish_count; i++)); do
            tput cup ${fish_y[$i]} ${fish_x[$i]}
            echo -e "><(((°>"
        done

        tput cup $shark_y $shark_x
        echo -e "▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄"
        tput cup $((shark_y + 1)) $shark_x
        echo -e "▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀"

        for ((i = 0; i < fish_count; i++)); do
            fish_x[$i]=$((fish_x[$i] + fish_dx[$i]))
            fish_y[$i]=$((fish_y[$i] + fish_dy[$i]))
            if ((fish_x[$i] >= WIDTH - 9)) || ((fish_x[$i] <= 0)); then
                fish_dx[$i]=$((fish_dx[$i] * -1))
            fi
            if ((fish_y[$i] >= HEIGHT - 1)) || ((fish_y[$i] <= 0)); then
                fish_dy[$i]=$((fish_dy[$i] * -1))
            fi
        done

        shark_x=$((shark_x + shark_dx))
        shark_y=$((shark_y + shark_dy))
        if ((shark_x >= WIDTH - 10)) || ((shark_x <= 0)); then
            shark_dx=$((shark_dx * -1))
        fi
        if ((shark_y >= HEIGHT - 2)) || ((shark_y <= 0)); then
            shark_dy=$((shark_dy * -1))
        fi

        sleep 0.1 
    done
}

tput civis
create_fish_screensaver
Fishes swim around the boat
#!/bin/bash

# Get the terminal size
WIDTH=$(tput cols)
HEIGHT=$(tput lines)

# Initialize the fish positions and directions
fish_count=5
declare -a fish_x
declare -a fish_y
declare -a fish_dx
declare -a fish_dy
for ((i = 0; i < fish_count; i++)); do
    fish_x[$i]=$((RANDOM % (WIDTH - 9) + 1))
    fish_y[$i]=$((RANDOM % (HEIGHT - 1) + 1))
    fish_dx[$i]=$((RANDOM % 2 * 2 - 1))
    fish_dy[$i]=$((RANDOM % 2 * 2 - 1))
done

# Initialize the boat position and direction
boat_x=$((WIDTH / 2 - 15))
boat_y=$((HEIGHT / 2))
boat_dx=1
boat_dy=0

create_fish_screensaver() {
    while true; do
        # Clear the screen
        tput clear

        # Print the fish
        for ((i = 0; i < fish_count; i++)); do
            tput cup ${fish_y[$i]} ${fish_x[$i]}
            echo -e "><(((°>"
        done

        # Print the boat
        tput cup $boat_y $boat_x
        echo "       ____"
        tput cup $((boat_y + 1)) $boat_x
        echo "              ---|"
        tput cup $((boat_y + 2)) $boat_x
        echo "  \/            /|     \/"
        tput cup $((boat_y + 3)) $boat_x
        echo "               / |\\"
        tput cup $((boat_y + 4)) $boat_x
        echo "              /  | \\        \/"
        tput cup $((boat_y + 5)) $boat_x
        echo "             /   || \\"
        tput cup $((boat_y + 6)) $boat_x
        echo "            /    | | \\"
        tput cup $((boat_y + 7)) $boat_x
        echo "           /     | |  \\"
        tput cup $((boat_y + 8)) $boat_x
        echo "          /      | |   \\"
        tput cup $((boat_y + 9)) $boat_x
        echo "         /       ||     \\"
        tput cup $((boat_y + 10)) $boat_x
        echo "        /        /       \\"
        tput cup $((boat_y + 11)) $boat_x
        echo "       /________/         \\"
        tput cup $((boat_y + 12)) $boat_x
        echo "       ________/__________--/"
        tput cup $((boat_y + 13)) $boat_x
        echo " ~~~   \___________________/"
        tput cup $((boat_y + 14)) $boat_x
        echo "         ~~~~~~~~~~       ~~~~~~~~"
        tput cup $((boat_y + 15)) $boat_x
        echo "~~~~~~~~~~~~~     ~~~~~~~~~"
        tput cup $((boat_y + 16)) $boat_x
        echo "                               ~~~~~~~~~"

        for ((i = 0; i < fish_count; i++)); do
            fish_x[$i]=$((fish_x[$i] + fish_dx[$i]))
            fish_y[$i]=$((fish_y[$i] + fish_dy[$i]))
            if ((fish_x[$i] >= WIDTH - 9)) || ((fish_x[$i] <= 0)); then
                fish_dx[$i]=$((fish_dx[$i] * -1))
            fi
            if ((fish_y[$i] >= HEIGHT - 1)) || ((fish_y[$i] <= 0)); then
                fish_dy[$i]=$((fish_dy[$i] * -1))
            fi
        done

        boat_x=$((boat_x + boat_dx))
        boat_y=$((boat_y + boat_dy))
        if ((boat_x >= WIDTH - 34)) || ((boat_x <= 0)); then
            boat_dx=$((boat_dx * -1))
        fi
        if ((boat_y >= HEIGHT - 17)) || ((boat_y <= 0)); then
            boat_dy=$((boat_dy * -1))
        fi

        sleep 0.1
    done
}

tput civis
create_fish_screensaver
Boat + Airplane
#!/bin/bash

WIDTH=$(tput cols)
HEIGHT=$(tput lines)

fish_count=5
declare -a fish_x
declare -a fish_y
declare -a fish_dx
declare -a fish_dy
for ((i = 0; i < fish_count; i++)); do
    fish_x[$i]=$((RANDOM % (WIDTH - 9) + 1))
    fish_y[$i]=$((RANDOM % (HEIGHT - 1) + 1))
    fish_dx[$i]=$((RANDOM % 2 * 2 - 1))
    fish_dy[$i]=$((RANDOM % 2 * 2 - 1))
done

boat_x=$((WIDTH / 2 - 15))
boat_y=$((HEIGHT / 2))
boat_dx=1
boat_dy=0

airplane_x=0
airplane_y=$((HEIGHT / 4))
airplane_dx=2
airplane_dy=0

create_fish_screensaver() {
    while true; 
        tput clear

        for ((i = 0; i < fish_count; i++)); do
            tput cup ${fish_y[$i]} ${fish_x[$i]}
            echo -e "><(((°>"
        done

        tput cup $boat_y $boat_x
        echo "       ____"
        tput cup $((boat_y + 1)) $boat_x
        echo "              ---|"
        tput cup $((boat_y + 2)) $boat_x
        echo "  \/            /|     \/"
        tput cup $((boat_y + 3)) $boat_x
        echo "               / |\\"
        tput cup $((boat_y + 4)) $boat_x
        echo "              /  | \\        \/"
        tput cup $((boat_y + 5)) $boat_x
        echo "             /   || \\"
        tput cup $((boat_y + 6)) $boat_x
        echo "            /    | | \\"
        tput cup $((boat_y + 7)) $boat_x
        echo "           /     | |  \\"
        tput cup $((boat_y + 8)) $boat_x
        echo "          /      | |   \\"
        tput cup $((boat_y + 9)) $boat_x
        echo "         /       ||     \\"
        tput cup $((boat_y + 10)) $boat_x
        echo "        /        /       \\"
        tput cup $((boat_y + 11)) $boat_x
        echo "       /________/         \\"
        tput cup $((boat_y + 12)) $boat_x
        echo "       ________/__________--/"
        tput cup $((boat_y + 13)) $boat_x
        echo " ~~~   \___________________/"
        tput cup $((boat_y + 14)) $boat_x
        echo "         ~~~~~~~~~~       ~~~~~~~~"
        tput cup $((boat_y + 15)) $boat_x
        echo "~~~~~~~~~~~~~     ~~~~~~~~~"
        tput cup $((boat_y + 16)) $boat_x
        echo "                               ~"
        tput cup $airplane_y $airplane_x
        echo "          ______"
        tput cup $((airplane_y + 1)) $airplane_x
        echo "            _\\ _~-\___"
        tput cup $((airplane_y + 2)) $airplane_x
        echo "    =  = ==(____AA____D"
        tput cup $((airplane_y + 3)) $airplane_x
        echo "                \\_____\___________________,-~~~~~~~\`-.._"
        tput cup $((airplane_y + 4)) $airplane_x
        echo "                /     o O o o o o O O o o o o o o O o  |\_"
        tput cup $((airplane_y + 5)) $airplane_x
        echo "                \`~-.__        ___..----..                  )"
        tput cup $((airplane_y + 6)) $airplane_x
        echo "                      \`---~~\\___________/------------\`\`\`"
        tput cup $((airplane_y + 7)) $airplane_x
        echo "                      =  ===(_________D"

        for ((i = 0; i < fish_count; i++)); do
            fish_x[$i]=$((fish_x[$i] + fish_dx[$i]))
            fish_y[$i]=$((fish_y[$i] + fish_dy[$i]))
            if ((fish_x[$i] >= WIDTH - 9)) || ((fish_x[$i] <= 0)); then
                fish_dx[$i]=$((fish_dx[$i] * -1))
            fi
            if ((fish_y[$i] >= HEIGHT - 1)) || ((fish_y[$i] <= 0)); then
                fish_dy[$i]=$((fish_dy[$i] * -1))
            fi
        done

        boat_x=$((boat_x + boat_dx))
        boat_y=$((boat_y + boat_dy))
        if ((boat_x >= WIDTH - 34)) || ((boat_x <= 0)); then
            boat_dx=$((boat_dx * -1))
        fi
        if ((boat_y >= HEIGHT - 17)) || ((boat_y <= 0)); then
            boat_dy=$((boat_dy * -1))
        fi

        airplane_x=$((airplane_x + airplane_dx))
        airplane_y=$((airplane_y + airplane_dy))
        if ((airplane_x >= WIDTH - 23)) || ((airplane_x <= 0)); then
            airplane_dx=$((airplane_dx * -1))
        fi
        if ((airplane_y >= HEIGHT / 2 - 7)) || ((airplane_y <= 0)); then
            airplane_dy=$((airplane_dy * -1))
        fi

        sleep 0.1
    done
}

tput civis
create_fish_screensaver