📘

モダン man ページビュアー qman

に公開

モダン man ページビュアー qman を紹介する。

主な特徴

  • man ページ内のセクションの目次を表示し、セクションにジャンプできる
  • man ページ内で参照している別の man ページをリンクに変換し、リンクの man ページへ遷移できる
  • man ページのインデックスを表示し、検索して選択した man ページに遷移できる
  • man ページの履歴を確認して、過去に表示していた man ページに遷移できる

Ubuntu 24.04 でのインストール

インストール方法はこちらに記載されている。
Ubuntu 24.04 (WSL2) でインストールした手順を紹介する。
システムインストールではなくユーザーのホームディレクトリ下にインストールする。

実行時依存ライブラリ

manaproposwhatisncurseswgroff が必要。
私の環境ではいずれもインストール済みだった。ncurseswlibncursesw6 がインストールされていた。
なければ apt でインストールする。

ビルド依存ライブラリ

必須の依存物:

オプショナルな依存物:

  • zlib
    • gzip で圧縮した man ページのサポートに必要
  • bzip2
    • bzip2 で圧縮した man ページのサポートに必要
    • Ubuntu 24.04 のバグで追加対応が必要
  • liblzma
    • xz で圧縮した man ページのサポートに必要
  • cunit
    • ユニットテストで使うものであり、オプショナルとされているので不要かと思ったが、ないとビルド時にエラーになる

オプショナルな依存ライブラリは次のコマンドでインストールできる。

sudo apt install zlib1g-dev libbz2-dev liblzma-dev libcunit1-dev

Meson のインストール

Meson には Ninja が必要なので Ninja もインストールする。
mise を使ってインストールする。

mise use -g ninja@latest
mise use -g pipx:meson@latest

Ninja はバージョン1.13.1、Meson はバージョン1.9.0がインストールされた。

cogapp のインストール

cogapp も mise でインストールする。

mise use -g pipx:cogapp@latest

bzip2 の pkg-config 設定ファイル

Ubuntu 24.04 には pkg-configbzip2 を見つけられないバグがある。
こちらに報告されている。

このバグに対応するために次の内容で /usr/local/lib/pkgconfig/bzip2.pc を作成する。

prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib/x86_64-linux-gnu
includedir=${prefix}/include

Name: bzip2
Description: bzip2 high-quality block-sorting file compressor library - runtime
Version: 1.0.8
Libs: -L${libdir} -lbz2
Cflags: -I${includedir}

環境変数 PKG_CONFIG_PATH/usr/local/lib/pkgconfig を設定しておく。

set -Ux PKG_CONFIG_PATH /usr/local/lib/pkgconfig

ソースをダウンロード

mkdir ~/src
cd ~/src
curl -L -o qman-v1.5.0.tar.gz https://github.com/plp13/qman/archive/refs/tags/v1.5.0.tar.gz
tar -x -f qman-v1.5.0.tar.gz -z

~/src/qman-1.5.0 にソースが展開された。

ビルド & インストール

まずはソースディレクトリ ~/src/qman-1.5.0 で Meson のセットアップを行う。

$ meson setup -Dprefix=$HOME/qman/1.5.0 -Dconfigdir=$HOME/qman/1.5.0/config -Dlocalstatedir=$HOME/.local -Dsharedstatedir=$HOME/.local/state build
The Meson build system
Version: 1.9.0
Source dir: /home/kit494way/src/qman-1.5.0
Build dir: /home/kit494way/src/qman-1.5.0/build
Build type: native build
Project name: qman
Project version: 1.5.0
C compiler for the host machine: cc (gcc 13.3.0 "cc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0")
C linker for the host machine: cc ld.bfd 2.42
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program cog found: YES (/home/kit494way/.local/share/mise/installs/pipx-cogapp/3.5.1/bin/cog)
Found pkg-config: YES (/usr/bin/pkg-config) 1.8.1
Run-time dependency ncursesw found: YES 6.4.20240113
Run-time dependency zlib found: YES 1.3
Run-time dependency bzip2 found: YES 1.0.8
Run-time dependency liblzma found: YES 5.4.5
Run-time dependency cunit found: YES 2.1-3
Build targets in project: 3

qman 1.5.0

  User defined options
    configdir     : /home/kit494way/qman/1.5.0/config
    localstatedir : /home/kit494way/.local
    prefix        : /home/kit494way/qman/1.5.0
    sharedstatedir: /home/kit494way/.local/state

Found ninja-1.13.1 at /home/kit494way/.local/share/mise/installs/ninja/1.13.1/ninja

最後の引数 build はビルドディレクトリ。
デフォルトでは /etc 以下に設定ファイルをインストールしようとする。
-Dconfigdir=$HOME/qman/1.5.0/config でデフォルトの設定ファイルのインストール先を変更している。

meson setup をやり直すときは --reconfigure オプションを指定してを実行する。
-D で指定した設定を変更するだけなら meson setup の代わりに meson configure でできる。

-Dprefix で指定したインストール先のディレクトリを作成する。

mkdir -p ~/qman/1.5.0

build ディレクトリに移動して meson compile を実行する。

