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
moerx
murx
*.o
# Packages

View file

@ -1,12 +1,12 @@
# moerx project instructions
# murx project instructions
moerx is a deliberately small terminal multiplexer: one C99 source file
(`moerx.c`), no dependencies, no config file.
murx is a deliberately small terminal multiplexer: one C99 source file
(`murx.c`), no dependencies, no config file.
## Build
```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
```
@ -16,7 +16,7 @@ outside the repo for geometry/logic checks; do not leave test files behind.
## 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.
- `README.md` is user-facing documentation. Update it when shortcuts, behavior,
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)
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:
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.
pkgname=moerx
pkgname=murx
pkgver=0.20261116
pkgrel=0
pkgdesc="Small persistent terminal multiplexer"
url="https://codeberg.org/armin/moerx"
url="https://codeberg.org/armin/murx"
arch="all"
license="Apache-2.0"
subpackages="$pkgname-doc"
source="moerx.c Makefile moerx.1 README.md LICENSE"
source="murx.c Makefile murx.1 README.md LICENSE"
builddir="$srcdir"
build() {
@ -15,7 +15,7 @@ build() {
}
check() {
./moerx --help >/dev/null
./murx --help >/dev/null
}
package() {
@ -25,9 +25,9 @@ package() {
}
sha512sums="
0a0cedb8702b5ac041896065c6d36d22f57deffdc3f8023c9b02b7b87218dfcd32a8e2eaecfc470930d1d1228109cf6894ba8e5242ebcf760ef2dd17ab35d2ab moerx.c
e6336e712a9a6071b16cbde83cd6f591c480da68cf5185f0db27f321b26adb075844a958e792da419dcb82a930de6cff28bc64a98e9b0facd9350e382aa95ce1 Makefile
cc677bc8c9637963dd19a031c0920f7178e71a93d236d1445ef4a5cbabefd3b3a68d9696444d2a6d0a9993ed05df55e8de876e7e515bd31effaeb7425c90a52a moerx.1
d1bc928e391b50a0031834396b8f655474d8073399f94e7c5dbf7469977a1ff7665db1c21ced7180bf7a891584dae61f52e1ef345ef75ab3348705aeb0d091e0 README.md
efd4dd0bcfd3ef36b1e4b8285452690f684a29e7906c0ada7aa09f879143b998a6e9cb8ddc76eb861867f882c7cb7f5a1fb350ce102e67a632d8ea238eba9b65 murx.c
4f52ecfc78bb993f9bdbaa235f671fe54327497fa8e21517805a2696bea9f06d335e4da564d0019ec1fad86986c05bce90e4825dcebc2ef3c0bc66fb9a768030 Makefile
523ac85c9b789a7721c76e8f7691a1a8ab43d7fec2624f43b3850e5135451d94404d8711fa40422a67e9f13b7388470436ab06deb6ad7c87c7e72a37492ae617 murx.1
b6595d86edb76ec4ef90a1b44dfc350543f501b1c5bd41dbd2fe5b479c57d871f83eff9021b0407bb8b791e410128c70c9c0772a9328cded90e67f70cc20b9d4 README.md
2fe33ba22c5f68e124904be594208f050be20f33d115f9a56f60cac93304102da32e6a7e78154e831d3704da7ca8bfefd7025e7b8901e65babcd83e7342f6382 LICENSE
"

View file

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

View file

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

140
README.md
View file

@ -1,36 +1,36 @@
# moerx
# murx
A deliberately small terminal multiplexer. One C file, no config file, no
dependencies.
```sh
make -B CC=clang
./moerx # session "0"
./moerx work # separate named session
./moerx -p x work # use Ctrl-X as this client's prefix
./moerx --prefix x work # same as -p x
./moerx -s bottom work # show the session status line at the bottom
./moerx --status bottom work # same as -s bottom
./moerx --no-cwd work # show [moerx] instead of the directory
./moerx --no-cwd --no-moerx work # do not show [moerx] instead of the directory
./moerx --no-clock work # hide the status bar clock
./moerx --no-hostname work # hide the hostname: prefix in window titles
./moerx -l, --list-sessions # list running sessions without attaching
./moerx --help # all shortcuts
./murx # session "0"
./murx work # separate named session
./murx -p x work # use Ctrl-X as this client's prefix
./murx --prefix x work # same as -p x
./murx -s bottom work # show the session status line at the bottom
./murx --status bottom work # same as -s bottom
./murx --no-cwd work # show [murx] instead of the directory
./murx --no-cwd --no-murx work # do not show [murx] instead of the directory
./murx --no-clock work # hide the status bar clock
./murx --no-hostname work # hide the hostname: prefix in window titles
./murx -l, --list-sessions # list running sessions without attaching
./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
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
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.
The [moerx(1) manual](moerx.1) covers all options, shortcuts, session behavior,
and remote shell setup. Read it locally with `man ./moerx.1`. Run
`make install` to install both the program and manual, then use `man moerx`.
The [murx(1) manual](murx.1) covers all options, shortcuts, session behavior,
and remote shell setup. Read it locally with `man ./murx.1`. Run
`make install` to install both the program and manual, then use `man murx`.
The default prefix is `/usr/local`; override `PREFIX`, `BINDIR` or `MANDIR`
as needed. `DESTDIR` supports staged installs, and `make uninstall` removes
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,
case-insensitively. The choice applies to this attached client; use the option
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.
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
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
`--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
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
- 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.
- Real ptys per pane, a built-in VT100/xterm-ish screen emulator (colors,
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)
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
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`),
you can skip this entire section—no remote configuration is required for
normal local use.
While an SSH pane is active, `moerx` can show `[moerx] remote-hostname:program`
(for example `[moerx] server:vim`) in the outer terminal title and
While an SSH pane is active, `murx` can show `[murx] remote-hostname:program`
(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
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
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.
Names refresh within one second; disconnecting restores the local hostname,
shell name, and path.
@ -131,7 +141,7 @@ host you connect to over SSH:
```zsh
if [[ -o interactive && ( -n $SSH_CONNECTION || $TERM == screen-256color ) ]]; then
autoload -Uz add-zsh-hook
moerx_ssh_title() {
murx_ssh_title() {
local program=${1:t}
printf '\033]2;%s:%s\007' "${HOST%%.*}" "$program"
local directory=$PWD
@ -140,28 +150,28 @@ if [[ -o interactive && ( -n $SSH_CONNECTION || $TERM == screen-256color ) ]]; t
elif [[ $directory == "$HOME/"* ]]; then
directory="~/${directory#"$HOME/"}"
fi
printf '\033]777;moerx-cwd;%s\007' "$directory"
printf '\033]777;moerx-root;%s\007' "$((EUID == 0))"
printf '\033]777;murx-cwd;%s\007' "$directory"
printf '\033]777;murx-root;%s\007' "$((EUID == 0))"
}
moerx_ssh_preexec() {
murx_ssh_preexec() {
local -a words
words=(${(z)1})
moerx_ssh_title "${(Q)words[1]}"
murx_ssh_title "${(Q)words[1]}"
}
moerx_ssh_precmd() { moerx_ssh_title zsh; }
add-zsh-hook preexec moerx_ssh_preexec
add-zsh-hook precmd moerx_ssh_precmd
murx_ssh_precmd() { murx_ssh_title zsh; }
add-zsh-hook preexec murx_ssh_preexec
add-zsh-hook precmd murx_ssh_precmd
fi
```
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,
so these cannot reset the window name to `local-hostname:ssh`.
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
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
@ -170,8 +180,8 @@ host you connect to over SSH:
```bash
if [[ $- == *i* && ( -n $SSH_CONNECTION || $TERM == screen-256color ) &&
-z ${moerx_ssh_installed-} ]]; then
moerx_ssh_title() {
-z ${murx_ssh_installed-} ]]; then
murx_ssh_title() {
local program=$1 directory=$PWD
program=${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
directory="~/${directory#"$HOME/"}"
fi
printf '\033]777;moerx-cwd;%s\007' "$directory"
printf '\033]777;moerx-root;%s\007' "$((EUID == 0))"
printf '\033]777;murx-cwd;%s\007' "$directory"
printf '\033]777;murx-root;%s\007' "$((EUID == 0))"
}
moerx_ssh_preexec() {
if [[ ${moerx_ssh_ready-0} == 1 && $1 != moerx_ssh_precmd ]]; then
moerx_ssh_ready=0
murx_ssh_preexec() {
if [[ ${murx_ssh_ready-0} == 1 && $1 != murx_ssh_precmd ]]; then
murx_ssh_ready=0
local program rest
read -r program rest <<< "$1"
# Strip quotes around a simple command name without evaluating it.
program=${program#\"}; program=${program%\"}
program=${program#\'}; program=${program%\'}
moerx_ssh_title "$program"
murx_ssh_title "$program"
fi
return 0
}
moerx_ssh_precmd() {
murx_ssh_precmd() {
local last_status=$?
moerx_ssh_title bash
moerx_ssh_ready=1
murx_ssh_title bash
murx_ssh_ready=1
return "$last_status"
}
# Keep existing prompt commands, and run our prompt hook last.
if [[ $(declare -p PROMPT_COMMAND 2>/dev/null) == 'declare -a '* ]]; then
PROMPT_COMMAND+=(moerx_ssh_precmd)
PROMPT_COMMAND+=(murx_ssh_precmd)
else
PROMPT_COMMAND=("${PROMPT_COMMAND-}" moerx_ssh_precmd)
PROMPT_COMMAND=("${PROMPT_COMMAND-}" murx_ssh_precmd)
fi
trap 'moerx_ssh_preexec "$BASH_COMMAND"' DEBUG
moerx_ssh_installed=1
trap 'murx_ssh_preexec "$BASH_COMMAND"' DEBUG
murx_ssh_installed=1
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`)
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;
`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
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
`OSC 777;moerx-root;0` otherwise, allowing the active remote window name to turn
The hooks also send `OSC 777;murx-root;1` for effective UID 0 and
`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
security indicator.
@ -301,7 +311,7 @@ Hard-coded:
`colour12`), refreshed every second and when switching panes. On Linux this
follows the active pane's foreground process, falling back to its shell's
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
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).
@ -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
screen/tmux/linux.
The terminal window title is set to `[moerx] hostname:program`, following the
active moerx window (or `[moerx] program` with `--no-hostname`). Hostnames use
The terminal window title is set to `[murx] hostname:program`, following the
active murx window (or `[murx] program` with `--no-hostname`). Hostnames use
their short form (before the first dot).
## Deliberate limitations
@ -340,7 +350,7 @@ This is "very basic" by design:
- Killing the server affects only the current session, since each named
session has its own small server process.
- 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.
- Resizing does not reflow existing text.
- 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
```
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
(normally `~/packages`); use `apk add /path/to/package.apk` for each signed
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
`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`
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
@ -397,5 +407,5 @@ requires a test suite; its check step runs `moerx --help` as a smoke check.
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.

View file

@ -1,24 +1,24 @@
.TH MOERX 1 "November 2026" "moerx" "User Commands"
.TH MURX 1 "November 2026" "murx" "User Commands"
.SH NAME
moerx \- small persistent terminal multiplexer
murx \- small persistent terminal multiplexer
.SH SYNOPSIS
.B moerx
.B murx
.RB [ \-p " letter"]
.RB [ \-s " top|bottom"]
.RB [ \-\-no\-cwd ]
.RB [ \-\-no\-clock ]
.RB [ \-\-no\-moerx ]
.RB [ \-\-no\-murx ]
.RB [ \-\-no\-hostname ]
.RB [ \-\- ]
.RI [ session ]
.br
.B moerx
.B murx
.BR \-h " | " \-\-help
.br
.B moerx
.B murx
.BR \-l " | " \-\-list\-sessions
.SH DESCRIPTION
.B moerx
.B murx
runs shells and terminal programs in windows and split panes.
It attaches to the named session, starting a server if necessary.
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.
.TP
.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
.B \-\-no\-clock
Hide the status clock.
.TP
.B \-\-no\-moerx
Hide the [moerx] label when the directory is disabled with
.B \-\-no\-murx
Hide the [murx] label when the directory is disabled with
.BR \-\-no\-cwd .
This does not hide an enabled directory or require the clock to be disabled.
.TP
@ -221,7 +221,7 @@ Returning to the shell restores its name.
Linux uses /proc; other systems use ps.
The right side shows HH:MM:SS, refreshed every second.
.PP
The outer terminal title follows [moerx] hostname:program.
The outer terminal title follows [murx] hostname:program.
Hostnames are shortened at the first dot.
Panes have no title rows; only splits have separator lines.
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.
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.
Restart session servers after upgrading moerx to gain newly added features.
Restart session servers after upgrading murx to gain newly added features.
.PP
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,
@ -264,19 +264,19 @@ Directories may be reported using OSC 7:
.nf
ESC ] 7 ; file://host/percent-encoded-path BEL
.fi
or using the moerx-specific form:
or using the murx-specific form:
.nf
ESC ] 777 ; moerx-cwd ; /absolute/path BEL
ESC ] 777 ; moerx-cwd ; ~/relative/to/remote/home BEL
ESC ] 777 ; murx-cwd ; /absolute/path BEL
ESC ] 777 ; murx-cwd ; ~/relative/to/remote/home BEL
.fi
The spaces above separate fields for readability and are not transmitted.
ESC backslash also terminates an OSC report.
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.
Disconnecting SSH restores the local shell's path and name.
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.
Remote su command titles also mark the active window red, even before a 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
if [[ \-o interactive && ( \-n $SSH_CONNECTION || $TERM == screen\-256color ) ]]; then
autoload \-Uz add\-zsh\-hook
moerx_ssh_title() {
murx_ssh_title() {
local program=${1:t}
printf '\e033]2;%s:%s\e007' "${HOST%%.*}" "$program"
local directory=$PWD
@ -302,17 +302,17 @@ if [[ \-o interactive && ( \-n $SSH_CONNECTION || $TERM == screen\-256color ) ]]
elif [[ $directory == "$HOME/"* ]]; then
directory="~/${directory#"$HOME/"}"
fi
printf '\e033]777;moerx\-cwd;%s\e007' "$directory"
printf '\e033]777;moerx\-root;%s\e007' "$((EUID == 0))"
printf '\e033]777;murx\-cwd;%s\e007' "$directory"
printf '\e033]777;murx\-root;%s\e007' "$((EUID == 0))"
}
moerx_ssh_preexec() {
murx_ssh_preexec() {
local \-a words
words=(${(z)1})
moerx_ssh_title "${(Q)words[1]}"
murx_ssh_title "${(Q)words[1]}"
}
moerx_ssh_precmd() { moerx_ssh_title zsh; }
add\-zsh\-hook preexec moerx_ssh_preexec
add\-zsh\-hook precmd moerx_ssh_precmd
murx_ssh_precmd() { murx_ssh_title zsh; }
add\-zsh\-hook preexec murx_ssh_preexec
add\-zsh\-hook precmd murx_ssh_precmd
fi
.ft
@ -327,8 +327,8 @@ Do not enable function tracing (set -T) for these hooks.
.nf
.ft CR
if [[ $\- == *i* && ( \-n $SSH_CONNECTION || $TERM == screen\-256color ) &&
\-z ${moerx_ssh_installed\-} ]]; then
moerx_ssh_title() {
\-z ${murx_ssh_installed\-} ]]; then
murx_ssh_title() {
local program=$1 directory=$PWD
program=${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
directory="~/${directory#"$HOME/"}"
fi
printf '\e033]777;moerx\-cwd;%s\e007' "$directory"
printf '\e033]777;moerx\-root;%s\e007' "$((EUID == 0))"
printf '\e033]777;murx\-cwd;%s\e007' "$directory"
printf '\e033]777;murx\-root;%s\e007' "$((EUID == 0))"
}
moerx_ssh_preexec() {
if [[ ${moerx_ssh_ready\-0} == 1 && $1 != moerx_ssh_precmd ]]; then
moerx_ssh_ready=0
murx_ssh_preexec() {
if [[ ${murx_ssh_ready\-0} == 1 && $1 != murx_ssh_precmd ]]; then
murx_ssh_ready=0
local program rest
read \-r program rest <<< "$1"
# Strip quotes around a simple command name without evaluating it.
program=${program#\e"}; program=${program%\e"}
program=${program#\e'}; program=${program%\e'}
moerx_ssh_title "$program"
murx_ssh_title "$program"
fi
return 0
}
moerx_ssh_precmd() {
murx_ssh_precmd() {
local last_status=$?
moerx_ssh_title bash
moerx_ssh_ready=1
murx_ssh_title bash
murx_ssh_ready=1
return "$last_status"
}
# Keep existing prompt commands, and run our prompt hook last.
if [[ $(declare \-p PROMPT_COMMAND 2>/dev/null) == 'declare \-a '* ]]; then
PROMPT_COMMAND+=(moerx_ssh_precmd)
PROMPT_COMMAND+=(murx_ssh_precmd)
else
PROMPT_COMMAND=("${PROMPT_COMMAND\-}" moerx_ssh_precmd)
PROMPT_COMMAND=("${PROMPT_COMMAND\-}" murx_ssh_precmd)
fi
trap 'moerx_ssh_preexec "$BASH_COMMAND"' DEBUG
moerx_ssh_installed=1
trap 'murx_ssh_preexec "$BASH_COMMAND"' DEBUG
murx_ssh_installed=1
fi
.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.
.SH FILES
.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
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.
.PP
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:
.PP
.nf
moerx
murx
.fi
.PP
Use a named session, Ctrl-X prefix and bottom status:
.PP
.nf
moerx \-\-prefix x \-\-status bottom work
murx \-\-prefix x \-\-status bottom work
.fi
.PP
Start a session with a minimal status display:
.PP
.nf
moerx \-\-no\-cwd \-\-no\-moerx \-\-no\-clock \-\-no\-hostname minimal
murx \-\-no\-cwd \-\-no\-murx \-\-no\-clock \-\-no\-hostname minimal
.fi
.PP
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,
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
.TP
.B 0

View file

@ -1,6 +1,6 @@
/*
* This file is part of moerx - An ultra-minimalist, single-file, terminal
* multiplexer: https://codeberg.org/armin/moerx
* This file is part of murx - An ultra-minimalist, single-file, terminal
* multiplexer: https://codeberg.org/armin/murx
*
* Copyright 2026 Armin Jenewein <a@bsd.pm>
* Licensed under the terms of the Apache-2.0 license.
@ -28,12 +28,12 @@
#endif
/*
* moerx - a very small terminal multiplexer
* murx - a very small terminal multiplexer
*
* One binary, no config file. Shortcuts and colours are hard-coded.
*
* moerx [session] attach to session (default "0"), or start it
* moerx -h|--help show usage and all Ctrl-A shortcut chains
* murx [session] attach to session (default "0"), or start it
* murx -h|--help show usage and all Ctrl-A shortcut chains
*
* 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) {
fputs("moerx: numeric limit exceeded\n", stderr);
fputs("murx: numeric limit exceeded\n", stderr);
exit(1);
}
@ -161,7 +161,7 @@ static unsigned short tty_dimension(int value) {
static void *xmalloc(size_t n) {
void *p = malloc(n);
if (!p) {
fputs("moerx: out of memory\n", stderr);
fputs("murx: out of memory\n", stderr);
exit(1);
}
return p;
@ -170,7 +170,7 @@ static void *xmalloc(size_t n) {
static void *xcalloc(size_t n, size_t sz) {
void *p = calloc(1, size_mul(n, sz));
if (!p) {
fputs("moerx: out of memory\n", stderr);
fputs("murx: out of memory\n", stderr);
exit(1);
}
return p;
@ -179,7 +179,7 @@ static void *xcalloc(size_t n, size_t sz) {
static void *xrealloc(void *p, size_t n) {
void *q = realloc(p, n);
if (!q) {
fputs("moerx: out of memory\n", stderr);
fputs("murx: out of memory\n", stderr);
exit(1);
}
return q;
@ -205,7 +205,7 @@ static int parse_ulong_field(const char **text, unsigned long *out) {
static long long now_ms(void) {
struct timespec ts = { 0, 0 };
if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) {
perror("moerx: clock_gettime");
perror("murx: clock_gettime");
exit(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_ULINE 0x08
#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. */
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);
/* 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 ~. */
static void em_osc_cwd(Pane *p) {
const char *path = NULL;
int uri = 0;
static const char cwd_prefix[] = "777;murx-cwd;";
if (strncmp(p->seq, "7;file://", 9) == 0) {
path = strchr(p->seq + 9, '/');
uri = 1;
} else if (strncmp(p->seq, "777;moerx-cwd;", 14) == 0) {
path = p->seq + 14;
} else if (strncmp(p->seq, cwd_prefix, sizeof cwd_prefix - 1) == 0) {
path = p->seq + sizeof cwd_prefix - 1;
}
if (!path || (*path != '/' &&
!(*path == '~' && (!path[1] || path[1] == '/')))) return;
@ -974,12 +975,12 @@ static void em_osc_cwd(Pane *p) {
static void em_osc_done(Pane *p) {
p->seq[p->seqlen] = '\0';
em_osc_cwd(p);
if (strcmp(p->seq, "777;moerx-root;0") == 0 ||
strcmp(p->seq, "777;moerx-root;1") == 0) {
if (strcmp(p->seq, "777;murx-root;0") == 0 ||
strcmp(p->seq, "777;murx-root;1") == 0) {
pid_t pid = tcgetpgrp(p->fd);
if (pid <= 0) pid = tcgetpgrp(p->tty_fd);
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;
}
}
@ -1225,6 +1226,14 @@ struct Client {
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 {
char name[64];
char sock_path[PATH_MAX];
@ -1233,10 +1242,7 @@ struct Session {
int w, h;
int status_bottom;
int show_cwd;
int show_clock;
int show_moerx;
int show_hostname;
DisplayOptions display;
Window *windows;
Window *cur, *last;
int nwin;
@ -1367,13 +1373,13 @@ static int window_update_name(Session *s, Window *w) {
w->privileged = privileged;
char next[sizeof w->name];
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);
} else {
const char *colon = strchr(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];
if (gethostname(host, sizeof host) < 0) snprintf(host, sizeof host, "localhost");
host[sizeof host - 1] = '\0';
@ -1653,7 +1659,7 @@ static Window *window_new(Session *s, const char *name) {
base = base ? base + 1 : shell;
if (name) {
snprintf(w->name, sizeof w->name, "%s", name);
} else if (s->show_hostname) {
} else if (s->display.show_hostname) {
char host[256];
if (gethostname(host, sizeof host) < 0) snprintf(host, sizeof host, "localhost");
host[sizeof host - 1] = '\0';
@ -1705,11 +1711,15 @@ static void session_layout(Session *s) {
/* 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) {
const char *base = getenv("XDG_RUNTIME_DIR");
if (!base || !*base) base = getenv("TMPDIR");
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) {
@ -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
cannot truncate the socket path. Session names are limited to 48 bytes. */
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);
}
@ -2002,7 +2012,7 @@ static void status_draw(Grid *g, Session *s, Client *c) {
clockbuf[0] = '\0';
int right_len = 0;
int rx = s->w;
if (s->show_clock) {
if (s->display.show_clock) {
time_t t = time(NULL);
struct tm tmv;
if (localtime_r(&t, &tmv) &&
@ -2029,12 +2039,12 @@ static void status_draw(Grid *g, Session *s, Client *c) {
int left_len = 0;
{
char left[PATH_MAX];
if (s->show_cwd) {
if (s->display.show_cwd) {
if (!status_cwd(s, left, sizeof left))
status_cwd_home(left, sizeof left);
left_len = status_cwd_draw(g, y, left, start);
} else if (s->show_moerx) {
snprintf(left, sizeof left, "moerx");
} else if (s->display.show_murx) {
snprintf(left, sizeof left, "murx");
left_len = status_cwd_draw(g, y, left, start);
} else {
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 */
status_right_draw(g, rx, y, clockbuf);
}
@ -2350,7 +2360,7 @@ static void draw_frame(Session *s, Client *c, Grid *scr) {
}
{
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) {
buf_printf(&b, "\x1b]2;%s\x07", title);
snprintf(c->title, sizeof c->title, "%s", title);
@ -2835,7 +2845,7 @@ static void client_lock(Client *c) {
c->locked = 1;
c->mode = 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 x = (c->cols - tw) / 2;
int y = c->rows / 2;
@ -3675,7 +3685,7 @@ static void run_server(Session *s) {
}
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);
free(panes);
}
@ -3715,7 +3725,7 @@ static void server_fail(int readyfd, const char *stage, int err) {
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(SIGHUP, SIG_IGN);
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->h = 24;
s->running = 1;
s->show_cwd = show_cwd;
s->show_clock = show_clock;
s->show_moerx = show_moerx;
s->show_hostname = show_hostname;
s->display = *display;
s->last_status = now_ms();
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) {
char dirs[2][PATH_MAX];
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;
size_t count = 0;
int result = 0;
@ -3861,7 +3868,7 @@ static int list_sessions(void) {
DIR *dir = opendir(dirs[i]);
if (!dir) {
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;
}
continue;
@ -3872,7 +3879,7 @@ static int list_sessions(void) {
entry = readdir(dir);
if (!entry) {
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;
}
break;
@ -3926,14 +3933,14 @@ static int ensure_socket_dir(void) {
if (mkdir(dir, 0700) < 0 && errno != EEXIST) return -1;
chmod(dir, 0700);
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 (mkdir(alt, 0700) == 0) chmod(alt, 0700);
}
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;
char dir[PATH_MAX], lockpath[PATH_MAX + 64];
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);
}
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);
}
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) {
struct termios saved;
if (tty_raw(&saved) < 0) {
fprintf(stderr, "moerx: not a terminal\n");
fprintf(stderr, "murx: not a terminal\n");
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;
tty_restore(&saved);
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));
} else {
fprintf(stderr, "moerx: cannot attach to session '%s': %s\n",
fprintf(stderr, "murx: cannot attach to session '%s': %s\n",
name, strerror(err));
}
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) {
fprintf(out,
"usage: moerx [-p letter] [-s top|bottom] [--no-cwd] [--no-clock] [--no-moerx] [--no-hostname] [session]\n"
" moerx -l | --list-sessions\n"
" moerx -h | --help\n"
"usage: murx [-p letter] [-s top|bottom] [--no-cwd] [--no-clock] [--no-murx] [--no-hostname] [session]\n"
" murx -l | --list-sessions\n"
" murx -h | --help\n"
"\n"
"Attach to a running session, or start it if it is not running.\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"
"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-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"
"\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;
unsigned char prefix = DEFAULT_PREFIX;
int status = 0;
int show_cwd = 1;
int show_clock = 1;
int show_moerx = 1;
int show_hostname = 1;
DisplayOptions display = {1, 1, 1, 1};
int list = 0;
while (argi < argc && argv[argi][0] == '-' && argv[argi][1]) {
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) {
list = 1;
} else if (strcmp(option, "--no-cwd") == 0) {
show_cwd = 0;
display.show_cwd = 0;
} else if (strcmp(option, "--no-clock") == 0) {
show_clock = 0;
} else if (strcmp(option, "--no-moerx") == 0) {
show_moerx = 0;
display.show_clock = 0;
} else if (strcmp(option, "--no-murx") == 0) {
display.show_murx = 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) {
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;
}
argi++;
} else if (strcmp(option, "-s") == 0 || strcmp(option, "--status") == 0) {
if (argi >= argc || (strcmp(argv[argi], "top") != 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;
}
status = strcmp(argv[argi++], "bottom") == 0 ? 2 : 1;
} else {
fprintf(stderr, "moerx: unknown option '%s'\n", option);
fprintf(stderr, "Try 'moerx --help' for more information.\n");
fprintf(stderr, "murx: unknown option '%s'\n", option);
fprintf(stderr, "Try 'murx --help' for more information.\n");
return 2;
}
}
if (list) {
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 list_sessions();
}
if (argc - argi > 1) {
fprintf(stderr, "moerx: too many arguments\n");
fprintf(stderr, "Try 'moerx --help' for more information.\n");
fprintf(stderr, "murx: too many arguments\n");
fprintf(stderr, "Try 'murx --help' for more information.\n");
return 2;
}
const char *name = argc - argi > 0 ? argv[argi] : "0";
if (!valid_session_name(name)) {
fprintf(stderr, "moerx: bad session name '%s'\n", name);
fprintf(stderr, "Try 'moerx --help' for more information.\n");
fprintf(stderr, "murx: bad session name '%s'\n", name);
fprintf(stderr, "Try 'murx --help' for more information.\n");
return 2;
}
@ -4393,9 +4397,9 @@ int main(int argc, char **argv) {
make_socket_path(name, path, sizeof 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) {
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));
return 1;
}