Matrix Animation in your Terminal (cross-platform in PowerShell). Written to be quite flexible, featuring:
- Cross-platform rendering systems (Switchable with
-Renderer [Windows, Unix]
)- Windows mode: Uses PowerShell's native console manipulation capabilities through
System.Management.Automation.Host
namespace. It utilizesPlace-BufferedContent
for precise character placement and supports Windows console color schemes. - Unix mode: Employs ANSI escape sequences for text positioning and coloring, providing compatibility with a wide range of Unix-based terminals. This mode offers more fine-grained color control, enabling smoother color transitions and a more vibrant "glow" effect for the leading characters.
- Windows mode: Uses PowerShell's native console manipulation capabilities through
- Adjustable sparsity of the matrix effect with
-Sparsity
- Customizable animation speed with
-SleepTime
- Option to use special characters for a more authentic Matrix look with
-SpecialChars
(works best with Unicode-compatible terminals) - Debug mode for troubleshooting with
-Debug
- Dynamic resizing to fit the terminal window
Matrix Running in MacOS Iterm2 |
---|
- Cross-platform compatibility (Windows and Unix-based systems)
- Adjustable matrix density
- Customizable animation speed
- Special character mode for authentic Matrix appearance
- Dynamic resizing to fit terminal window
- Debug mode for troubleshooting
- PowerShell 5.1 or later (PowerShell Core 6.0+ recommended for cross-platform use)
Run the script using PowerShell:
Matrix.ps1 [[-Sparsity] <double>] [[-SleepTime] <int>] [[-Renderer] <string>] [-SpecialChars] [-Debug]
-Sparsity
: Density of the matrix effect (range: 0.0001 to 1, default: 0.1)-SleepTime
: Animation speed in milliseconds (default: 50)-Renderer
: Choose between "Windows" or "Unix" rendering (default: "Unix")-SpecialChars
: Use special characters for a more authentic Matrix look-Debug
: Enable debug mode for troubleshooting
-
Run with default settings:
.\Matrix.ps1
-
Full feature demo:
.\Matrix.ps1 -SpecialChars -Sparsity 1 -Renderer Unix
-
Use Windows on old terminals (like
conhost
,cmd
).\Matrix.ps1 -SleepTime 20 -Renderer Windows
- Run this:
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
(Allows you to run powershell scripts) - Cd to the path where you cloned this project
- Run
./Matrix.ps1
The script creates a matrix-like animation by:
- Generating random characters (including optional special characters)
- Creating vertical lines of these characters
- Animating the lines to fall down the screen
- Adjusting colors to create a glowing effect
The animation adapts to the terminal window size and can handle window resizing.
- Performance may vary depending on terminal and system specifications
- Some terminals may not support all color features
Inspired by the iconic digital rain effect from "The Matrix" film series.