CLI – matoken's blog https://matoken.org/blog Is there no plan B? Tue, 02 Dec 2025 10:58:31 +0000 ja hourly 1 https://wordpress.org/?v=7.1.5 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg CLI – matoken's blog https://matoken.org/blog 32 32 かわいいcli 天気アプリのstarlit https://matoken.org/blog/2025/12/03/cute-cli-weather-app-starlit/ https://matoken.org/blog/2025/12/03/cute-cli-weather-app-starlit/#respond Tue, 02 Dec 2025 21:22:00 +0000 https://matoken.org/blog/?p=4769

小さく可愛いCLI 天気アプリケーションのstarlit を少し試してみました.
starlit はPython製,ライセンスは不明です.

pipx で導入しました.

$ pipx install starlit-cli
  installed package starlit-cli 0.2.3, installed using Python 3.13.9
  These apps are now globally available
    - starlit
done! ✨ 🌟 ✨
$ starlit --help

Starlit is a minimal, cute and customizable weather cli.
Weather forecasts, beautifully styled for your terminal!

USAGE


  starlit [city] [--flags]


EXAMPLES


   # Get weather for default city
   starlit

   # Get weather for a specific city
   starlit tokyo

   # Start interactive mode
   starlit --interactive


FLAGS

  -s --setup                Create configuration folder with .env file
  -e --edit                 Open configuration file in default editor
  -c --config               View configuration settings in terminal
  -i --interactive          Start interactive mode
  -v --version              Show starlit version
  -h --help                 Show this help message

--setup オプションで設定ファイルを設定します.設定ファイルは $HOME/.config/starlit/.env に作られます.

$ starlit --setup

 DONE  Config created at `/home/matoken/.config/starlit/.env`

Would you like to edit the config now? (y/n): y

 EDIT  Opened .env file in default editor

設定ファイルを編集して最低限 API_KEY (OpenWeatherMap API key) と DEFAULT_CITY (既定値の都市)を指定します.

OpenWeatherMap API key は以下から,

都市は以下のあたりで確認します.

実行します.実際はカラフルでアニメーションで表示されます.

$ starlit

Forecast for Kanoya, JP ☁

               weather  ›   cloudy (16.1°C)
    .--.      sunset   ›   05:13 PM
  .-(    ).    wind     ›   13.6 km/h ↖
 (___.__)__)   humidity ›   72%
               precip   ›   0mm | 0%

Tue. Dec 2  07:26 PM (gmt+9)

 🐻 MSG  a chill playlist kinda day

starlit

オプションや環境変数で都市を指定すると特定の都市が表示されます.

starlit shibushi

その他interactive mode も.

いつもは類似アプリとしてwego を利用することが多いのですがstarlit も良さそうです.天気プロバイダが増えると便利かもです.

環境
$ starlit --version

 V0.2.3  starlit version
$ dpkg-query -W pipx python3
pipx    1.8.0-1
python3 3.13.7-1
$ lsb_release -dr
Description:    Debian GNU/Linux forky/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2025/12/03/cute-cli-weather-app-starlit/feed/ 0
nanotodon 0.5.0でSixel https://matoken.org/blog/2025/01/12/nanotodon-0-5-0/ https://matoken.org/blog/2025/01/12/nanotodon-0-5-0/#respond Sat, 11 Jan 2025 22:03:50 +0000 https://matoken.org/blog/?p=4365

CLI Mastodon clientのnanotodon 0.5.0がリリースされました.
Sixel対応のようです.

  • Sixelがある程度動くようになった

Sixelのつかいかた

Makefileを見てね!

ということでReleaseからsource archiveを入手したり,git cloneしてMakefileを見てみます.

$ wget2 -c -v https://github.com/taka-tuos/nanotodon/archive/refs/tags/0.5.0.tar.gz
$ tar tvf 0.5.0.tar.gz
$ cd nanotodon-0.5.0

or

$ git clone https://github.com/taka-tuos/nanotodon
$ cd nanotodon
$ git checkout -b 0.5.0

Sixel対応のため以下のように編集しました.(Webpはオプション)

$ git diff Makefile
diff --git a/Makefile b/Makefile
index 6332820..238c2ed 100644
--- a/Makefile
+++ b/Makefile
@@ -10,11 +10,11 @@ LDLIBS += -lcurl -lpthread -lm
 CFLAGS += -DSUPPORT_XDG_BASE_DIR

 # EXPERIMENTAL: sixel support
