tmux – matoken's blog https://matoken.org/blog Is there no plan B? Fri, 04 Oct 2024 19:56:57 +0000 ja hourly 1 https://wordpress.org/?v=6.8.3 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg tmux – matoken's blog https://matoken.org/blog 32 32 tmux 3.5 release https://matoken.org/blog/2024/10/05/tmux-3-5-release/ https://matoken.org/blog/2024/10/05/tmux-3-5-release/#respond Fri, 04 Oct 2024 20:51:00 +0000 https://matoken.org/blog/?p=4107

tmux 3.5 がリリースされました。

早速build します。

$ sudo apt build-dep tmux (1)
$ sudo apt install libjemalloc-dev (2)
$ git clone https://github.com/tmux/tmux
$ cd tmux
$ git checkout 3.5
$ ./configure --enable-sixel \ (3)
              --enable-jemalloc \ (4)
              --prefix=$HOME/local (5)
$ make
$ make install
$ which tmux
/home/matoken/local/bin/tmux
$ tmux -V
tmux 3.5
  1. tmux の build に必要なパッケージを導入

  2. tmux 3.5 で新しく利用できるようになった --enable-jemalloc のためのパッケージ導入

  3. sixel を有効にする

  4. jemalloc を有効にする

  5. インストール場所を指定

数日使っていますが問題無さそうです。

しかし、tmux 3.5 は早かったですね。そういえば GNU screen 5.0.0 も最近出ました。

Note

tmux 3.3a: 2022-01-09
tmux 3.4: 2024-02-13
GNU screen 5.0.0: 2024-08-29
tmux 3.5: 2024-09-27

環境
$ tmux -V
tmux 3.5
$ lsb_release -dr
Description:    Debian GNU/Linux trixie/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2024/10/05/tmux-3-5-release/feed/ 0
AlmaLinux でも tmux で Sixel を https://matoken.org/blog/2023/12/02/sixel-with-tmux-on-almalinux/ https://matoken.org/blog/2023/12/02/sixel-with-tmux-on-almalinux/#respond Sat, 02 Dec 2023 09:42:08 +0000 https://matoken.org/blog/?p=3942

AlmaLinux でもSixel 対応版tmux のbuild をしてみました.

tmux alma

KVM 環境にAlmaLinux 9.3 を導入してmlterm からssh 経由で接続しています.

tmux のbuild 手順は公式の 「Installing · tmux/tmux Wiki」From source tarball の通りですが, autogen.shaclocal が見つからないと言われたので automake package を導入.Sixel を有効にするために configure--enable-sixel を付けています.

$ sudo dnf install libevent-devel ncurses-devel gcc make bison git automake (1)
$ git clone --depth 1 https://github.com/tmux/tmux (2)
$ cd tmux
$ ./autogen.sh
$ ./configure --enable-sixel (3)
$ make
$ ./tmux -V
tmux next-3.4
$ ./tmux
  1. build に必要なパッケージ導入
  2. tmux のsource を入手
  3. sixel を有効に
環境
$ git -C ~/src/tmux log -1
commit bdf8e614af34ba1eaa8243d3a818c8546cb21812 (grafted, HEAD -> master, origin/master, origin/HEAD)
Author: Thomas Adam <thomas@xteddy.org>
Date:   Tue Nov 14 22:01:09 2023 +0000

    Merge branch 'obsd-master'
$ dnf info libevent-devel ncurses-devel gcc make bison git automake | grep -e '^Name' -e '^Version' -e '^Release'
Name         : automake
Version      : 1.16.2
Release      : 8.el9
Name         : bison
Version      : 3.7.4
Release      : 5.el9
Name         : gcc
Version      : 11.4.1
Release      : 2.1.el9.alma
Name         : git
Version      : 2.39.3
Release      : 1.el9_2
Name         : libevent-devel
Version      : 2.1.12
Release      : 6.el9
Name         : make
Version      : 4.3
Release      : 7.el9
Name         : ncurses-devel
Version      : 6.2
Release      : 10.20210508.el9
Name         : libevent-devel
Version      : 2.1.12
Release      : 6.el9
Name         : ncurses-devel
Version      : 6.2
Release      : 10.20210508.el9
$ ~/src/neofetch/neofetch
         'c:.                              matoken@alma-kvm
        lkkkx, ..       ..   ,cc,          ----------------
        okkkk:ckkx'  .lxkkx.okkkkd         OS: AlmaLinux 9.3 (Shamrock Pampas Cat) x86_64
        .:llcokkx'  :kkkxkko:xkkd,         Host: KVM/QEMU (Standard PC (Q35 + ICH9, 2009) pc-q35-8.1)
      .xkkkkdood:  ;kx,  .lkxlll;          Kernel: 5.14.0-362.8.1.el9_3.x86_64
       xkkx.       xk'     xkkkkk:         Uptime: 3 hours, 33 mins
       'xkx.       xd      .....,.         Packages: 438 (rpm)
      .. :xkl'     :c      ..''..          Shell: bash 5.1.8
    .dkx'  .:ldl:'. '  ':lollldkkxo;       Resolution: 1280x800
  .''lkkko'                     ckkkx.     Terminal: /dev/pts/1
