Add --no-moerx option to hide [moerx] in status bar
This commit is contained in:
parent
0ffb02a954
commit
0b113c12a9
2 changed files with 19 additions and 8 deletions
|
|
@ -13,6 +13,7 @@ make -B CC=clang
|
||||||
./moerx --status bottom work # same as -s bottom
|
./moerx --status bottom work # same as -s bottom
|
||||||
./moerx --no-cwd work # show [moerx] instead of the directory
|
./moerx --no-cwd work # show [moerx] instead of the directory
|
||||||
./moerx --no-clock work # hide the status bar clock
|
./moerx --no-clock work # hide the status bar clock
|
||||||
|
./moerx --no-clock --no-moerx work # hide clock and [moerx]
|
||||||
./moerx --help # all shortcuts
|
./moerx --help # all shortcuts
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -42,7 +43,8 @@ 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 `[moerx]` on the left of the status bar instead of the
|
||||||
current directory, and `--no-clock` to hide the clock on the right. These
|
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`). These
|
||||||
options apply when starting a new session.
|
options apply when starting a new session.
|
||||||
|
|
||||||
## What it does
|
## What it does
|
||||||
|
|
|
||||||
25
moerx.c
25
moerx.c
|
|
@ -1128,6 +1128,7 @@ struct Session {
|
||||||
int status_bottom;
|
int status_bottom;
|
||||||
int show_cwd;
|
int show_cwd;
|
||||||
int show_clock;
|
int show_clock;
|
||||||
|
int show_moerx;
|
||||||
Window *windows;
|
Window *windows;
|
||||||
Window *cur, *last;
|
Window *cur, *last;
|
||||||
int nwin;
|
int nwin;
|
||||||
|
|
@ -1831,10 +1832,13 @@ static void status_draw(Grid *g, Session *s, Client *c) {
|
||||||
if (s->show_cwd) {
|
if (s->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);
|
||||||
} else {
|
|
||||||
snprintf(left, sizeof left, "moerx");
|
|
||||||
}
|
|
||||||
left_len = status_cwd_draw(g, y, left, start);
|
left_len = status_cwd_draw(g, y, left, start);
|
||||||
|
} else if (s->show_moerx) {
|
||||||
|
snprintf(left, sizeof left, "moerx");
|
||||||
|
left_len = status_cwd_draw(g, y, left, start);
|
||||||
|
} else {
|
||||||
|
left_len = 0;
|
||||||
|
}
|
||||||
if (start < left_len) start = left_len;
|
if (start < left_len) start = left_len;
|
||||||
}
|
}
|
||||||
if (start < 0) start = 0;
|
if (start < 0) start = 0;
|
||||||
|
|
@ -3490,7 +3494,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) {
|
static void server_start(const char *path, const char *name, int readyfd, int show_cwd, int show_clock, int show_moerx) {
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
signal(SIGHUP, SIG_IGN);
|
signal(SIGHUP, SIG_IGN);
|
||||||
signal(SIGCHLD, SIG_DFL);
|
signal(SIGCHLD, SIG_DFL);
|
||||||
|
|
@ -3540,6 +3544,7 @@ static void server_start(const char *path, const char *name, int readyfd, int sh
|
||||||
s->running = 1;
|
s->running = 1;
|
||||||
s->show_cwd = show_cwd;
|
s->show_cwd = show_cwd;
|
||||||
s->show_clock = show_clock;
|
s->show_clock = show_clock;
|
||||||
|
s->show_moerx = show_moerx;
|
||||||
s->last_status = now_ms();
|
s->last_status = now_ms();
|
||||||
|
|
||||||
Window *w = window_new(s, NULL);
|
Window *w = window_new(s, NULL);
|
||||||
|
|
@ -3619,7 +3624,7 @@ static int ensure_socket_dir(void) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spawn_server(const char *path, const char *name, int show_cwd, int show_clock) {
|
static int spawn_server(const char *path, const char *name, int show_cwd, int show_clock, int show_moerx) {
|
||||||
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);
|
||||||
|
|
@ -3667,7 +3672,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);
|
server_start(path, name, p[1], show_cwd, show_clock, show_moerx);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
close(p[1]);
|
close(p[1]);
|
||||||
|
|
@ -3924,7 +3929,7 @@ 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] [session]\n"
|
"usage: moerx [-p letter] [-s top|bottom] [--no-cwd] [--no-clock] [--no-moerx] [session]\n"
|
||||||
" moerx -h | --help\n"
|
" moerx -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"
|
||||||
|
|
@ -3935,6 +3940,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"
|
||||||
"\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"
|
||||||
"Letters a through z are supported (case-insensitive); the default is a (Ctrl-A).\n"
|
"Letters a through z are supported (case-insensitive); the default is a (Ctrl-A).\n"
|
||||||
|
|
@ -4011,6 +4017,7 @@ int main(int argc, char **argv) {
|
||||||
int status = 0;
|
int status = 0;
|
||||||
int show_cwd = 1;
|
int show_cwd = 1;
|
||||||
int show_clock = 1;
|
int show_clock = 1;
|
||||||
|
int show_moerx = 1;
|
||||||
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++];
|
||||||
if (strcmp(option, "--") == 0) break;
|
if (strcmp(option, "--") == 0) break;
|
||||||
|
|
@ -4022,6 +4029,8 @@ int main(int argc, char **argv) {
|
||||||
show_cwd = 0;
|
show_cwd = 0;
|
||||||
} else if (strcmp(option, "--no-clock") == 0) {
|
} else if (strcmp(option, "--no-clock") == 0) {
|
||||||
show_clock = 0;
|
show_clock = 0;
|
||||||
|
} else if (strcmp(option, "--no-moerx") == 0) {
|
||||||
|
show_moerx = 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, "moerx: %s requires a letter from a through z\n", option);
|
||||||
|
|
@ -4058,7 +4067,7 @@ 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);
|
if (fd < 0) fd = spawn_server(path, name, show_cwd, show_clock, show_moerx);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fprintf(stderr, "moerx: cannot start or attach session '%s': %s\n",
|
fprintf(stderr, "moerx: cannot start or attach session '%s': %s\n",
|
||||||
name, strerror(errno));
|
name, strerror(errno));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue