Set terminal title automatically [OpenBSD/ksh] This patch sets the terminal title when the DISPLAY variable is set. When a command is invoked, the terminal title will be set to: "$ full -command -line" When the command execution is finished, the terminal title will be reset to: "$ ksh (/current/path)" Index: bin/ksh/lex.c =================================================================== RCS file: /cvs/src/bin/ksh/lex.c,v retrieving revision 1.78 diff -u -p -u -p -r1.78 lex.c --- bin/ksh/lex.c 15 Jan 2018 14:58:05 -0000 1.78 +++ bin/ksh/lex.c 11 Jul 2021 08:42:30 -0000 @@ -1157,6 +1157,10 @@ getsc_line(Source *s) s->line++; histsave(s->line, s->str, 1); } + /* Set xterm title */ + char *d = str_val(global("DISPLAY")); + if(d[0] > 0) + shellf("%c]0;$ %s%c", '\033', s->str, '\007'); } if (interactive) set_prompt(PS2); Index: bin/ksh/main.c =================================================================== RCS file: /cvs/src/bin/ksh/main.c,v retrieving revision 1.98 diff -u -p -u -p -r1.98 main.c --- bin/ksh/main.c 28 Jun 2019 13:34:59 -0000 1.98 +++ bin/ksh/main.c 11 Jul 2021 08:42:30 -0000 @@ -609,6 +609,11 @@ shell(Source *volatile s, volatile int t j_notify(); mcheck(); set_prompt(PS1); + /* Reset xterm title */ + char *d = str_val(global("DISPLAY")); + if(d[0] > 0) + shellf("%c]0;$ ksh (%s)%c", '\033', + str_val(global("PWD")), '\007'); } t = compile(s);