-#CFLAGS += -DUSE_SIXEL
+CFLAGS += -DUSE_SIXEL

 # EXPERIMENTAL: webp support
-#CFLAGS += -DUSE_WEBP
-#LDLIBS += -lwebp
+CFLAGS += -DUSE_WEBP
+LDLIBS += -lwebp

 # for pkgsrc
 #CFLAGS += -I/usr/pkg/include
Note

webpを無効にするとwebp形式の画像の表示に失敗します.画像は以下のものに差し替えられました.結構webpは多いので有効にしたほうが良さそうです.

err

View on Mastodon

buildします.

$ make

そしてnanotodonを実行.

$ ./nanotodon

アイコンや添付画像がSixelで表示されるようになりました :)

nanotodon sixel

Sixel対応端末については以下のページが参考になります.

今回はmltermの上でtmuxを動かし,その上でnanotodonを動かしました.
以下はtmuxの上の窓でnanotodon,下の窓でsayakaでMisskeyを表示しています.

nanotodonsayaka

楽しいです :)

環境
$ dpkg-query -W make gcc libcurl4t64 libblis64-4-pthread
gcc     4:14.2.0-1
libblis64-4-pthread:amd64       1.0-1+b1
libcurl4t64:amd64       8.11.1-1
make    4.4.1-1
$ lsb_release -dr
Description:    Debian GNU/Linux trixie/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2025/01/12/nanotodon-0-5-0/feed/ 0
misskey-cli で Misskey を読み書き https://matoken.org/blog/2024/03/27/read-and-write-misskey-with-misskey-cli/ https://matoken.org/blog/2024/03/27/read-and-write-misskey-with-misskey-cli/#respond Tue, 26 Mar 2024 22:17:40 +0000 https://matoken.org/blog/?p=4002

Misskey クライアントの sayaka ちゃんは sixel で画像が表示できとても便利ですが,投稿ができません.

Terminal から投稿もしたいので他の cli クライアントの misskey-cli を試してみました.

早速導入します.
今回 go install で導入しましたが, Releases に各種環境向けのバイナリも用意されています.自分の環境にあったバイナリをダウンロードして実行権を付与してあげれば簡単に利用できます.hash や 署名は無さそうです.

install
$ go install github.com/mikuta0407/misskey-cli@latest
$ ~/go/bin/misskey-cli
misskey-cli  Misskey CLI Client

Usage:
  misskey-cli [command]

Available Commands:
  help        Help about any command
  note        Create/Reply/Delete note
  renote      Renote note by noteId
  stream      streaming timeline
  tl          Show timelime (local/home/global)
  version     Show version and build revision.

Flags:
      --config string     config file (default "/home/matoken/.config/misskey-cli.toml")
  -h, --help              help for misskey-cli
  -i, --instance string   connect instance name(not host name)
  -t, --toggle            Help message for toggle

Use "misskey-cli [command] --help" for more information about a command.
$ misskey-cli version
misskey-cli  version:

設定ファイルを用意します.
~/.config/misskey-cli.toml を作成します.host は Misskey の url ,name は任意の名前,token は Misskey の「設定」→「API」→「アクセストークンの発行」から発行したものを使います.
複数の Misskey を登録できます.以下は2つの Misskey を登録しました.実行時に一番上の設定がデフォルトになるのでよく使う Misskey を一番上にするといいです.

$ vi ~/.config/misskey-cli.toml
$ cat ~/.config/misskey-cli.toml
[[Instance]]
  host = "https://msky.ospn.jp/"
  name = "OSPN"
  token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
[[Instance]]
  host = "https://misskey.io/"
  name = "misskey.io"
  token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

早速使ってみます.

