1
0
Fork 0
forked from murx/murx

Rename moerx to murx and refactor session display options

This commit is contained in:
Johannes Findeisen 2026-11-17 03:06:45 +01:00
commit 984722aa47
8 changed files with 235 additions and 214 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
# Build files # Build files
moerx murx
*.o *.o
# Packages # Packages

View file

@ -1,12 +1,12 @@
# moerx project instructions # murx project instructions
moerx is a deliberately small terminal multiplexer: one C99 source file murx is a deliberately small terminal multiplexer: one C99 source file
(`moerx.c`), no dependencies, no config file. (`murx.c`), no dependencies, no config file.
## Build ## Build
```sh ```sh
make # cc -O2 -std=c99 -Wall -Wextra -o moerx moerx.c make # cc -O2 -std=c99 -Wall -Wextra -o murx murx.c
make clean make clean
``` ```
@ -16,7 +16,7 @@ outside the repo for geometry/logic checks; do not leave test files behind.
## Conventions ## Conventions
- Keep changes inside `moerx.c` where possible; the single-file design is - Keep changes inside `murx.c` where possible; the single-file design is
intentional. intentional.
- `README.md` is user-facing documentation. Update it when shortcuts, behavior, - `README.md` is user-facing documentation. Update it when shortcuts, behavior,
or limitations change. or limitations change.
@ -40,7 +40,7 @@ outside the repo for geometry/logic checks; do not leave test files behind.
## Current work (2026-10-30) ## Current work (2026-10-30)
Reworked `select_pane_dir()` in `moerx.c` so `Ctrl-A h/j/k/l` and the arrow Reworked `select_pane_dir()` in `murx.c` so `Ctrl-A h/j/k/l` and the arrow
keys choose the pane exactly left/down/up/right: keys choose the pane exactly left/down/up/right:
1. Only panes strictly beyond the active pane's edge in the requested direction 1. Only panes strictly beyond the active pane's edge in the requested direction

View file