$ cd build
$ meson compile
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /home/kit494way/.local/share/mise/installs/ninja/1.13.1/ninja
[0/1] Regenerating build files
The Meson build system
Version: 1.9.0
Source dir: /home/kit494way/src/qman-1.5.0
Build dir: /home/kit494way/src/qman-1.5.0/build
Build type: native build
Project name: qman
Project version: 1.5.0
C compiler for the host machine: cc (gcc 13.3.0 "cc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0")
C linker for the host machine: cc ld.bfd 2.42
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program cog found: YES (/home/kit494way/.local/share/mise/installs/pipx-cogapp/3.5.1/bin/cog)
Dependency ncursesw found: YES 6.4.20240113 (cached)
Dependency zlib found: YES 1.3 (cached)
Dependency bzip2 found: YES 1.0.8 (cached)
Dependency liblzma found: YES 5.4.5 (cached)
Dependency cunit found: YES 2.1-3 (cached)
Build targets in project: 3

qman 1.5.0

  User defined options
    configdir     : /home/kit494way/.config/qman
    localstatedir : /home/kit494way/.local
    prefix        : /home/kit494way/qman/1.5.0
    sharedstatedir: /home/kit494way/.local/state

Found ninja-1.13.1 at /home/kit494way/.local/share/mise/installs/ninja/1.13.1/ninja
Cleaning... 0 files.
[11/12] Linking target src/qman

インストールを実行。

$ meson install
ninja: Entering directory `/home/kit494way/src/qman-1.5.0/build'
ninja: no work to do.
Installing src/qman to /home/kit494way/qman/1.5.0/bin
Installing /home/kit494way/src/qman-1.5.0/man/qman.1 to /home/kit494way/qman/1.5.0/share/man/man1
Installing /home/kit494way/src/qman-1.5.0/config/qman.conf to /home/kit494way/qman/1.5.0/config
Installing /home/kit494way/src/qman-1.5.0/config/themes/modernity.conf to /home/kit494way/qman/1.5.0/config/themes
Installing /home/kit494way/src/qman-1.5.0/config/themes/modernity-light.conf to /home/kit494way/qman/1.5.0/config/themes
Installing /home/kit494way/src/qman-1.5.0/config/themes/adwaita.conf to /home/kit494way/qman/1.5.0/config/themes
Installing /home/kit494way/src/qman-1.5.0/config/themes/adwaita-light.conf to /home/kit494way/qman/1.5.0/config/themes
Installing /home/kit494way/src/qman-1.5.0/config/themes/catppuccin_latte.conf to /home/kit494way/qman/1.5.0/config/themes
Installing /home/kit494way/src/qman-1.5.0/config/README.md to /home/kit494way/qman/1.5.0/share/doc/qman/config
Installing /home/kit494way/src/qman-1.5.0/doc/BUILDING.md to /home/kit494way/qman/1.5.0/share/doc/qman/doc
Installing /home/kit494way/src/qman-1.5.0/doc/CONTRIBUTING.md to /home/kit494way/qman/1.5.0/share/doc/qman/doc
Installing /home/kit494way/src/qman-1.5.0/doc/DEBUGGING.md to /home/kit494way/qman/1.5.0/share/doc/qman/doc
Installing /home/kit494way/src/qman-1.5.0/doc/OS_SPECIFIC.md to /home/kit494way/qman/1.5.0/share/doc/qman/doc
Installing /home/kit494way/src/qman-1.5.0/doc/PACKAGES.md to /home/kit494way/qman/1.5.0/share/doc/qman/doc
Installing /home/kit494way/src/qman-1.5.0/doc/TESTING.md to /home/kit494way/qman/1.5.0/share/doc/qman/doc
Installing /home/kit494way/src/qman-1.5.0/doc/TROUBLESHOOTING.md to /home/kit494way/qman/1.5.0/share/doc/qman/doc
Installing /home/kit494way/src/qman-1.5.0/README.md to /home/kit494way/qman/1.5.0/share/doc/qman

qman 自身のマニュアルを ~/.local/share/man 以下に配置する。

ln -s ~/qman/1.5.0/share/man/man1/qman.1 ~/.local/share/man/man1/

マニュアルのインデックスを更新。

mandb ~/.local/share/man

実行

qman を実行すると全てのマニュアルのインデックスが表示され、任意のマニュアルを選択して遷移できる。
qman qman のように実行すると指定したマニュアルを表示した状態で起動する。

設定

デフォルトの設定ファイルはビルド時に指定したディレクトリ ~/qman/1.5.0/config 以下にインストールされている。
設定をカスタマイズするには ~/.config/qman 以下にコピーして変更すればよい。

cp -r ~/qman/1.5.0/config ~/.config/qman

カラーテーマ

組み込みのカラーテーマがいくつか用意されていて ~/qman/1.5.0/config/themes ディレクトリにインストールされている。
qman.conf から include するようになっている。

include themes/modernity.conf

tmux で set -g default-terminal tmux-256color を設定しているとカラーテーマが意図した色にならない。
環境変数 TERMxterm-256color を設定して実行すると意図通りの色になる。

TERM=xterm-256colorqman を実行するために fish の関数(~/.config/fish/functions/qman.fish)を作成して対応した。

function qman
    TERM=xterm-256color command qman $argv
end

clipboard

マウスで選択したテキストをクリップボードにコピーする機能がある。
これを有効にするには次の設定を追加する。

[tcap]
clipboard=true

tmux 内で利用するには tmux.conf で次の設定も必要になる。

set -g set-clipboard on

補足

こちらの issue でビルド済みのバイナリを配布する話が進んでいる。
そのうち自分でビルドしなくてもよくなるかもしれない。

Discussion