misskey-cli をで note や 閲覧
$ misskey-cli note 'misskey-cli から note
https://github.com/mikuta0407/misskey-cli'
misskey-cli  Create Note: @ (https://msky.ospn.jp/)
===============================================================================================================================================================================================================================================
Note Success! id : 9rcgksz5uzfb00f6
"misskey-cli から note
https://github.com/mikuta0407/misskey-cli"
$ misskey-cli tl -l1
misskey-cli  Timeline: local  @ (https://msky.ospn.jp/)
===============================================================================================================================================================================================================================================
2024/03/27 06:33:58 matoken(@matoken)    misskey-cli から note
https://github.com/mikuta0407/misskey-cli (9rcgksz5uzfb00f6)

複数のインスタンスを登録している場合は -i name (name は設定の tolm の name )で任意のインスタンスを指定できます.

$ misskey-cli -i misskey.io stream
misskey-cli  Stream: local  @ (https://misskey.io/)
===============================================================================================================================================================================================================================================
2024/03/27 06:59:02 Connected to server
  :

その他詳細は README.md に日本語で書かれています.

とりあえず一通りのことはできそうです.

環境
$ misskey-cli version
misskey-cli  version:
$ ls ~/go/pkg/mod/github.com/mikuta0407/
misskey-cli@v0.0.0-20230730142608-ab80e8e6583c
$ dpkg-query -W golang
golang:armhf    2:1.19~1
$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm
$ arch
aarch64
]]>
https://matoken.org/blog/2024/03/27/read-and-write-misskey-with-misskey-cli/feed/ 0
Twitterクライアントsayakaちゃんの最新版(3.5.0)をLinuxでビルドする https://matoken.org/blog/2021/03/06/build-the-latest-version-3-5-0-of-twitter-client-sayaka-on-linux/ https://matoken.org/blog/2021/03/06/build-the-latest-version-3-5-0-of-twitter-client-sayaka-on-linux/#respond Sat, 06 Mar 2021 13:32:34 +0000 http://matoken.org/blog/?p=3052

追記2021-03-09)
Raspberry Pi OS buster armhf 及び Ubuntu 21.04 (development branch) amd64でも同様にビルドできました :)

ターミナルで動作するTwitterクライアントとしてsayakaちゃんというものがあります.NetBSDの入ったSHARP X68030でも動作するという軽量なクライアントで,SIXELで画像が表示できたりストリームモードがあってハッシュタグなどを垂れ流すのに便利に使っています.

今日オープンソースカンファレンス2021 Online/Spring 2日目があって @ebijunさんの「NetBSDのご紹介」 を視聴していたのですが,新しいバージョンの 3.5.0 がリリースされたとのことで試してみました.

twitter クライアント sayaka ちゃん version 3.5.0 (2021/03/03)
ターミナルに特化した twitter クライアントです。

フィルタストリームの垂れ流しが出来ます。
フィルタストリームによる疑似ホームタイムラインが表示できます。
mlterm などの SIXEL 対応ターミナル用です。
X68030/25MHz、メモリ12MB でも快適(?)動作。
更新履歴
3.5.0 (2021/03/03) … C++ に移行し vala 版廃止。 画像は現在のところ JPEG, PNG のみ対応。 ターミナル背景色の自動取得を実装。 --protect、--support-evs オプション廃止。 --noimg オプションを廃止 (--no-image に変更)。 userstream 時代の録画データの再生機能廃止。

watchしてたけどメール届いていないようです?

sayaka watch

現在のバーションを確認してみます.1つ前のバージョンぽいですね.

$ sayaka --version
sayaka.vala 3.4.6 (2020/11/10)

ビルドを試みます.

$ git clone https://github.com/isaki68k/sayaka/ (1)
$ cd sayaka
$ git checkout 3.5.0
HEAD is now at 958f630 ver 3.5.0 (2021/03/03)
$ ./configure (2)
  1. sayakaのsourceをclone
  2. configure

足りないものがパッケージ名で表示されて助かります :)

configure: error: *** mbedtls not found.
        On Ubuntu, sudo apt install libmbedtls-dev
configure: error: *** mbedtls not found.
        On Ubuntu, sudo apt install libmbedtls-dev

./configure が通ったらmake……失敗です.

$ make
(cd src; make all)
make[1]: Entering directory '/home/matoken/src/sayaka/src'
Makefile:3: *** missing separator.  Stop.
make[1]: Leaving directory '/home/matoken/src/sayaka/src'
make: *** [Makefile:2: all] Error 2

必要なものをよく見ると,GNU makeではなく BSD make が必要となっていました.(3.4.6を確認するとこのときはGNU makeなので今回変わったようです)

必要なもの
C++17 compiler
jpeg (libjpeg)
libpng
mbedtls (2.9.0 or later?)
BSD make (not GNU make)

BSD makeを導入してGNU makeではなくBSD makeを使います.

$ sudo apt install bmake (1)
$ bmake sayaka (2)
$ src/sayaka --version (3)
sayaka version 3.5.0 (2021/03/03)
$ install src/sayaka ~/bin/ (4)
  1. BSD makeを導入
  2. BSD makeでsayakaをmake
  3. 出来上がったsayakaを叩いてみる
  4. sayakaを適当な場所( ~/bin )にコピーにinstall