'xkkkd:kkd.       ..  ;'        :kkxo.     CPU: Intel i5-7300U (2) @ 2.712GHz
,xkkkd;kk'      ,d;    ld.   ':dkd::cc,    Memory: 185MiB / 425MiB
 .,,.;xkko'.';lxo.      dx,  :kkk'xkkkkc
     'dkkkkkxo:.        ;kx  .kkk:;xkkd.
       .....   .;dk:.   lkk.  :;,
             :kkkkkkkdoxkkx
              ,c,,;;;:xkkd.
                ;kkkkl...
                ;kkkkl
                 ,od;
$ arch
x86_64
]]>
https://matoken.org/blog/2023/12/02/sixel-with-tmux-on-almalinux/feed/ 0
tmux Sixel でリモート画像を表示して遊ぶ https://matoken.org/blog/2023/11/10/tmux-sixel-fun/ https://matoken.org/blog/2023/11/10/tmux-sixel-fun/#respond Fri, 10 Nov 2023 10:34:00 +0000 https://matoken.org/blog/?p=3932

ターミナルマルチプレクサのtmux がSixel に対応し,グラフィックが使えるようになりました.これで少し遊んでみました.

tmux sixel live rain sayaka

ターミナルマルチプレクサでSixel が使えるようになったということで,リモートの端末でグラフックを扱い,それを必要な時だけ閲覧といったことが可能となります.
例えばライブカメラの映像の最新を取得して表示,

10分+動作時間毎にYoutubeLiveの最新1コマをダウンロードしてpng画像に変換,Sixel で表示し続ける.(画像左)
$ while true; do ffmpeg -i "$(yt-dlp --quiet -f 'bestvideo[height<=640]' -g IWPSU_aXdIE | head -n 1 )" -loglevel -8 -vframes 1 -c:v png -f image2 - | img2sixel ;sleep 60; done

雨雲レーダーの情報をウェブブラウザで取得して表示,

10分+動作時間毎に国土交通省 川の防災情報ページのスクリーンショットを取得して表示(右上)
$ while true; do chromium --headless --hide-scrollbars --window-size=800,500 --screenshot=/tmp/screenshot-rain.png  'https://www.river.go.jp/kawabou/mb?zm=11&fld=0&clat=31.24891059083941&clon=130.67756652832034&mapType=0&viewGrpStg=0&viewRd=1&viewRW=1&viewRiver=1&viewPoint=1&knd=rn' 2>/dev/null ;img2sixel /tmp/screenshot-rain.png ;sleep 600; done
Misskey のローカルタイムラインを表示(右下)
while true; do sayaka --local misskey.io ;sleep 5; done

しかし,RAMの少ないVPS で調子に乗って色々動かして遊んでいたらメモリ不足になりMariaDB を落としてしまいました.リソースと相談しながら遊びましょう…….

server環境
$ tmux -V
tmux next-3.4
$ git -C ~/src/tmux/ log -1 | grep -e ^commit -e ^Date:
commit 381c00a74ea1eb136a97c86da9a7713190b10a62
Date:   Thu Nov 2 22:58:45 2023 +0000
$ sayaka --version
sayaka version 3.7.2 (2023/10/19)
$ dpkg-query -W yt-dlp ffmpeg libsixel-bin ffmpeg chromium
chromium        116.0.5845.180-1~deb12u1
ffmpeg  7:5.1.3-1
libsixel-bin    1.10.3-3
yt-dlp  2023.03.04-1
$ lsb_release -dr
No LSB modules are available.
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
$ arch
x86_64
client環境
$ dpkg-query -W mlterm
mlterm  3.9.3-1
$ lsb_release -dr
No LSB modules are available.
Description:    Debian GNU/Linux trixie/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2023/11/10/tmux-sixel-fun/feed/ 0
Tmux でSixel https://matoken.org/blog/2023/11/06/tmux-in-sixel/ https://matoken.org/blog/2023/11/06/tmux-in-sixel/#comments Sun, 05 Nov 2023 23:47:28 +0000 https://matoken.org/blog/?p=3923

