From 435d8e60925dd346f137aef56f16aaa8d6e1fa6c Mon Sep 17 00:00:00 2001 From: hanez Date: Sun, 15 Nov 2026 23:24:20 +0100 Subject: [PATCH] Made -p more comfortable. Now uses just a letter instead of the C- prefix. --- README.md | 10 +++++----- moerx.c | 13 ++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7e4e3a5..822f61b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ dependencies. make -B CC=clang ./moerx # session "0" ./moerx work # separate named session -./moerx -p C-x work # use Ctrl-X as this client's prefix +./moerx -p x work # use Ctrl-X as this client's prefix ./moerx --help # all shortcuts ``` @@ -16,13 +16,13 @@ Detach with `Ctrl-A d`. Run `moerx` again to reattach. Every shortcut is a chain that starts with the prefix (by default `Ctrl-A`): press it, release it, then press the rest of the chain. -Use `-p C-x` or `--prefix C-x` to choose Ctrl-X instead. Control letters -`C-a` through `C-z` are supported, case-insensitively. The choice applies to +Use `-p x` or `--prefix x` to choose Ctrl-X instead. 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 C-x'`. Clients attached to the same session +alias such as `alias moerx='moerx -p x'`. Clients attached to the same session can choose different prefixes. -With `-p C-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`, and switch to the last window with `Ctrl-X Ctrl-X`. Doubling the prefix takes priority over any other control-key binding; `Ctrl-X x` still locks the client. Ctrl-A is sent straight to the pane. All tables below show the default prefix; diff --git a/moerx.c b/moerx.c index 9f8d21c..330100f 100644 --- a/moerx.c +++ b/moerx.c @@ -3838,14 +3838,14 @@ static int run_client(int fd, const char *name, unsigned char prefix) { static void print_help(FILE *out) { fprintf(out, - "usage: moerx [-p C-key] [session]\n" + "usage: moerx [-p letter] [session]\n" " moerx -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" "\n" - "Use -p C-x (or --prefix C-x) to choose Ctrl-X as this client's prefix.\n" - "Keys C-a through C-z are supported; the default is C-a.\n" + "Use -p x (or --prefix x) to choose Ctrl-X as this client's prefix.\n" + "Letters a through z are supported (case-insensitive); the default is a (Ctrl-A).\n" "The shortcuts below use the default Ctrl-A prefix. Replace it with\n" "your chosen prefix, including both keys in the last-window shortcut.\n" "Prefix then a sends the chosen prefix literally to the pane.\n" @@ -3903,9 +3903,8 @@ static void print_help(FILE *out) { } static int parse_prefix(const char *text, unsigned char *prefix) { - if (!text || strlen(text) != 3 || - (text[0] != 'C' && text[0] != 'c') || text[1] != '-') return 0; - unsigned char letter = (unsigned char)text[2]; + if (!text || strlen(text) != 1) return 0; + unsigned char letter = (unsigned char)text[0]; if (letter >= 'A' && letter <= 'Z') letter += 'a' - 'A'; if (letter < 'a' || letter > 'z') return 0; *prefix = letter - 'a' + 1; @@ -3926,7 +3925,7 @@ int main(int argc, char **argv) { } if (strcmp(option, "-p") == 0 || strcmp(option, "--prefix") == 0) { if (argi >= argc || !parse_prefix(argv[argi], &prefix)) { - fprintf(stderr, "moerx: %s requires a key from C-a through C-z\n", option); + fprintf(stderr, "moerx: %s requires a letter from a through z\n", option); return 2; } argi++;