ということでsayaka 3.5.0 にできました :)

私はmlterm等のSIXEL対応端末で検索したいキーワードを繋げていってデスクトップの横においておくといった感じで使っています.

環境
$ sayaka --version
sayaka version 3.5.0 (2021/03/03)
$ ldd src/sayaka | cut -f1 -d"(" | cut -f3 -d" " | xargs -n1 apt-file search | cut -f1 -d: | uniq | xargs dpkg-query -W | grep amd64
libbsd0:amd64   0.11.3-1
libc6:amd64     2.31-9
libgcc-s1:amd64 10.2.1-6
libjpeg62-turbo:amd64   1:2.0.6-2
libmbedcrypto3:amd64    2.16.9-0.1
libmbedtls12:amd64      2.16.9-0.1
libmbedx509-0:amd64     2.16.9-0.1
libmd0:amd64    1.0.3-3
libpng16-16:amd64       1.6.37-3
libstdc++6:amd64        10.2.1-6
zlib1g:amd64    1:1.2.11.dfsg-2
$ dpkg-query -W bmake build-essential
bmake   20200710-7
build-essential 12.9
$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -m
x86_64
]]>
https://matoken.org/blog/2021/03/06/build-the-latest-version-3-5-0-of-twitter-client-sayaka-on-linux/feed/ 0
盆栽楽しい https://matoken.org/blog/2021/03/05/bonsai-is-fun/ https://matoken.org/blog/2021/03/05/bonsai-is-fun/#respond Fri, 05 Mar 2021 10:04:23 +0000 http://matoken.org/blog/?p=3049

cbonsai

盆栽が表示できるアプリです.

sourceとx86_64用の.debがあります.armhf環境でsourceからbuildしてみました.

$ sudo apt install libncurses-dev build-essential
$ git clone https://gitlab.com/jallbrit/cbonsai
$ cd cbonsai
$ make
$ install ./cbonsai ~/bin/

いくつかの実行例です.

$ cbonsai (1)
$ cbonsai -p (2)
$ cbonsai -l (3)
$ cbonsai -l -t 0.01 (4)
$ cbonsai -c '<>' (5)
$ cbonsai -m "hello BONSAI" (6)
$ cbonsai -i -w1 (7)
  1. 盆栽を表示(なにかキー入力で終了)
  2. 盆栽をプリントして終了
  3. ライブモード
  4. ライブモードで速度を1/3に(既定値0.03で単位は秒)
  5. 葉っぱを変更
  6. メッセージを表示(マルチバイト文字は不可)
  7. 無限に表示,間隔を1秒間隔に(既定値は4.00秒)

楽しいです🌳

ログイン時に盆栽とfortuneのメッセージを表示したいときはこんな感じで.

$ echo 'cbonsai -p -m "`fortune`"' >> ~/.profile

環境
$ git log -1
commit 15e19580ddc58741291386000076928b2e591ef2 (HEAD -> master, origin/master, origin/HEAD)
Author: John A <jallbritten6@gmail.com>
Date:   Thu Mar 4 10:37:32 2021 -0500

    Update install instructions and add bashrc notice

$ dpkg-query -W libncurses-dev build-essential
build-essential 12.6
libncurses-dev:armhf    6.1+20181013-2+deb10u2
$ lsb_release -dr
Description:    Raspbian GNU/Linux 10 (buster)
Release:        10
$ arch
armv7l
$ cat /proc/device-tree/model && echo
Raspberry Pi 3 Model B Rev 1.2
]]>
https://matoken.org/blog/2021/03/05/bonsai-is-fun/feed/ 0
CLI な podcast aggregator/downloader な podracer を試してみる https://matoken.org/blog/2016/01/28/try-the-cli-of-podcat-aggregator-downloader-of-podracer/ https://matoken.org/blog/2016/01/28/try-the-cli-of-podcat-aggregator-downloader-of-podracer/#comments Thu, 28 Jan 2016 05:42:30 +0000 http://matoken.org/blog/?p=1080

podcast aggregator に rhythmbox を利用しているのですが,たまにファイルが存在するのに何度やってもダウンロードに失敗したり NotePC で動かしているので容量の問題で古いのをファイルサーバに持って行ったりといった処理が面倒です.
CIL で動くものがあればファイルサーバで入手するようにして新しい物だけ手元に or ファイルサーバ経由で視聴するようにしら便利かもということで CLI で動く podcast aggregator が無いか探してみました.

