Skip to content

Instantly share code, notes, and snippets.

@crazy-matt
Last active March 5, 2020 22:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crazy-matt/44993bff84fdbb204d2b7efca345944b to your computer and use it in GitHub Desktop.
Save crazy-matt/44993bff84fdbb204d2b7efca345944b to your computer and use it in GitHub Desktop.
Install cmatrix to be executed randomly after a clear command run
#!/usr/bin/env bash
# reference: https://adammusciano.com/2020/03/04/2020-03-04-clear-your-terminal-in-style/
## INSTALL GUIDE
## * 1 single line to dowload & run the installation script:
## brew install python || yum install -y python-pip || apt install -f python-pip && pip install getgist && cd /tmp && getgist adjogahm /tmp/install_cmatrix.sh && bash /tmp/install_cmatrix.sh && cd - && clear
if [ -f "${HOME}/.bash_aliases" ]; then
FILE="${HOME}/.bash_aliases"
elif [ -f "${HOME}/.bashrc" ]; then
FILE="${HOME}/.bashrc"
elif [ -f "${HOME}/.bash_profile" ]; then
FILE="${HOME}/.bash_profile"
fi
set -e
unameOut=$(uname -s)
case ${unameOut} in
Darwin*) MACHINE=darwin;;
Linux*) MACHINE=linux;;
*) MACHINE="UNKNOWN:${unameOut}";;
esac
if [[ ${MACHINE} == "darwin" ]]; then
brew install cmatrix
sudo cat >> "${FILE}" <<EOF1
alias clear='[ $[$RANDOM % 20] = 0 ] && timeout 3 cmatrix; clear || clear'
EOF1
elif [[ ${MACHINE} == "linux" ]]; then
[[ -n "$(command -v yum)" ]] && MACHINE=redhat
[[ -n "$(command -v apt-get)" ]] && MACHINE=debian
sudo cat >> "${FILE}" <<EOF1
alias clear='[ $[$RANDOM % 20] = 0 ] && timeout 3 cmatrix; clear || clear'
EOF1
if [[ ${MACHINE} == "redhat" ]]; then
yum install -y gcc make autoconf automake ncurses-devel
git clone https://github.com/abishekvashok/cmatrix.git
cd cmatrix
autoreconf -i # skip if using released tarball
./configure
make
make install
rm -rf cmatrix install_cmatrix.sh
elif [[ ${MACHINE} == "debian" ]]; then
apt-get install -f cmatrix
fi
else
echo -e "\nOS unsupported!" && exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment