From b7153083cb0baa9c9f996cf8d537ffe985c40a24 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sun, 20 Mar 2022 21:07:13 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=93=20Adds=20Matrix=20terminal=20scree?= =?UTF-8?q?nsaver?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/matrix.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ zsh/.zshrc | 7 ++++++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 utils/matrix.sh diff --git a/utils/matrix.sh b/utils/matrix.sh new file mode 100644 index 0000000..a462d03 --- /dev/null +++ b/utils/matrix.sh @@ -0,0 +1,47 @@ +# Matrix-style screensaver for your terminal +# Either run execute the script directly, +# Or source it in .zshrc, and start with $ matrix + +matrix () { + local lines=$(tput lines) + cols=$(tput cols) + + awkscript=' + { + letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()" + lines=$1 + random_col=$3 + c=$4 + letter=substr(letters,c,1) + cols[random_col]=0; + for (col in cols) { + line=cols[col]; + cols[col]=cols[col]+1; + printf "\033[%s;%sH\033[2;32m%s", line, col, letter; + printf "\033[%s;%sH\033[1;37m%s\033[0;0H", cols[col], col, letter; + if (cols[col] >= lines) { + cols[col]=0; + } + } + } + ' + + echo -e "\e[1;40m" + clear + + while :; do + echo $lines $cols $(( $RANDOM % $cols)) $(( $RANDOM % 72 )) + sleep 0.05 + done | awk "$awkscript" +} + +# Determine if file is being run directly or sourced +([[ -n $ZSH_EVAL_CONTEXT && $ZSH_EVAL_CONTEXT =~ :file$ ]] || + [[ -n $KSH_VERSION && $(cd "$(dirname -- "$0")" && + printf '%s' "${PWD%/}/")$(basename -- "$0") != "${.sh.file}" ]] || + [[ -n $BASH_VERSION ]] && (return 0 2>/dev/null)) && sourced=1 || sourced=0 + +# If script being called directly, start matrix +if [ $sourced -eq 0 ]; then + matrix +fi diff --git a/zsh/.zshrc b/zsh/.zshrc index e608fb4..2c40b9d 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -10,21 +10,26 @@ utils_dir=~/.config/utils source ${zsh_dir}/aliases/general.zsh source ${zsh_dir}/aliases/git.zsh source ${zsh_dir}/aliases/node-js.zsh +source ${zsh_dir}/aliases/alias-tips.zsh # Setup Antigen, and import plugins source ${zsh_dir}/helpers/setup-antigen.zsh source ${zsh_dir}/helpers/import-plugins.zsh # Configure ZSH stuff -source ${zsh_dir}/lib/history.zsh source ${zsh_dir}/lib/colors.zsh +source ${zsh_dir}/lib/cursor.zsh +source ${zsh_dir}/lib/history.zsh +source ${zsh_dir}/lib/surround.zsh source ${zsh_dir}/lib/completion.zsh source ${zsh_dir}/lib/term-title.zsh source ${zsh_dir}/lib/navigation.zsh +source ${zsh_dir}/lib/expansions.zsh source ${zsh_dir}/lib/key-bindings.zsh # Import utility functions source ${utils_dir}/transfer.sh +source ${utils_dir}/matrix.sh source ${utils_dir}/hr.sh # Left over tasks