ターミナルマルチプレクサの中で今一番利用されているであろうtmux にSIXEL branch がMarge されていたのに気づいたので試してみました.

8月に取り込まれていたのですね.未だリリースはされていないのでgit でsource を貰ってきて試しました.

Note

Debianだとexperimental は対応バージョンのようですが,Sixel が有効にしてあるかは未確認.

$ rmadison tmux
tmux       | 2.8-3             | oldoldstable             | source, amd64, arm64, armel, armhf, i386, mips, mips64el, mipsel, ppc64el, s390x
tmux       | 3.1c-1~bpo10+1    | buster-backports         | source, amd64, arm64, armel, armhf, i386, mips, mips64el, mipsel, ppc64el, s390x
tmux       | 3.1c-1~bpo10+1    | buster-backports-debug   | source
tmux       | 3.1c-1+deb11u1    | oldstable                | source, amd64, arm64, armel, armhf, i386, mips64el, mipsel, ppc64el, s390x
tmux       | 3.1c-1+deb11u1    | oldstable-debug          | source
tmux       | 3.3a-3~bpo11+1    | bullseye-backports       | source, amd64, arm64, armel, armhf, i386, mips64el, mipsel, ppc64el, s390x
tmux       | 3.3a-3~bpo11+1    | bullseye-backports-debug | source
tmux       | 3.3a-3            | stable                   | source, amd64, arm64, armel, armhf, i386, mips64el, mipsel, ppc64el, s390x
tmux       | 3.3a-5            | testing                  | source, amd64, arm64, armel, armhf, i386, mips64el, ppc64el, s390x
tmux       | 3.3a-5            | unstable                 | source, amd64, arm64, armel, armhf, i386, mips64el, ppc64el, riscv64, s390x
tmux       | 3.3a-5            | unstable-debug           | source
tmux       | 3.4~git20230924-1 | experimental             | source, amd64, arm64, armel, armhf, i386, mips64el, ppc64el, riscv64, s390x
tmux       | 3.4~git20230924-1 | experimental-debug       | source

追記) 有効になっているよう

$ curl -s https://metadata.ftp-master.debian.org/changelogs//main/t/tmux/tmux_3.4~git20230924-1_changelog | grep -A3 3.4~git20230924-1
tmux (3.4~git20230924-1) experimental; urgency=medium

  * New upstream snapshot, from Git commit b777780720.
  * Enable Sixel support.
$ sudo apt install vlock build-essential git
$ sudo apt build-dep tmux
$ git clone https://github.com/tmux/tmux
$ cd tmux
x$ git log -1
commit b77778072052c14d1450d2eb89542f2493121f84 (HEAD -> master, origin/master, origin/HEAD)
Merge: 0ca28b36 347cd0b5
Author: Thomas Adam <thomas@xteddy.org>
Date:   Tue Sep 19 12:01:11 2023 +0100

    Merge branch 'obsd-master'
$ ./configure --enable-sixel --prefix=/usr/local
$ make
$ ./tmux

tmux の上でSixel を表示してみます.

tmux sixel

大丈夫そうです.

tmux sixel split

画面分割してみても大丈夫そう.(左はtig でtmux リポジトリを表示,右上はchromium で取得した国土交通省 川の防災情報のスクリーンショットを表示,右下はsayaka でMisskey 表示)

ウィンドウ切り替えをするとSixel 画像は消えてしまうようです.
ssh 経由でリモートサーバのtmux でもSixel 表示OK なのでリモートで画像を取得表示して細い回線で必要なときにリモートのtmux に繋いで利用といったこともできて便利です.

mosh を挟むと駄目なようなのが残念.

追記) Sixel を使っていないタイミングでもtmux が落ちるように?安定度に難ありかも.とりあえずDebian pkg 版と併用しようと思います.

環境1
$ git log -1
commit b77778072052c14d1450d2eb89542f2493121f84 (HEAD -> master, origin/master, origin/HEAD)
Merge: 0ca28b36 347cd0b5
Author: Thomas Adam <thomas@xteddy.org>
Date:   Tue Sep 19 12:01:11 2023 +0100

    Merge branch 'obsd-master'
