dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit b73aba5c17b10eb9bbfaea6abe0de9802225573d
parent 081e3a1aa9459101b6028f0007face4f762ee1eb
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sun, 11 Dec 2016 23:08:47 +0100

Set initial window title based on command name if given

Based on a patch by René Kuligowski.

Diffstat:
dvtm.c | 19+++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/dvtm.c b/dvtm.c @@ -14,6 +14,8 @@ #include <unistd.h> #include <stdint.h> #include <wchar.h> +#include <limits.h> +#include <libgen.h> #include <sys/select.h> #include <sys/stat.h> #include <sys/ioctl.h> @@ -1051,11 +1053,20 @@ create(const char *args[]) { return; } - c->cmd = (args && args[0]) ? args[0] : shell; - if (args && args[1]) { - strncpy(c->title, args[1], sizeof(c->title) - 1); - c->title[sizeof(c->title) - 1] = '\0'; + if (args && args[0]) { + c->cmd = args[0]; + char name[PATH_MAX]; + strncpy(name, args[0], sizeof(name)); + name[sizeof(name)-1] = '\0'; + strncpy(c->title, basename(name), sizeof(c->title)); + } else { + c->cmd = shell; } + + if (args && args[1]) + strncpy(c->title, args[1], sizeof(c->title)); + c->title[sizeof(c->title)-1] = '\0'; + if (args && args[2]) cwd = !strcmp(args[2], "$CWD") ? getcwd_by_pid(sel) : (char*)args[2]; c->pid = vt_forkpty(c->term, shell, pargs, cwd, env, NULL, NULL);