もた日記

くだらないことを真面目にやる

ターミナルにマトリックスっぽく文字を落としたり、雪を降らせたりするスクリプト

unimatrix, snowmachineというターミナルで文字を落とすスクリプトがあったので試してみる。両方ともPythonで書かれているのでPythonで同様なことをしたいときは参考になるかも。

unimatrix

github.com

unimatrixは映画「マトリックス」のようにターミナルに文字を落とすことができるスクリプト。CMatrixという同様なツールをベースにしているとのこと。

f:id:wonder-wall:20180204153501g:plain


インストール

スクリプトをダウンロードして実行権限を付ければよい。

$ curl -L https://raw.githubusercontent.com/will8211/unimatrix/master/unimatrix.py -o unimatrix
$ chmod +x unimatrix

pipでもインストールできる。

$ pip install git+https://github.com/will8211/unimatrix.git


使い方

オプションを指定せずに実行できるが、以下のように色や落とす文字列を指定することもできる(終了はCtrl-c)。

$ unimatrix -c blue -u 'Linux'

f:id:wonder-wall:20180204153739g:plain

また、ヘルプに記述があるが実行中に矢印キーでスピードを変えたり、数字キーで色を変えたりすることもできる。

KEYBOARD CONTROL
  SPACE, CTRL-c or q   exit
  - or LEFT            decrease speed by 1
  + or RIGHT           increase speed by 1
  [ or DOWN            decrease speed by 10
  ] or UP              increase speed by 10
  a                    toggle asynchronous scrolling
  b                    cycle through bold character options
                           (bold off-->bold on-->all bold)
  f                    toggle flashing characters
  o                    toggle on-screen status
  1 to 9               set color: (1) Green   (2) Red   (3) Blue     (4) White
                                  (5) Yellow  (6) Cyan  (7) Magenta  (8) Black
                                  (9) Terminal default
  ! to (               set background color (same colors as above, but pressing
                           shift + number)


snowmachine

github.com

snowmachineはターミナルに雪を降らせるツール。

インストール

pipでインストールできる。

$ pip install snowmachine

ヘルプ情報。

$ snowmachine --help
Usage: snowmachine [OPTIONS]

Options:
  --speed INTEGER  Increase to make it snow faster.
  --stack TEXT     Make the snow stack.
  --particle TEXT  Change the partice used. Could be used to make it rain.
  --help           Show this message and exit.


使い方

snowmachineコマンドを実行してCtrl-cで終了する。

f:id:wonder-wall:20180204155938g:plain

--stack TEXTオプションを指定すると雪を積もらせることができる。

f:id:wonder-wall:20180204160153g:plain