$ tmux -V
tmux next-3.4
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux trixie/sid
Release:        n/a
Codename:       trixie
$ arch
x86_64
環境2
$ git log -1 -q
commit 381c00a74ea1eb136a97c86da9a7713190b10a62 (HEAD -> master, origin/master, origin/HEAD)
Merge: a5545dbc 5aadee6d
Author: Thomas Adam <thomas@xteddy.org>
Date:   Thu Nov 2 22:58:45 2023 +0000

    Merge branch 'obsd-master'
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm
$ arch
x86_64
]]>
https://matoken.org/blog/2023/11/06/tmux-in-sixel/feed/ 1
Byobu tmuxでファンクションキーを無効にする https://matoken.org/blog/2020/10/10/disable-function-keys-in-byobu-tmux/ https://matoken.org/blog/2020/10/10/disable-function-keys-in-byobu-tmux/#respond Fri, 09 Oct 2020 16:07:53 +0000 http://matoken.org/blog/?p=2867

アドホックに切り替える

Ctrl+b shift + F12 でトルグ

設定ファイルに設定する

~/.byobu/keybindings.tmux の1行目に
source /usr/share/byobu/keybindings/f-keys.tmux.disable を追記.

Byobu tmuxを起動し直すか,Ctrl+b : :source-file ~/.byobu/keybindings.tmux で反映する.

Byobu GNU screenの場合はこちら

環境
$ dpkg-query -W byobu tmux
byobu   5.133-1
tmux    3.1b-1
$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -m
x86_64
]]>
https://matoken.org/blog/2020/10/10/disable-function-keys-in-byobu-tmux/feed/ 0
vlock コマンドで tmux をロックする https://matoken.org/blog/2019/06/30/lock-tmux-with-vlock-command/ https://matoken.org/blog/2019/06/30/lock-tmux-with-vlock-command/#respond Sun, 30 Jun 2019 14:03:00 +0000 http://matoken.org/blog/?p=2408

現在ターミナルマルチプレクサは Byobu 経由で GNU screen と tmux を環境により併用しています.GNU screen では画面ロックの設定をしていたのですがtmux は設定していなかったので今回 console lock コマンドの vlock を設定してみました.

導入
$ sudo apt install vlock
help
$ vlock -h
vlock: locks virtual consoles, saving your current session.
Usage: vlock [options] [plugins...]
	   Where [options] are any of:
-c or --current: lock only this virtual console, allowing user to
	   switch to other virtual consoles.
-a or --all: lock all virtual consoles by preventing other users
	   from switching virtual consoles.
-n or --new: allocate a new virtual console before locking,
	   implies --all.
-s or --disable-sysrq: disable SysRq while consoles are locked to
	   prevent killing vlock with SAK
-t <seconds> or --timeout <seconds>: run screen saver plugins
	   after the given amount of time.
-v or --version: Print the version number of vlock and exit.
-h or --help: Print this help message and exit.
カレントコンソールをlock してみる.何かキーを押した後ユーザのパスワードを入力することで復帰できる.
$ vlock -c
This TTY is now locked.

Please press [ENTER] to unlock.
matoken's Password:
全てのコンソールをロックする.ロック状態で Alt + n で他のコンソールに移動しても全てロックされている.
$ vlock -a
The entire console display is now completely locked.
You will not be able to switch to another virtual console.

Please press [ENTER] to unlock.
matoken's Password:
$ tty
/dev/tty1
仮想コンソール(Xの端末, ターミナルマルチプレクサ, script等)では全てのロックは失敗する
$ vlock -a
vlock: this terminal is not a virtual console
$ tty
/dev/pts/9
tmux に設定してみる(byobu 経由の場合)
$ cat ~/.byobu/.tmux.conf
# Enable locking(I need vlock -> sudo apt install vlock)
set -g lock-command vlock
set -g lock-after-time 0
bind l lock-session

.tmux.conf に設定した状態で tmux を起動して Ctrl+b l と押すと vlock でロックされます.セッション単位でロックされます.

ちなみに X では xscreensaver-command -activate を設定しています.例えば以下は awesome wm で Mod4 + l に設定してあります.

    -- lock screen
    awful.key({ "Mod1"  }, "l", function () awful.util.spawn( "xscreensaver-command -activate",false) end),
環境1
$ dpkg-query -W byobu screen tmux vlock
byobu   5.129-1
screen  4.6.2-3
tmux    2.8-3
vlock   2.2.2-8
$ hostnamectl | egrep 'Operating System|Architecture'
  Operating System: Debian GNU/Linux 10 (buster)
      Architecture: x86-64

]]>
https://matoken.org/blog/2019/06/30/lock-tmux-with-vlock-command/feed/ 0