@ -1,13 +1,13 @@
# Local source snapshot; refresh checksums with `abuild checksum` after edits. # Local source snapshot; refresh checksums with `abuild checksum` after edits.
pkgname=moerx pkgname=murx
pkgver=0.20261116 pkgver=0.20261116
pkgrel=0 pkgrel=0
pkgdesc="Small persistent terminal multiplexer" pkgdesc="Small persistent terminal multiplexer"
url="https://codeberg.org/armin/moerx" url="https://codeberg.org/armin/murx"
arch="all" arch="all"
license="Apache-2.0" license="Apache-2.0"
subpackages="$pkgname-doc" subpackages="$pkgname-doc"
source="moerx.c Makefile moerx.1 README.md LICENSE" source="murx.c Makefile murx.1 README.md LICENSE"
builddir="$srcdir" builddir="$srcdir"
build() { build() {
@ -15,7 +15,7 @@ build() {
} }
check() { check() {
./moerx --help >/dev/null ./murx --help >/dev/null
} }
package() { package() {
@ -25,9 +25,9 @@ package() {
} }
sha512sums=" sha512sums="
0a0cedb8702b5ac041896065c6d36d22f57deffdc3f8023c9b02b7b87218dfcd32a8e2eaecfc470930d1d1228109cf6894ba8e5242ebcf760ef2dd17ab35d2ab moerx.c efd4dd0bcfd3ef36b1e4b8285452690f684a29e7906c0ada7aa09f879143b998a6e9cb8ddc76eb861867f882c7cb7f5a1fb350ce102e67a632d8ea238eba9b65 murx.c
e6336e712a9a6071b16cbde83cd6f591c480da68cf5185f0db27f321b26adb075844a958e792da419dcb82a930de6cff28bc64a98e9b0facd9350e382aa95ce1 Makefile 4f52ecfc78bb993f9bdbaa235f671fe54327497fa8e21517805a2696bea9f06d335e4da564d0019ec1fad86986c05bce90e4825dcebc2ef3c0bc66fb9a768030 Makefile
cc677bc8c9637963dd19a031c0920f7178e71a93d236d1445ef4a5cbabefd3b3a68d9696444d2a6d0a9993ed05df55e8de876e7e515bd31effaeb7425c90a52a moerx.1 523ac85c9b789a7721c76e8f7691a1a8ab43d7fec2624f43b3850e5135451d94404d8711fa40422a67e9f13b7388470436ab06deb6ad7c87c7e72a37492ae617 murx.1
d1bc928e391b50a0031834396b8f655474d8073399f94e7c5dbf7469977a1ff7665db1c21ced7180bf7a891584dae61f52e1ef345ef75ab3348705aeb0d091e0 README.md b6595d86edb76ec4ef90a1b44dfc350543f501b1c5bd41dbd2fe5b479c57d871f83eff9021b0407bb8b791e410128c70c9c0772a9328cded90e67f70cc20b9d4 README.md
2fe33ba22c5f68e124904be594208f050be20f33d115f9a56f60cac93304102da32e6a7e78154e831d3704da7ca8bfefd7025e7b8901e65babcd83e7342f6382 LICENSE 2fe33ba22c5f68e124904be594208f050be20f33d115f9a56f60cac93304102da32e6a7e78154e831d3704da7ca8bfefd7025e7b8901e65babcd83e7342f6382 LICENSE
" "

View file

@ -5,21 +5,21 @@ PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin BINDIR = $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man MANDIR ?= $(PREFIX)/share/man
all: moerx all: murx
moerx: moerx.c murx: murx.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ moerx.c $(LDLIBS) $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ murx.c $(LDLIBS)
install: moerx moerx.1 install: murx murx.1
install -d "$(DESTDIR)$(BINDIR)" "$(DESTDIR)$(MANDIR)/man1" install -d "$(DESTDIR)$(BINDIR)" "$(DESTDIR)$(MANDIR)/man1"
install -m 755 moerx "$(DESTDIR)$(BINDIR)/moerx" install -m 755 murx "$(DESTDIR)$(BINDIR)/murx"
install -m 644 moerx.1 "$(DESTDIR)$(MANDIR)/man1/moerx.1" install -m 644 murx.1 "$(DESTDIR)$(MANDIR)/man1/murx.1"
uninstall: uninstall:
rm -f "$(DESTDIR)$(BINDIR)/moerx" rm -f "$(DESTDIR)$(BINDIR)/murx"
rm -f "$(DESTDIR)$(MANDIR)/man1/moerx.1" rm -f "$(DESTDIR)$(MANDIR)/man1/murx.1"
clean: clean:
rm -f moerx rm -f murx
.PHONY: all install uninstall clean .PHONY: all install uninstall clean

View file

@ -1,18 +1,18 @@
# Local source snapshot; refresh checksums with `updpkgsums` after edits. # Local source snapshot; refresh checksums with `updpkgsums` after edits.
pkgname=moerx pkgname=murx
pkgver=0.20261116 pkgver=0.20261116
pkgrel=1 pkgrel=1
pkgdesc='Small persistent terminal multiplexer' pkgdesc='Small persistent terminal multiplexer'
arch=('x86_64' 'aarch64') arch=('x86_64' 'aarch64')
url='https://codeberg.org/armin/moerx' url='https://codeberg.org/armin/murx'
license=('Apache-2.0') license=('Apache-2.0')
depends=('glibc') depends=('glibc')
source=('moerx.c' 'Makefile' 'moerx.1' 'README.md' 'LICENSE') source=('murx.c' 'Makefile' 'murx.1' 'README.md' 'LICENSE')
sha256sums=( sha256sums=(
'6269f68e371de276308b25e4b3d3acadcd2eaec0ba86537571d2cf80ade5e97b' '921e2c446c2ba83192b883411bf2d9686da028374c8a10125086a97aa28e61f4'
'ad08bd0acd671f1f1716250528c2d4e5acc78a83bf55fcebdf41fa101fbb71d5' '1d77a97ff77ce6d876baef98e22b06cfa2109a4ae65cef8b75a91df4c02ad8ac'
'38b60956c86513c53bd129cb3541b28ac161c17d56c58441e8904cba7ea501d8' 'f07830b93f78674956a17b108738d52c3d3efd58f431dc29f137cc339d625ee5'
'03a41aae42949ea1ed840d56ff66e0de0d0b1e54f1a457709ba2bf84ffaee33b' '8f658ba4ffc508e4fb3d267504d40e7fb9227189626a864a2cd644d3f8c976b0'
'31c5556be4cdd9bf52bb55f18ead0c68a4f0e793c2c2dab0a2a2c6d92407d0d4' '31c5556be4cdd9bf52bb55f18ead0c68a4f0e793c2c2dab0a2a2c6d92407d0d4'
) )
@ -23,7 +23,7 @@ build() {
check() { check() {
cd "$srcdir" cd "$srcdir"
./moerx --help >/dev/null ./murx --help >/dev/null
} }
package() { package() {

140
README.md
View file

@ -1,36 +1,36 @@
# moerx # murx
A deliberately small terminal multiplexer. One C file, no config file, no A deliberately small terminal multiplexer. One C file, no config file, no
dependencies. dependencies.
```sh ```sh
make -B CC=clang make -B CC=clang
./moerx # session "0" ./murx # session "0"
./moerx work # separate named session ./murx work # separate named session
./moerx -p x work # use Ctrl-X as this client's prefix ./murx -p x work # use Ctrl-X as this client's prefix
./moerx --prefix x work # same as -p x ./murx --prefix x work # same as -p x
./moerx -s bottom work # show the session status line at the bottom ./murx -s bottom work # show the session status line at the bottom
./moerx --status bottom work # same as -s bottom ./murx --status bottom work # same as -s bottom
./moerx --no-cwd work # show [moerx] instead of the directory ./murx --no-cwd work # show [murx] instead of the directory
./moerx --no-cwd --no-moerx work # do not show [moerx] instead of the directory ./murx --no-cwd --no-murx work # do not show [murx] instead of the directory
./moerx --no-clock work # hide the status bar clock ./murx --no-clock work # hide the status bar clock
./moerx --no-hostname work # hide the hostname: prefix in window titles ./murx --no-hostname work # hide the hostname: prefix in window titles
./moerx -l, --list-sessions # list running sessions without attaching ./murx -l, --list-sessions # list running sessions without attaching
./moerx --help # all shortcuts ./murx --help # all shortcuts
``` ```
Detach with `Ctrl-A d`. Run `moerx` again to reattach. Detach with `Ctrl-A d`. Run `murx` again to reattach.
Use `moerx -l` or `moerx --list-sessions` to list running sessions, sorted by Use `murx -l` or `murx --list-sessions` to list running sessions, sorted by
name, one per line. Listing works without a terminal and does not create or name, one per line. Listing works without a terminal and does not create or
attach to a session. It checks the current user's runtime socket directory attach to a session. It checks the current user's runtime socket directory
and `/tmp` fallback, skips stale sockets, and prints nothing when no sessions and `/tmp` fallback, skips stale sockets, and prints nothing when no sessions
are running. Do not pass a session name with this option. Use `moerx name` are running. Do not pass a session name with this option. Use `murx name`
to attach to a listed session. to attach to a listed session.
The [moerx(1) manual](moerx.1) covers all options, shortcuts, session behavior, The [murx(1) manual](murx.1) covers all options, shortcuts, session behavior,
and remote shell setup. Read it locally with `man ./moerx.1`. Run and remote shell setup. Read it locally with `man ./murx.1`. Run
`make install` to install both the program and manual, then use `man moerx`. `make install` to install both the program and manual, then use `man murx`.
The default prefix is `/usr/local`; override `PREFIX`, `BINDIR` or `MANDIR` The default prefix is `/usr/local`; override `PREFIX`, `BINDIR` or `MANDIR`
as needed. `DESTDIR` supports staged installs, and `make uninstall` removes as needed. `DESTDIR` supports staged installs, and `make uninstall` removes
the installed program and manual. the installed program and manual.
@ -42,7 +42,7 @@ Use `-p x` or `--prefix x` to choose Ctrl-X instead; `--prefix` is the long
form of `-p`. Letters `a` through `z` select Ctrl-A through Ctrl-Z, form of `-p`. Letters `a` through `z` select Ctrl-A through Ctrl-Z,
case-insensitively. The choice applies to this attached client; use the option case-insensitively. The choice applies to this attached client; use the option
again when reattaching, or set a shell again when reattaching, or set a shell
alias such as `alias moerx='moerx -p x'`. Clients attached to the same session alias such as `alias murx='murx -p x'`. Clients attached to the same session
can choose different prefixes. can choose different prefixes.
With `-p x`, detach with `Ctrl-X d`, send a literal Ctrl-X with `Ctrl-X a`, With `-p x`, detach with `Ctrl-X d`, send a literal Ctrl-X with `Ctrl-X a`,
@ -58,16 +58,26 @@ existing session for all attached clients; omitting the option preserves its
position. Prompts and messages follow the status line. Restart servers from position. Prompts and messages follow the status line. Restart servers from
older versions once before using this option. older versions once before using this option.
Use `--no-cwd` to show `[moerx]` on the left of the status bar instead of the Use `--no-cwd` to show `[murx]` on the left of the status bar instead of the
current directory, and `--no-clock` to hide the clock on the right. Use current directory, and `--no-clock` to hide the clock on the right. Use
`--no-moerx` to hide `[moerx]` when using `--no-clock` (and `--no-cwd`). Use `--no-murx` to hide `[murx]` when using `--no-clock` (and `--no-cwd`). Use
`--no-hostname` to hide the `hostname:` prefix in window names and the outer `--no-hostname` to hide the `hostname:` prefix in window names and the outer
terminal title. These options apply when starting a new session. terminal title. These options apply when starting a new session.
## Upgrading from moerx
The executable, source and manual are now `murx`, `murx.c` and `murx.1`.
Update aliases and scripts to use `murx` and replace `--no-moerx` with
`--no-murx`. Sessions use a separate `murx-<uid>` socket directory; finish
existing sessions with the old executable before removing it. Existing
sessions are not migrated automatically. Replace the optional remote SSH
hooks below and reload the remote shell: custom reports now use `murx-cwd`
and `murx-root`.
## What it does ## What it does
- One persistent server per session (a Unix socket in - One persistent server per session (a Unix socket in
`$XDG_RUNTIME_DIR/moerx-<uid>/` or `$TMPDIR/moerx-<uid>/`). `$XDG_RUNTIME_DIR/murx-<uid>/` or `$TMPDIR/murx-<uid>/`).
- Windows, panes, splits, resizing, renaming and a status line. - Windows, panes, splits, resizing, renaming and a status line.
- Real ptys per pane, a built-in VT100/xterm-ish screen emulator (colors, - Real ptys per pane, a built-in VT100/xterm-ish screen emulator (colors,
256-color and truecolor SGR, alternate screen, scrolling, UTF-8, wide 256-color and truecolor SGR, alternate screen, scrolling, UTF-8, wide
@ -94,21 +104,21 @@ terminal title. These options apply when starting a new session.
## SSH window names and directories (optional) ## SSH window names and directories (optional)
This section is **optional** and only needed if you want `moerx` to show This section is **optional** and only needed if you want `murx` to show
details from inside an SSH session (remote hostname/program in window titles details from inside an SSH session (remote hostname/program in window titles
and the window list, remote working directory in the status line, and reported and the window list, remote working directory in the status line, and reported
remote root status). If you do not use SSH from `moerx`, or you are fine with remote root status). If you do not use SSH from `murx`, or you are fine with
the pane being shown as the local `ssh` process (e.g. `local-hostname:ssh`), the pane being shown as the local `ssh` process (e.g. `local-hostname:ssh`),
you can skip this entire section—no remote configuration is required for you can skip this entire section—no remote configuration is required for
normal local use. normal local use.
While an SSH pane is active, `moerx` can show `[moerx] remote-hostname:program` While an SSH pane is active, `murx` can show `[murx] remote-hostname:program`
(for example `[moerx] server:vim`) in the outer terminal title and (for example `[murx] server:vim`) in the outer terminal title and
`server:vim` in the window list, update it as remote programs start/stop, and `server:vim` in the window list, update it as remote programs start/stop, and
show the remote shell name (for example `server:zsh`) at a remote prompt. show the remote shell name (for example `server:zsh`) at a remote prompt.
Because SSH does not expose the remote foreground program, directory, or root Because SSH does not expose the remote foreground program, directory, or root
status to the local terminal, the **remote shell** must emit OSC title/reports status to the local terminal, the **remote shell** must emit OSC title/reports
for `moerx` to display this. Without those reports, names remain for `murx` to display this. Without those reports, names remain
`local-hostname:ssh` and remote directory/root details are not tracked. `local-hostname:ssh` and remote directory/root details are not tracked.
Names refresh within one second; disconnecting restores the local hostname, Names refresh within one second; disconnecting restores the local hostname,
shell name, and path. shell name, and path.
@ -131,7 +141,7 @@ host you connect to over SSH:
```zsh ```zsh
if [[ -o interactive && ( -n $SSH_CONNECTION || $TERM == screen-256color ) ]]; then if [[ -o interactive && ( -n $SSH_CONNECTION || $TERM == screen-256color ) ]]; then
autoload -Uz add-zsh-hook autoload -Uz add-zsh-hook
moerx_ssh_title() { murx_ssh_title() {
local program=${1:t} local program=${1:t}
printf '\033]2;%s:%s\007' "${HOST%%.*}" "$program" printf '\033]2;%s:%s\007' "${HOST%%.*}" "$program"
local directory=$PWD local directory=$PWD
@ -140,28 +150,28 @@ if [[ -o interactive && ( -n $SSH_CONNECTION || $TERM == screen-256color ) ]]; t
elif [[ $directory == "$HOME/"* ]]; then elif [[ $directory == "$HOME/"* ]]; then
directory="~/${directory#"$HOME/"}" directory="~/${directory#"$HOME/"}"
fi fi
printf '\033]777;moerx-cwd;%s\007' "$directory" printf '\033]777;murx-cwd;%s\007' "$directory"
printf '\033]777;moerx-root;%s\007' "$((EUID == 0))" printf '\033]777;murx-root;%s\007' "$((EUID == 0))"
} }
moerx_ssh_preexec() { murx_ssh_preexec() {
local -a words local -a words
words=(${(z)1}) words=(${(z)1})
moerx_ssh_title "${(Q)words[1]}" murx_ssh_title "${(Q)words[1]}"
} }
moerx_ssh_precmd() { moerx_ssh_title zsh; } murx_ssh_precmd() { murx_ssh_title zsh; }
add-zsh-hook preexec moerx_ssh_preexec add-zsh-hook preexec murx_ssh_preexec
add-zsh-hook precmd moerx_ssh_precmd add-zsh-hook precmd murx_ssh_precmd
fi fi
``` ```
This reports the command launched by the shell (the first command for a This reports the command launched by the shell (the first command for a
pipeline), then `hostname:zsh` at the prompt. moerx retains the latest pipeline), then `hostname:zsh` at the prompt. murx retains the latest
`hostname:program` for that SSH job when programs send other terminal titles, `hostname:program` for that SSH job when programs send other terminal titles,
so these cannot reset the window name to `local-hostname:ssh`. so these cannot reset the window name to `local-hostname:ssh`.
The hook also reports the remote working directory before each command and at The hook also reports the remote working directory before each command and at
each prompt, so the status bar follows remote `cd` commands and shows `~` for each prompt, so the status bar follows remote `cd` commands and shows `~` for
the remote home directory. Disconnecting restores the local path. Restart the remote home directory. Disconnecting restores the local path. Restart
existing moerx servers and reload the remote shell configuration after upgrading. existing murx servers and reload the remote shell configuration after upgrading.
### Bash ### Bash
@ -170,8 +180,8 @@ host you connect to over SSH:
```bash ```bash
if [[ $- == *i* && ( -n $SSH_CONNECTION || $TERM == screen-256color ) && if [[ $- == *i* && ( -n $SSH_CONNECTION || $TERM == screen-256color ) &&
-z ${moerx_ssh_installed-} ]]; then -z ${murx_ssh_installed-} ]]; then
moerx_ssh_title() { murx_ssh_title() {
local program=$1 directory=$PWD local program=$1 directory=$PWD
program=${program##*/} program=${program##*/}
printf '\033]2;%s:%s\007' "${HOSTNAME%%.*}" "$program" printf '\033]2;%s:%s\007' "${HOSTNAME%%.*}" "$program"
@ -180,35 +190,35 @@ if [[ $- == *i* && ( -n $SSH_CONNECTION || $TERM == screen-256color ) &&
elif [[ $directory == "$HOME/"* ]]; then elif [[ $directory == "$HOME/"* ]]; then
directory="~/${directory#"$HOME/"}" directory="~/${directory#"$HOME/"}"
fi fi
printf '\033]777;moerx-cwd;%s\007' "$directory" printf '\033]777;murx-cwd;%s\007' "$directory"
printf '\033]777;moerx-root;%s\007' "$((EUID == 0))" printf '\033]777;murx-root;%s\007' "$((EUID == 0))"
} }
moerx_ssh_preexec() { murx_ssh_preexec() {
if [[ ${moerx_ssh_ready-0} == 1 && $1 != moerx_ssh_precmd ]]; then if [[ ${murx_ssh_ready-0} == 1 && $1 != murx_ssh_precmd ]]; then
moerx_ssh_ready=0 murx_ssh_ready=0
local program rest local program rest
read -r program rest <<< "$1" read -r program rest <<< "$1"
# Strip quotes around a simple command name without evaluating it. # Strip quotes around a simple command name without evaluating it.
program=${program#\"}; program=${program%\"} program=${program#\"}; program=${program%\"}
program=${program#\'}; program=${program%\'} program=${program#\'}; program=${program%\'}
moerx_ssh_title "$program" murx_ssh_title "$program"
fi fi
return 0 return 0
} }
moerx_ssh_precmd() { murx_ssh_precmd() {
local last_status=$? local last_status=$?
moerx_ssh_title bash murx_ssh_title bash
moerx_ssh_ready=1 murx_ssh_ready=1
return "$last_status" return "$last_status"
} }
# Keep existing prompt commands, and run our prompt hook last. # Keep existing prompt commands, and run our prompt hook last.
if [[ $(declare -p PROMPT_COMMAND 2>/dev/null) == 'declare -a '* ]]; then if [[ $(declare -p PROMPT_COMMAND 2>/dev/null) == 'declare -a '* ]]; then
PROMPT_COMMAND+=(moerx_ssh_precmd) PROMPT_COMMAND+=(murx_ssh_precmd)
else else
PROMPT_COMMAND=("${PROMPT_COMMAND-}" moerx_ssh_precmd) PROMPT_COMMAND=("${PROMPT_COMMAND-}" murx_ssh_precmd)
fi fi
trap 'moerx_ssh_preexec "$BASH_COMMAND"' DEBUG trap 'murx_ssh_preexec "$BASH_COMMAND"' DEBUG
moerx_ssh_installed=1 murx_ssh_installed=1
fi fi
``` ```
@ -227,13 +237,13 @@ paths containing spaces may display differently from the Zsh hook. The command
text is never evaluated by the hook. Do not enable function tracing (`set -T`) text is never evaluated by the hook. Do not enable function tracing (`set -T`)
for these hooks. for these hooks.
moerx accepts standard OSC 7 reports (`ESC ] 7 ; file://host/path BEL`) too, murx accepts standard OSC 7 reports (`ESC ] 7 ; file://host/path BEL`) too,
including percent-encoded paths. These display the reported absolute path; including percent-encoded paths. These display the reported absolute path;
`OSC 777;moerx-cwd;path` accepts either an absolute path or a path starting with `OSC 777;murx-cwd;path` accepts either an absolute path or a path starting with
`~` and preserves that abbreviation. Reports belong to the foreground job `~` and preserves that abbreviation. Reports belong to the foreground job
that sent them, so an old SSH connection cannot override the local shell's path. that sent them, so an old SSH connection cannot override the local shell's path.
The hooks also send `OSC 777;moerx-root;1` for effective UID 0 and The hooks also send `OSC 777;murx-root;1` for effective UID 0 and
`OSC 777;moerx-root;0` otherwise, allowing the active remote window name to turn `OSC 777;murx-root;0` otherwise, allowing the active remote window name to turn
red in a root shell. This is a visual hint based on shell reports, not a red in a root shell. This is a visual hint based on shell reports, not a
security indicator. security indicator.
@ -301,7 +311,7 @@ Hard-coded:
`colour12`), refreshed every second and when switching panes. On Linux this `colour12`), refreshed every second and when switching panes. On Linux this
follows the active pane's foreground process, falling back to its shell's follows the active pane's foreground process, falling back to its shell's
directory; on other systems it shows the session's starting directory. directory; on other systems it shows the session's starting directory.
Paths in `$HOME` use `~`, for example `[~/code/moerx]`; `$HOME` itself Paths in `$HOME` use `~`, for example `[~/code/murx]`; `$HOME` itself
appears as `[~]`. Long paths end in `...` to leave room for the window list and clock; the appears as `[~]`. Long paths end in `...` to leave room for the window list and clock; the
directory label is hidden when fewer than four columns remain. Remote SSH directory label is hidden when fewer than four columns remain. Remote SSH
directories require a shell report; see [SSH window names and directories](#ssh-window-names-and-directories). directories require a shell report; see [SSH window names and directories](#ssh-window-names-and-directories).
@ -323,8 +333,8 @@ Colours are written to the outer terminal in 256-colour form (`38;5;n` /
unless the outer terminal advertises `COLORTERM=truecolor` and is not unless the outer terminal advertises `COLORTERM=truecolor` and is not
screen/tmux/linux. screen/tmux/linux.
The terminal window title is set to `[moerx] hostname:program`, following the The terminal window title is set to `[murx] hostname:program`, following the
active moerx window (or `[moerx] program` with `--no-hostname`). Hostnames use active murx window (or `[murx] program` with `--no-hostname`). Hostnames use
their short form (before the first dot). their short form (before the first dot).
## Deliberate limitations ## Deliberate limitations
@ -340,7 +350,7 @@ This is "very basic" by design:
- Killing the server affects only the current session, since each named - Killing the server affects only the current session, since each named
session has its own small server process. session has its own small server process.
- Key repeat is not implemented: one resize step per key press. - Key repeat is not implemented: one resize step per key press.
- New windows start in the directory moerx was started from, not in the - New windows start in the directory murx was started from, not in the
current pane's directory. current pane's directory.
- Resizing does not reflow existing text. - Resizing does not reflow existing text.
- Session dimensions are clamped to 1,000 columns and 1,000 rows. Numeric - Session dimensions are clamped to 1,000 columns and 1,000 rows. Numeric
@ -369,7 +379,7 @@ On Alpine, install `alpine-sdk`, configure your abuild signing key with
abuild -r abuild -r
``` ```
Install the resulting `moerx` package and its `moerx-doc` subpackage for the Install the resulting `murx` package and its `murx-doc` subpackage for the
manual. abuild writes packages beneath its configured repository destination manual. abuild writes packages beneath its configured repository destination
(normally `~/packages`); use `apk add /path/to/package.apk` for each signed (normally `~/packages`); use `apk add /path/to/package.apk` for each signed
package after trusting your local signing key. package after trusting your local signing key.
@ -383,10 +393,10 @@ makepkg -si
This builds the package and installs it through pacman. The recipe lists This builds the package and installs it through pacman. The recipe lists
`x86_64` and `aarch64`; builds run on the current architecture. `x86_64` and `aarch64`; builds run on the current architecture.
After changing any packaged source file (`moerx.c`, `Makefile`, `moerx.1`, After changing any packaged source file (`murx.c`, `Makefile`, `murx.1`,
`README.md` or `LICENSE`), refresh recipe checksums with `abuild checksum` `README.md` or `LICENSE`), refresh recipe checksums with `abuild checksum`
on Alpine and `updpkgsums` (from `pacman-contrib`) on Arch. Neither recipe on Alpine and `updpkgsums` (from `pacman-contrib`) on Arch. Neither recipe
requires a test suite; its check step runs `moerx --help` as a smoke check. requires a test suite; its check step runs `murx --help` as a smoke check.
## Authors ## Authors
@ -397,5 +407,5 @@ requires a test suite; its check step runs `moerx --help` as a smoke check.
Copyright 2026 Armin Jenewein Copyright 2026 Armin Jenewein
The code of moerx is licensed under the terms aof the Apache-2.0 license. See The code of murx is licensed under the terms of the Apache-2.0 license. See
LICENSE for details. LICENSE for details.

View file

@ -1,24 +1,24 @@
.TH MOERX 1 "November 2026" "moerx" "User Commands" .TH MURX 1 "November 2026" "murx" "User Commands"
.SH NAME .SH NAME
moerx \- small persistent terminal multiplexer murx \- small persistent terminal multiplexer
.SH SYNOPSIS .SH SYNOPSIS
.B moerx .B murx
.RB [ \-p " letter"] .RB [ \-p " letter"]
.RB [ \-s " top|bottom"] .RB [ \-s " top|bottom"]
.RB [ \-\-no\-cwd ] .RB [ \-\-no\-cwd ]
.RB [ \-\-no\-clock ] .RB [ \-\-no\-clock ]
.RB [ \-\-no\-moerx ] .RB [ \-\-no\-murx ]
.RB [ \-\-no\-hostname ] .RB [ \-\-no\-hostname ]
.RB [ \-\- ] .RB [ \-\- ]
.RI [ session ] .RI [ session ]
.br .br
.B moerx .B murx
.BR \-h " | " \-\-help .BR \-h " | " \-\-help
.br .br
.B moerx .B murx
.BR \-l " | " \-\-list\-sessions .BR \-l " | " \-\-list\-sessions
.SH DESCRIPTION .SH DESCRIPTION
.B moerx .B murx
runs shells and terminal programs in windows and split panes. runs shells and terminal programs in windows and split panes.
It attaches to the named session, starting a server if necessary. It attaches to the named session, starting a server if necessary.
The default session name is The default session name is
@ -58,13 +58,13 @@ for all clients. Omitting this option preserves the session's position.
Prompts and messages follow the status line. Prompts and messages follow the status line.
.TP .TP
.B \-\-no\-cwd .B \-\-no\-cwd
Show [moerx] instead of the current directory at the left of the status line. Show [murx] instead of the current directory at the left of the status line.
.TP .TP
.B \-\-no\-clock .B \-\-no\-clock
Hide the status clock. Hide the status clock.
.TP .TP
.B \-\-no\-moerx .B \-\-no\-murx
Hide the [moerx] label when the directory is disabled with Hide the [murx] label when the directory is disabled with
.BR \-\-no\-cwd . .BR \-\-no\-cwd .
This does not hide an enabled directory or require the clock to be disabled. This does not hide an enabled directory or require the clock to be disabled.
.TP .TP
@ -221,7 +221,7 @@ Returning to the shell restores its name.
Linux uses /proc; other systems use ps. Linux uses /proc; other systems use ps.
The right side shows HH:MM:SS, refreshed every second. The right side shows HH:MM:SS, refreshed every second.
.PP .PP
The outer terminal title follows [moerx] hostname:program. The outer terminal title follows [murx] hostname:program.
Hostnames are shortened at the first dot. Hostnames are shortened at the first dot.
Panes have no title rows; only splits have separator lines. Panes have no title rows; only splits have separator lines.
The status uses colour12, accents colour14 and the current window colour11. The status uses colour12, accents colour14 and the current window colour11.
@ -251,7 +251,7 @@ Resizing does not reflow existing text.
SSH does not expose remote foreground programs or working directories locally. SSH does not expose remote foreground programs or working directories locally.
Configure the remote shell to send terminal reports using one of the examples Configure the remote shell to send terminal reports using one of the examples
below. Reload the shell configuration or open a new SSH shell afterward. below. Reload the shell configuration or open a new SSH shell afterward.
Restart session servers after upgrading moerx to gain newly added features. Restart session servers after upgrading murx to gain newly added features.
.PP .PP
OSC 0 or OSC 2 titles of the form hostname:program update the SSH window name. OSC 0 or OSC 2 titles of the form hostname:program update the SSH window name.
Use a hostname containing only letters, digits, dots, underscores or hyphens, Use a hostname containing only letters, digits, dots, underscores or hyphens,
@ -264,19 +264,19 @@ Directories may be reported using OSC 7:
.nf .nf
ESC ] 7 ; file://host/percent-encoded-path BEL ESC ] 7 ; file://host/percent-encoded-path BEL
.fi .fi
or using the moerx-specific form: or using the murx-specific form:
.nf .nf
ESC ] 777 ; moerx-cwd ; /absolute/path BEL ESC ] 777 ; murx-cwd ; /absolute/path BEL
ESC ] 777 ; moerx-cwd ; ~/relative/to/remote/home BEL ESC ] 777 ; murx-cwd ; ~/relative/to/remote/home BEL
.fi .fi
The spaces above separate fields for readability and are not transmitted. The spaces above separate fields for readability and are not transmitted.
ESC backslash also terminates an OSC report. ESC backslash also terminates an OSC report.
Standard OSC 7 paths are percent-decoded and displayed as absolute paths; Standard OSC 7 paths are percent-decoded and displayed as absolute paths;
the moerx-specific form preserves remote ~ abbreviations. the murx-specific form preserves remote ~ abbreviations.
Reports are associated with the foreground job that sent them. Reports are associated with the foreground job that sent them.
Disconnecting SSH restores the local shell's path and name. Disconnecting SSH restores the local shell's path and name.
With splits the window and status follow the active pane. With splits the window and status follow the active pane.
OSC 777;moerx-root;1 reports a root shell and OSC 777;moerx-root;0 clears it. OSC 777;murx-root;1 reports a root shell and OSC 777;murx-root;0 clears it.
The report is tied to the foreground SSH job and is ignored after disconnect. The report is tied to the foreground SSH job and is ignored after disconnect.
Remote su command titles also mark the active window red, even before a UID Remote su command titles also mark the active window red, even before a UID
report arrives. Remote shells without hooks cannot report their UID. report arrives. Remote shells without hooks cannot report their UID.
@ -293,7 +293,7 @@ precmd restores the shell name and reports the directory after cd.
.ft CR .ft CR
if [[ \-o interactive && ( \-n $SSH_CONNECTION || $TERM == screen\-256color ) ]]; then if [[ \-o interactive && ( \-n $SSH_CONNECTION || $TERM == screen\-256color ) ]]; then
autoload \-Uz add\-zsh\-hook autoload \-Uz add\-zsh\-hook
moerx_ssh_title() { murx_ssh_title() {
local program=${1:t} local program=${1:t}
printf '\e033]2;%s:%s\e007' "${HOST%%.*}" "$program" printf '\e033]2;%s:%s\e007' "${HOST%%.*}" "$program"
local directory=$PWD local directory=$PWD
@ -302,17 +302,17 @@ if [[ \-o interactive && ( \-n $SSH_CONNECTION || $TERM == screen\-256color ) ]]
elif [[ $directory == "$HOME/"* ]]; then elif [[ $directory == "$HOME/"* ]]; then
directory="~/${directory#"$HOME/"}" directory="~/${directory#"$HOME/"}"
fi fi
printf '\e033]777;moerx\-cwd;%s\e007' "$directory" printf '\e033]777;murx\-cwd;%s\e007' "$directory"
printf '\e033]777;moerx\-root;%s\e007' "$((EUID == 0))" printf '\e033]777;murx\-root;%s\e007' "$((EUID == 0))"
} }
moerx_ssh_preexec() { murx_ssh_preexec() {
local \-a words local \-a words
words=(${(z)1}) words=(${(z)1})
moerx_ssh_title "${(Q)words[1]}" murx_ssh_title "${(Q)words[1]}"
} }
moerx_ssh_precmd() { moerx_ssh_title zsh; } murx_ssh_precmd() { murx_ssh_title zsh; }
add\-zsh\-hook preexec moerx_ssh_preexec add\-zsh\-hook preexec murx_ssh_preexec
add\-zsh\-hook precmd moerx_ssh_precmd add\-zsh\-hook precmd murx_ssh_precmd
fi fi
.ft .ft
@ -327,8 +327,8 @@ Do not enable function tracing (set -T) for these hooks.
.nf .nf
.ft CR .ft CR
if [[ $\- == *i* && ( \-n $SSH_CONNECTION || $TERM == screen\-256color ) && if [[ $\- == *i* && ( \-n $SSH_CONNECTION || $TERM == screen\-256color ) &&
\-z ${moerx_ssh_installed\-} ]]; then \-z ${murx_ssh_installed\-} ]]; then
moerx_ssh_title() { murx_ssh_title() {
local program=$1 directory=$PWD local program=$1 directory=$PWD
program=${program##*/} program=${program##*/}
printf '\e033]2;%s:%s\e007' "${HOSTNAME%%.*}" "$program" printf '\e033]2;%s:%s\e007' "${HOSTNAME%%.*}" "$program"
@ -337,35 +337,35 @@ if [[ $\- == *i* && ( \-n $SSH_CONNECTION || $TERM == screen\-256color ) &&
elif [[ $directory == "$HOME/"* ]]; then elif [[ $directory == "$HOME/"* ]]; then
directory="~/${directory#"$HOME/"}" directory="~/${directory#"$HOME/"}"
fi fi
printf '\e033]777;moerx\-cwd;%s\e007' "$directory" printf '\e033]777;murx\-cwd;%s\e007' "$directory"
printf '\e033]777;moerx\-root;%s\e007' "$((EUID == 0))" printf '\e033]777;murx\-root;%s\e007' "$((EUID == 0))"
} }
moerx_ssh_preexec() { murx_ssh_preexec() {
if [[ ${moerx_ssh_ready\-0} == 1 && $1 != moerx_ssh_precmd ]]; then if [[ ${murx_ssh_ready\-0} == 1 && $1 != murx_ssh_precmd ]]; then
moerx_ssh_ready=0 murx_ssh_ready=0
local program rest local program rest
read \-r program rest <<< "$1" read \-r program rest <<< "$1"
# Strip quotes around a simple command name without evaluating it. # Strip quotes around a simple command name without evaluating it.
program=${program#\e"}; program=${program%\e"} program=${program#\e"}; program=${program%\e"}
program=${program#\e'}; program=${program%\e'} program=${program#\e'}; program=${program%\e'}
moerx_ssh_title "$program" murx_ssh_title "$program"
fi fi
return 0 return 0
} }
moerx_ssh_precmd() { murx_ssh_precmd() {
local last_status=$? local last_status=$?
moerx_ssh_title bash murx_ssh_title bash
moerx_ssh_ready=1 murx_ssh_ready=1
return "$last_status" return "$last_status"
} }
# Keep existing prompt commands, and run our prompt hook last. # Keep existing prompt commands, and run our prompt hook last.
if [[ $(declare \-p PROMPT_COMMAND 2>/dev/null) == 'declare \-a '* ]]; then if [[ $(declare \-p PROMPT_COMMAND 2>/dev/null) == 'declare \-a '* ]]; then
PROMPT_COMMAND+=(moerx_ssh_precmd) PROMPT_COMMAND+=(murx_ssh_precmd)
else else
PROMPT_COMMAND=("${PROMPT_COMMAND\-}" moerx_ssh_precmd) PROMPT_COMMAND=("${PROMPT_COMMAND\-}" murx_ssh_precmd)
fi fi
trap 'moerx_ssh_preexec "$BASH_COMMAND"' DEBUG trap 'murx_ssh_preexec "$BASH_COMMAND"' DEBUG
moerx_ssh_installed=1 murx_ssh_installed=1
fi fi
.ft .ft
@ -404,9 +404,9 @@ Used by the example shell hooks to enable reporting in remote SSH shells.
Along with the standard locale environment, controls character width handling. Along with the standard locale environment, controls character width handling.
.SH FILES .SH FILES
.TP .TP
.I $XDG_RUNTIME_DIR/moerx-<uid>/<session>.sock .I $XDG_RUNTIME_DIR/murx-<uid>/<session>.sock
Per-user session socket. If XDG_RUNTIME_DIR is unavailable, the parent comes Per-user session socket. If XDG_RUNTIME_DIR is unavailable, the parent comes
from TMPDIR or /tmp. Long socket paths fall back to /tmp/moerx-<uid>/. from TMPDIR or /tmp. Long socket paths fall back to /tmp/murx-<uid>/.
Socket permissions are restricted to the owner. Socket permissions are restricted to the owner.
.PP .PP
There is no configuration file and no on-disk scrollback. There is no configuration file and no on-disk scrollback.
@ -414,24 +414,31 @@ There is no configuration file and no on-disk scrollback.
Start or reattach to the default session: Start or reattach to the default session:
.PP .PP
.nf .nf
moerx murx
.fi .fi
.PP .PP
Use a named session, Ctrl-X prefix and bottom status: Use a named session, Ctrl-X prefix and bottom status:
.PP .PP
.nf .nf
moerx \-\-prefix x \-\-status bottom work murx \-\-prefix x \-\-status bottom work
.fi .fi
.PP .PP
Start a session with a minimal status display: Start a session with a minimal status display:
.PP .PP
.nf .nf
moerx \-\-no\-cwd \-\-no\-moerx \-\-no\-clock \-\-no\-hostname minimal murx \-\-no\-cwd \-\-no\-murx \-\-no\-clock \-\-no\-hostname minimal
.fi .fi
.PP .PP
Detach with Ctrl-A d (or Ctrl-X d with the alternate prefix), then run the Detach with Ctrl-A d (or Ctrl-X d with the alternate prefix), then run the
same session command to reattach. Exit the last pane's shell to end the session, same session command to reattach. Exit the last pane's shell to end the session,
or use the confirmed kill-pane, kill-window or kill-server bindings. or use the confirmed kill-pane, kill-window or kill-server bindings.
.SH UPGRADING FROM MOERX
The executable and manual are now murx and murx(1). Update scripts and aliases,
and replace the old status-label option with \fB\-\-no\-murx\fR.
Sessions use a separate murx-<uid> socket directory and are not migrated.
Finish existing sessions with the old executable before removing it.
Replace optional remote shell hooks and reload the remote shell;
custom OSC reports now use murx-cwd and murx-root.
.SH EXIT STATUS .SH EXIT STATUS
.TP .TP
.B 0 .B 0

View file

@ -1,6 +1,6 @@
/* /*
* This file is part of moerx - An ultra-minimalist, single-file, terminal * This file is part of murx - An ultra-minimalist, single-file, terminal
* multiplexer: https://codeberg.org/armin/moerx * multiplexer: https://codeberg.org/armin/murx
* *
* Copyright 2026 Armin Jenewein <a@bsd.pm> * Copyright 2026 Armin Jenewein <a@bsd.pm>
* Licensed under the terms of the Apache-2.0 license. * Licensed under the terms of the Apache-2.0 license.
@ -28,12 +28,12 @@
#endif #endif
/* /*
* moerx - a very small terminal multiplexer * murx - a very small terminal multiplexer
* *
* One binary, no config file. Shortcuts and colours are hard-coded. * One binary, no config file. Shortcuts and colours are hard-coded.
* *
* moerx [session] attach to session (default "0"), or start it * murx [session] attach to session (default "0"), or start it
* moerx -h|--help show usage and all Ctrl-A shortcut chains * murx -h|--help show usage and all Ctrl-A shortcut chains
* *
* Pure C99 + POSIX (macOS / Linux / FreeBSD). * Pure C99 + POSIX (macOS / Linux / FreeBSD).
*/ */
@ -120,7 +120,7 @@ static int send_msg(int fd, uint32_t type, const void *data, size_t len);
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static void range_error(void) { static void range_error(void) {
fputs("moerx: numeric limit exceeded\n", stderr); fputs("murx: numeric limit exceeded\n", stderr);
exit(1); exit(1);
} }
@ -161,7 +161,7 @@ static unsigned short tty_dimension(int value) {
static void *xmalloc(size_t n) { static void *xmalloc(size_t n) {
void *p = malloc(n); void *p = malloc(n);
if (!p) { if (!p) {
fputs("moerx: out of memory\n", stderr); fputs("murx: out of memory\n", stderr);
exit(1); exit(1);
} }
return p; return p;
@ -170,7 +170,7 @@ static void *xmalloc(size_t n) {
static void *xcalloc(size_t n, size_t sz) { static void *xcalloc(size_t n, size_t sz) {
void *p = calloc(1, size_mul(n, sz)); void *p = calloc(1, size_mul(n, sz));
if (!p) { if (!p) {
fputs("moerx: out of memory\n", stderr); fputs("murx: out of memory\n", stderr);
exit(1); exit(1);
} }
return p; return p;
@ -179,7 +179,7 @@ static void *xcalloc(size_t n, size_t sz) {
static void *xrealloc(void *p, size_t n) { static void *xrealloc(void *p, size_t n) {
void *q = realloc(p, n); void *q = realloc(p, n);
if (!q) { if (!q) {
fputs("moerx: out of memory\n", stderr); fputs("murx: out of memory\n", stderr);
exit(1); exit(1);
} }
return q; return q;
@ -205,7 +205,7 @@ static int parse_ulong_field(const char **text, unsigned long *out) {
static long long now_ms(void) { static long long now_ms(void) {
struct timespec ts = { 0, 0 }; struct timespec ts = { 0, 0 };
if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) {
perror("moerx: clock_gettime"); perror("murx: clock_gettime");
exit(1); exit(1);
} }
if (ts.tv_sec < 0 || (uintmax_t)ts.tv_sec > (uintmax_t)(LLONG_MAX - MSG_TIME) / 1000 - 1) if (ts.tv_sec < 0 || (uintmax_t)ts.tv_sec > (uintmax_t)(LLONG_MAX - MSG_TIME) / 1000 - 1)
@ -261,7 +261,7 @@ typedef struct {
#define A_ITALIC 0x04 #define A_ITALIC 0x04
#define A_ULINE 0x08 #define A_ULINE 0x08
#define A_REV 0x10 #define A_REV 0x10
/* Internal marker: cell belongs to a moerx border, not pane content. /* Internal marker: cell belongs to a murx border, not pane content.
Never emitted to the terminal. */ Never emitted to the terminal. */
static Cell blank_cell(void) { static Cell blank_cell(void) {
@ -934,16 +934,17 @@ static void em_csi(Pane *p, const char *raw, int len, unsigned char final) {
static int pane_remote_title(Pane *p, pid_t pid); static int pane_remote_title(Pane *p, pid_t pid);
/* OSC 7 uses a percent-encoded file URI. The moerx-specific form also /* OSC 7 uses a percent-encoded file URI. The murx-specific form also
accepts a shell-shortened path so remote $HOME can be displayed as ~. */ accepts a shell-shortened path so remote $HOME can be displayed as ~. */
static void em_osc_cwd(Pane *p) { static void em_osc_cwd(Pane *p) {
const char *path = NULL; const char *path = NULL;
int uri = 0; int uri = 0;
static const char cwd_prefix[] = "777;murx-cwd;";
if (strncmp(p->seq, "7;file://", 9) == 0) { if (strncmp(p->seq, "7;file://", 9) == 0) {
path = strchr(p->seq + 9, '/'); path = strchr(p->seq + 9, '/');
uri = 1; uri = 1;
} else if (strncmp(p->seq, "777;moerx-cwd;", 14) == 0) { } else if (strncmp(p->seq, cwd_prefix, sizeof cwd_prefix - 1) == 0) {
path = p->seq + 14; path = p->seq + sizeof cwd_prefix - 1;
} }
if (!path || (*path != '/' && if (!path || (*path != '/' &&
!(*path == '~' && (!path[1] || path[1] == '/')))) return; !(*path == '~' && (!path[1] || path[1] == '/')))) return;
@ -974,12 +975,12 @@ static void em_osc_cwd(Pane *p) {
static void em_osc_done(Pane *p) { static void em_osc_done(Pane *p) {
p->seq[p->seqlen] = '\0'; p->seq[p->seqlen] = '\0';
em_osc_cwd(p); em_osc_cwd(p);
if (strcmp(p->seq, "777;moerx-root;0") == 0 || if (strcmp(p->seq, "777;murx-root;0") == 0 ||
strcmp(p->seq, "777;moerx-root;1") == 0) { strcmp(p->seq, "777;murx-root;1") == 0) {
pid_t pid = tcgetpgrp(p->fd); pid_t pid = tcgetpgrp(p->fd);
if (pid <= 0) pid = tcgetpgrp(p->tty_fd); if (pid <= 0) pid = tcgetpgrp(p->tty_fd);
if (pid > 0) { if (pid > 0) {
p->reported_root = p->seq[15] == '1'; p->reported_root = p->seq[sizeof "777;murx-root;" - 1] == '1';
p->reported_root_pgrp = pid; p->reported_root_pgrp = pid;
} }
} }
@ -1225,6 +1226,14 @@ struct Client {
Client *next; Client *next;
}; };
/* Display choices are set when a session starts. */
typedef struct {
int show_cwd;
int show_clock;
int show_murx;
int show_hostname;
} DisplayOptions;
struct Session { struct Session {
char name[64]; char name[64];
char sock_path[PATH_MAX]; char sock_path[PATH_MAX];
@ -1233,10 +1242,7 @@ struct Session {
int w, h; int w, h;
int status_bottom; int status_bottom;
int show_cwd; DisplayOptions display;
int show_clock;
int show_moerx;
int show_hostname;
Window *windows; Window *windows;
Window *cur, *last; Window *cur, *last;
int nwin; int nwin;
@ -1367,13 +1373,13 @@ static int window_update_name(Session *s, Window *w) {
w->privileged = privileged; w->privileged = privileged;
char next[sizeof w->name]; char next[sizeof w->name];
if (strcmp(base, "ssh") == 0 && p->remote_title_pgrp == pid && p->remote_title[0]) { if (strcmp(base, "ssh") == 0 && p->remote_title_pgrp == pid && p->remote_title[0]) {
if (s->show_hostname) { if (s->display.show_hostname) {
snprintf(next, sizeof next, "%s", p->remote_title); snprintf(next, sizeof next, "%s", p->remote_title);
} else { } else {
const char *colon = strchr(p->remote_title, ':'); const char *colon = strchr(p->remote_title, ':');
snprintf(next, sizeof next, "%s", colon ? colon + 1 : p->remote_title); snprintf(next, sizeof next, "%s", colon ? colon + 1 : p->remote_title);
} }
} else if (s->show_hostname) { } else if (s->display.show_hostname) {
char host[256]; char host[256];
if (gethostname(host, sizeof host) < 0) snprintf(host, sizeof host, "localhost"); if (gethostname(host, sizeof host) < 0) snprintf(host, sizeof host, "localhost");
host[sizeof host - 1] = '\0'; host[sizeof host - 1] = '\0';
@ -1653,7 +1659,7 @@ static Window *window_new(Session *s, const char *name) {
base = base ? base + 1 : shell; base = base ? base + 1 : shell;
if (name) { if (name) {
snprintf(w->name, sizeof w->name, "%s", name); snprintf(w->name, sizeof w->name, "%s", name);
} else if (s->show_hostname) { } else if (s->display.show_hostname) {
char host[256]; char host[256];
if (gethostname(host, sizeof host) < 0) snprintf(host, sizeof host, "localhost"); if (gethostname(host, sizeof host) < 0) snprintf(host, sizeof host, "localhost");
host[sizeof host - 1] = '\0'; host[sizeof host - 1] = '\0';
@ -1705,11 +1711,15 @@ static void session_layout(Session *s) {
/* session helpers */ /* session helpers */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static void socket_dir_at(const char *base, char *out, size_t n) {
snprintf(out, n, "%s/murx-%u", base, (unsigned)getuid());
}
static void socket_dir(char *out, size_t n) { static void socket_dir(char *out, size_t n) {
const char *base = getenv("XDG_RUNTIME_DIR"); const char *base = getenv("XDG_RUNTIME_DIR");
if (!base || !*base) base = getenv("TMPDIR"); if (!base || !*base) base = getenv("TMPDIR");
if (!base || !*base) base = "/tmp"; if (!base || !*base) base = "/tmp";
snprintf(out, n, "%s/moerx-%u", base, (unsigned)getuid()); socket_dir_at(base, out, n);
} }
static int valid_session_name(const char *s) { static int valid_session_name(const char *s) {
@ -1726,7 +1736,7 @@ static void make_socket_path(const char *name, char *out, size_t n) {
/* Select the fallback before formatting, so a long runtime directory /* Select the fallback before formatting, so a long runtime directory
cannot truncate the socket path. Session names are limited to 48 bytes. */ cannot truncate the socket path. Session names are limited to 48 bytes. */
if (strlen(dir) + strlen(name) + 6 >= 100) { if (strlen(dir) + strlen(name) + 6 >= 100) {
snprintf(dir, sizeof dir, "/tmp/moerx-%u", (unsigned)getuid()); socket_dir_at("/tmp", dir, sizeof dir);
} }
snprintf(out, n, "%.99s/%.48s.sock", dir, name); snprintf(out, n, "%.99s/%.48s.sock", dir, name);
} }
@ -2002,7 +2012,7 @@ static void status_draw(Grid *g, Session *s, Client *c) {
clockbuf[0] = '\0'; clockbuf[0] = '\0';
int right_len = 0; int right_len = 0;
int rx = s->w; int rx = s->w;
if (s->show_clock) { if (s->display.show_clock) {
time_t t = time(NULL); time_t t = time(NULL);
struct tm tmv; struct tm tmv;
if (localtime_r(&t, &tmv) && if (localtime_r(&t, &tmv) &&
@ -2029,12 +2039,12 @@ static void status_draw(Grid *g, Session *s, Client *c) {
int left_len = 0; int left_len = 0;
{ {
char left[PATH_MAX]; char left[PATH_MAX];
if (s->show_cwd) { if (s->display.show_cwd) {
if (!status_cwd(s, left, sizeof left)) if (!status_cwd(s, left, sizeof left))
status_cwd_home(left, sizeof left); status_cwd_home(left, sizeof left);
left_len = status_cwd_draw(g, y, left, start); left_len = status_cwd_draw(g, y, left, start);
} else if (s->show_moerx) { } else if (s->display.show_murx) {
snprintf(left, sizeof left, "moerx"); snprintf(left, sizeof left, "murx");
left_len = status_cwd_draw(g, y, left, start); left_len = status_cwd_draw(g, y, left, start);
} else { } else {
left_len = 0; left_len = 0;
@ -2086,7 +2096,7 @@ static void status_draw(Grid *g, Session *s, Client *c) {
} }
} }
if (s->show_clock) { if (s->display.show_clock) {
/* keep the clock visible even if a message or window list is long */ /* keep the clock visible even if a message or window list is long */
status_right_draw(g, rx, y, clockbuf); status_right_draw(g, rx, y, clockbuf);
} }
@ -2350,7 +2360,7 @@ static void draw_frame(Session *s, Client *c, Grid *scr) {
} }
{ {
char title[160]; char title[160];
snprintf(title, sizeof title, "[moerx] %s", s->cur ? s->cur->name : "moerx"); snprintf(title, sizeof title, "[murx] %s", s->cur ? s->cur->name : "murx");
if (strcmp(title, c->title) != 0) { if (strcmp(title, c->title) != 0) {
buf_printf(&b, "\x1b]2;%s\x07", title); buf_printf(&b, "\x1b]2;%s\x07", title);
snprintf(c->title, sizeof c->title, "%s", title); snprintf(c->title, sizeof c->title, "%s", title);
@ -2835,7 +2845,7 @@ static void client_lock(Client *c) {
c->locked = 1; c->locked = 1;
c->mode = 0; c->mode = 0;
c->prefix_pending = 0; c->prefix_pending = 0;
const char *text = "[moerx] locked - press Enter to unlock"; const char *text = "[murx] locked - press Enter to unlock";
int tw = text_width(text); int tw = text_width(text);
int x = (c->cols - tw) / 2; int x = (c->cols - tw) / 2;
int y = c->rows / 2; int y = c->rows / 2;
@ -3675,7 +3685,7 @@ static void run_server(Session *s) {
} }
char msg[128]; char msg[128];
snprintf(msg, sizeof msg, "[moerx: session \"%s\" server exited]", s->name); snprintf(msg, sizeof msg, "[murx: session \"%s\" server exited]", s->name);
server_notify_all(s, msg); server_notify_all(s, msg);
free(panes); free(panes);
} }
@ -3715,7 +3725,7 @@ static void server_fail(int readyfd, const char *stage, int err) {
close(readyfd); close(readyfd);
} }
static void server_start(const char *path, const char *name, int readyfd, int show_cwd, int show_clock, int show_moerx, int show_hostname) { static void server_start(const char *path, const char *name, int readyfd, const DisplayOptions *display) {
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
signal(SIGHUP, SIG_IGN); signal(SIGHUP, SIG_IGN);
signal(SIGCHLD, SIG_DFL); signal(SIGCHLD, SIG_DFL);
@ -3769,10 +3779,7 @@ static void server_start(const char *path, const char *name, int readyfd, int sh
s->w = 80; s->w = 80;
s->h = 24; s->h = 24;
s->running = 1; s->running = 1;
s->show_cwd = show_cwd; s->display = *display;
s->show_clock = show_clock;
s->show_moerx = show_moerx;
s->show_hostname = show_hostname;
s->last_status = now_ms(); s->last_status = now_ms();
Window *w = window_new(s, NULL); Window *w = window_new(s, NULL);
@ -3852,7 +3859,7 @@ static int session_name_compare(const void *a, const void *b) {
static int list_sessions(void) { static int list_sessions(void) {
char dirs[2][PATH_MAX]; char dirs[2][PATH_MAX];
socket_dir(dirs[0], sizeof dirs[0]); socket_dir(dirs[0], sizeof dirs[0]);
snprintf(dirs[1], sizeof dirs[1], "/tmp/moerx-%u", (unsigned)getuid()); socket_dir_at("/tmp", dirs[1], sizeof dirs[1]);
char (*names)[49] = NULL; char (*names)[49] = NULL;
size_t count = 0; size_t count = 0;
int result = 0; int result = 0;
@ -3861,7 +3868,7 @@ static int list_sessions(void) {
DIR *dir = opendir(dirs[i]); DIR *dir = opendir(dirs[i]);
if (!dir) { if (!dir) {
if (errno != ENOENT) { if (errno != ENOENT) {
fprintf(stderr, "moerx: cannot list %s: %s\n", dirs[i], strerror(errno)); fprintf(stderr, "murx: cannot list %s: %s\n", dirs[i], strerror(errno));
result = 1; result = 1;
} }
continue; continue;
@ -3872,7 +3879,7 @@ static int list_sessions(void) {
entry = readdir(dir); entry = readdir(dir);
if (!entry) { if (!entry) {
if (errno) { if (errno) {
fprintf(stderr, "moerx: cannot read %s: %s\n", dirs[i], strerror(errno)); fprintf(stderr, "murx: cannot read %s: %s\n", dirs[i], strerror(errno));
result = 1; result = 1;
} }
break; break;
@ -3926,14 +3933,14 @@ static int ensure_socket_dir(void) {
if (mkdir(dir, 0700) < 0 && errno != EEXIST) return -1; if (mkdir(dir, 0700) < 0 && errno != EEXIST) return -1;
chmod(dir, 0700); chmod(dir, 0700);
char alt[PATH_MAX]; char alt[PATH_MAX];
snprintf(alt, sizeof alt, "/tmp/moerx-%u", (unsigned)getuid()); socket_dir_at("/tmp", alt, sizeof alt);
if (strcmp(alt, dir) != 0) { if (strcmp(alt, dir) != 0) {
if (mkdir(alt, 0700) == 0) chmod(alt, 0700); if (mkdir(alt, 0700) == 0) chmod(alt, 0700);
} }
return 0; return 0;
} }
static int spawn_server(const char *path, const char *name, int show_cwd, int show_clock, int show_moerx, int show_hostname) { static int spawn_server(const char *path, const char *name, const DisplayOptions *display) {
if (ensure_socket_dir() < 0) return -1; if (ensure_socket_dir() < 0) return -1;
char dir[PATH_MAX], lockpath[PATH_MAX + 64]; char dir[PATH_MAX], lockpath[PATH_MAX + 64];
socket_dir(dir, sizeof dir); socket_dir(dir, sizeof dir);
@ -3981,7 +3988,7 @@ static int spawn_server(const char *path, const char *name, int show_cwd, int sh
if (dn > 2) close(dn); if (dn > 2) close(dn);
} }
close(lock); close(lock);
server_start(path, name, p[1], show_cwd, show_clock, show_moerx, show_hostname); server_start(path, name, p[1], display);
_exit(1); _exit(1);
} }
close(p[1]); close(p[1]);
@ -4075,7 +4082,7 @@ static int terminal_truecolor(void) {
static int run_client(int fd, const char *name, unsigned char prefix, int status) { static int run_client(int fd, const char *name, unsigned char prefix, int status) {
struct termios saved; struct termios saved;
if (tty_raw(&saved) < 0) { if (tty_raw(&saved) < 0) {
fprintf(stderr, "moerx: not a terminal\n"); fprintf(stderr, "murx: not a terminal\n");
return 1; return 1;
} }
@ -4119,10 +4126,10 @@ static int run_client(int fd, const char *name, unsigned char prefix, int status
g_winch_pipe[0] = g_winch_pipe[1] = -1; g_winch_pipe[0] = g_winch_pipe[1] = -1;
tty_restore(&saved); tty_restore(&saved);
if (err == EPIPE || err == ECONNRESET) { if (err == EPIPE || err == ECONNRESET) {
fprintf(stderr, "moerx: cannot attach to session '%s': server closed " fprintf(stderr, "murx: cannot attach to session '%s': server closed "
"the connection (%s)\n", name, strerror(err)); "the connection (%s)\n", name, strerror(err));
} else { } else {
fprintf(stderr, "moerx: cannot attach to session '%s': %s\n", fprintf(stderr, "murx: cannot attach to session '%s': %s\n",
name, strerror(err)); name, strerror(err));
} }
return 1; return 1;
@ -4238,9 +4245,9 @@ static int run_client(int fd, const char *name, unsigned char prefix, int status
static void print_help(FILE *out) { static void print_help(FILE *out) {
fprintf(out, fprintf(out,
"usage: moerx [-p letter] [-s top|bottom] [--no-cwd] [--no-clock] [--no-moerx] [--no-hostname] [session]\n" "usage: murx [-p letter] [-s top|bottom] [--no-cwd] [--no-clock] [--no-murx] [--no-hostname] [session]\n"
" moerx -l | --list-sessions\n" " murx -l | --list-sessions\n"
" moerx -h | --help\n" " murx -h | --help\n"
"\n" "\n"
"Attach to a running session, or start it if it is not running.\n" "Attach to a running session, or start it if it is not running.\n"
"The session name defaults to \"0\".\n" "The session name defaults to \"0\".\n"
@ -4252,7 +4259,7 @@ static void print_help(FILE *out) {
"Without -s, keep the session position.\n" "Without -s, keep the session position.\n"
"Use --no-cwd to hide the current directory in the status bar.\n" "Use --no-cwd to hide the current directory in the status bar.\n"
"Use --no-clock to hide the clock in the status bar.\n" "Use --no-clock to hide the clock in the status bar.\n"
"Use --no-moerx to hide [moerx] in the status bar when using --no-clock.\n" "Use --no-murx to hide [murx] in the status bar when using --no-clock.\n"
"Use --no-hostname to hide the hostname: prefix in window titles.\n" "Use --no-hostname to hide the hostname: prefix in window titles.\n"
"\n" "\n"
"Use -p x (or --prefix x) to choose Ctrl-X as this client's prefix.\n" "Use -p x (or --prefix x) to choose Ctrl-X as this client's prefix.\n"
@ -4328,10 +4335,7 @@ int main(int argc, char **argv) {
int argi = 1; int argi = 1;
unsigned char prefix = DEFAULT_PREFIX; unsigned char prefix = DEFAULT_PREFIX;
int status = 0; int status = 0;
int show_cwd = 1; DisplayOptions display = {1, 1, 1, 1};
int show_clock = 1;
int show_moerx = 1;
int show_hostname = 1;
int list = 0; int list = 0;
while (argi < argc && argv[argi][0] == '-' && argv[argi][1]) { while (argi < argc && argv[argi][0] == '-' && argv[argi][1]) {
const char *option = argv[argi++]; const char *option = argv[argi++];
@ -4343,49 +4347,49 @@ int main(int argc, char **argv) {
if (strcmp(option, "-l") == 0 || strcmp(option, "--list-sessions") == 0) { if (strcmp(option, "-l") == 0 || strcmp(option, "--list-sessions") == 0) {
list = 1; list = 1;
} else if (strcmp(option, "--no-cwd") == 0) { } else if (strcmp(option, "--no-cwd") == 0) {
show_cwd = 0; display.show_cwd = 0;
} else if (strcmp(option, "--no-clock") == 0) { } else if (strcmp(option, "--no-clock") == 0) {
show_clock = 0; display.show_clock = 0;
} else if (strcmp(option, "--no-moerx") == 0) { } else if (strcmp(option, "--no-murx") == 0) {
show_moerx = 0; display.show_murx = 0;
} else if (strcmp(option, "--no-hostname") == 0) { } else if (strcmp(option, "--no-hostname") == 0) {
show_hostname = 0; display.show_hostname = 0;
} else if (strcmp(option, "-p") == 0 || strcmp(option, "--prefix") == 0) { } else if (strcmp(option, "-p") == 0 || strcmp(option, "--prefix") == 0) {
if (argi >= argc || !parse_prefix(argv[argi], &prefix)) { if (argi >= argc || !parse_prefix(argv[argi], &prefix)) {
fprintf(stderr, "moerx: %s requires a letter from a through z\n", option); fprintf(stderr, "murx: %s requires a letter from a through z\n", option);
return 2; return 2;
} }
argi++; argi++;
} else if (strcmp(option, "-s") == 0 || strcmp(option, "--status") == 0) { } else if (strcmp(option, "-s") == 0 || strcmp(option, "--status") == 0) {
if (argi >= argc || (strcmp(argv[argi], "top") != 0 && if (argi >= argc || (strcmp(argv[argi], "top") != 0 &&
strcmp(argv[argi], "bottom") != 0)) { strcmp(argv[argi], "bottom") != 0)) {
fprintf(stderr, "moerx: %s requires top or bottom\n", option); fprintf(stderr, "murx: %s requires top or bottom\n", option);
return 2; return 2;
} }
status = strcmp(argv[argi++], "bottom") == 0 ? 2 : 1; status = strcmp(argv[argi++], "bottom") == 0 ? 2 : 1;
} else { } else {
fprintf(stderr, "moerx: unknown option '%s'\n", option); fprintf(stderr, "murx: unknown option '%s'\n", option);
fprintf(stderr, "Try 'moerx --help' for more information.\n"); fprintf(stderr, "Try 'murx --help' for more information.\n");
return 2; return 2;
} }
} }
if (list) { if (list) {
if (argi != argc) { if (argi != argc) {
fprintf(stderr, "moerx: --list-sessions does not take a session name\n"); fprintf(stderr, "murx: --list-sessions does not take a session name\n");
return 2; return 2;
} }
return list_sessions(); return list_sessions();
} }
if (argc - argi > 1) { if (argc - argi > 1) {
fprintf(stderr, "moerx: too many arguments\n"); fprintf(stderr, "murx: too many arguments\n");
fprintf(stderr, "Try 'moerx --help' for more information.\n"); fprintf(stderr, "Try 'murx --help' for more information.\n");
return 2; return 2;
} }
const char *name = argc - argi > 0 ? argv[argi] : "0"; const char *name = argc - argi > 0 ? argv[argi] : "0";
if (!valid_session_name(name)) { if (!valid_session_name(name)) {
fprintf(stderr, "moerx: bad session name '%s'\n", name); fprintf(stderr, "murx: bad session name '%s'\n", name);
fprintf(stderr, "Try 'moerx --help' for more information.\n"); fprintf(stderr, "Try 'murx --help' for more information.\n");
return 2; return 2;
} }
@ -4393,9 +4397,9 @@ int main(int argc, char **argv) {
make_socket_path(name, path, sizeof path); make_socket_path(name, path, sizeof path);
int fd = connect_session(path); int fd = connect_session(path);
if (fd < 0) fd = spawn_server(path, name, show_cwd, show_clock, show_moerx, show_hostname); if (fd < 0) fd = spawn_server(path, name, &display);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "moerx: cannot start or attach session '%s': %s\n", fprintf(stderr, "murx: cannot start or attach session '%s': %s\n",
name, strerror(errno)); name, strerror(errno));
return 1; return 1;
} }