$ apt-cache search podcast aggregator
gpodder - podcast client and feed aggregator
podracer - podcast aggregator/downloader

gpodder は GUI と CLI のセットで,podracer は CLI のみのようです.今回は podracer を試してみます.

導入

導入は apt 一発です.

$ sudo apt install podracer

設定ファイルの用意

~/.podracer/subscriptions というファイルに入手したいフィードを1フィード1行で書いておきます.# 行はコメントになるようです.

# 電脳空間カウボーイズ
http://feeds.feedburner.com/weblogs/csc
# backspace.fm
http://feeds.backspace.fm/backspacefm
:

実行

podracer コマンドを実行すると,~/.podracer/subscriptions からpodcast をダウンドードしてくれます.ダウンロードが完了すると自動的に終了します.

$ podracer

初回実行時には過去のものも入手するので時間が掛かるでしょう.特に画面には何も表示されないのでログファイル( ~/.podracer/podcast.log ) を確認するといいと思います.

$ tail -f ~/.podracer/podcast.log

取得した podcast は ~/podcasts 以下の日付ファイルの下に保存されます.この日付は実行日時です.

$ ls ~/podcasts
2016-01-27  2016-01-28
$ ls -lA ~/podcasts/2016-01-28
合計 59408
-rw-r--r-- 1 mk mk        0  1月 28 14:03 2016-01-28-podcasts.m3u
-rw-r--r-- 1 mk mk 60833627  1月 28 14:02 jlEV91AshKrq
$ file  ~/podcasts/2016-01-28/*
/home/mk/podcasts/2016-01-28/2016-01-28-podcasts.m3u: empty
/home/mk/podcasts/2016-01-28/jlEV91AshKrq:            Audio file with ID3 version 2.3.0

後は各種プレイヤーで再生できます.

$ mplayer ~/podcasts/2016-01-28/jlEV91AshKrq

ファイル名は podcast 提供者の物のままで同じディレクトリに格納されてしまうので名前が衝突したら多分新しい方で上書きされてしまいます.それとこのままではどのファイルがどの podcast なのかとかわからないですね.オプションも特に無いようなので沢山の podcast を保管しようという用途で使うのには向いていないかもしれません.
毎日実行して今日の分をまとめて再生して消してというように使う感じなのかもしれません.

追記)プレイリストの不具合?

podracer 実行時に 2016-01-28-podcasts.m3u のようなプレイリストが作られますが,mp3/ogg/m4a/m4b 以外の拡張子は登録されません.こんな感じで作り直すと良さそう.

$ ls -1A ~/podcasts/2016-01-28 | grep -v \.m3u$ > ~/podcasts/2016-01-28/2016-01-28-podcasts.m3u

この方がいいかな

$ ls -1A ~/podcasts/`date +%F` | grep -v \.m3u$ > ~/podcasts/`date +%F`/`date +%F`-podcasts.m3u

podracer 自体を修正してもいいかも.雑いけどこんなとか.
これだとサムネイル画像なども含まれてしまう.

$ diff -u /usr/bin/podracer podracer
--- /usr/bin/podracer   2015-07-04 22:39:26.000000000 +0900
+++ podracer    2016-01-28 18:34:40.317391930 +0900
@@ -415,10 +415,7 @@
                then
                (
                cd "$poddir"
-               find . -name \*.mp3 > "$m3u"
-               find . -name \*.ogg  >> "$m3u"
-               find . -name \*.m4a  >> "$m3u"
-               find . -name \*.m4b  >> "$m3u"
+               find . -name \* -type f | grep -v "$m3u" > "$m3u"
                )
        fi
 fi

追記2)
上の修正だとサムネイル画像なども登録されてしまう.
以下はその他のファイルを file command で調べて audio という文字列が入っていたら登録するもの.

$ diff -u /usr/bin/podracer ./podracer
--- /usr/bin/podracer   2015-07-04 22:39:26.000000000 +0900
+++ ./podracer  2016-01-28 19:12:31.980446668 +0900
@@ -419,6 +419,7 @@
                find . -name \*.ogg  >> "$m3u"
                find . -name \*.m4a  >> "$m3u"
                find . -name \*.m4b  >> "$m3u"
+               find . | egrep -v "\.mp3$|\.ogg$|\.m4a$|\.m4b$" | xargs file | grep -i audio | cut -f1 -d: >> "$m3u"
                )
        fi
 fi

]]>
https://matoken.org/blog/2016/01/28/try-the-cli-of-podcat-aggregator-downloader-of-podracer/feed/ 3