Skip to content

Commit 9a993e3

Browse files
committed
patch 8.0.1665: when running a terminal from the GUI 'term' is not useful
Problem: When running a terminal from the GUI 'term' is not useful. Solution: Use $TERM in the GUI if it starts with "xterm". (closes #2776)
1 parent 3aa67fb commit 9a993e3

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

runtime/doc/terminal.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,9 @@ On Unix a pty is used to make it possible to run all kinds of commands. You
352352
can even run Vim in the terminal! That's used for debugging, see below.
353353

354354
Environment variables are used to pass information to the running job:
355-
TERM name of the terminal, from the 'term' option
355+
TERM the name of the terminal, from the 'term' option or
356+
$TERM in the GUI; falls back to "xterm" if it does not
357+
start with "xterm"
356358
ROWS number of rows in the terminal initially
357359
LINES same as ROWS
358360
COLUMNS number of columns in the terminal initially

src/os_unix.c

+14-2
Original file line numberDiff line numberDiff line change
@@ -5579,11 +5579,23 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
55795579

55805580
# ifdef FEAT_TERMINAL
55815581
if (options->jo_term_rows > 0)
5582+
{
5583+
char *term = (char *)T_NAME;
5584+
5585+
#ifdef FEAT_GUI
5586+
if (term_is_gui(T_NAME))
5587+
/* In the GUI 'term' is not what we want, use $TERM. */
5588+
term = getenv("TERM");
5589+
#endif
5590+
/* Use 'term' or $TERM if it starts with "xterm", otherwise fall
5591+
* back to "xterm". */
5592+
if (term == NULL || *term == NUL || STRNCMP(term, "xterm", 5) != 0)
5593+
term = "xterm";
55825594
set_child_environment(
55835595
(long)options->jo_term_rows,
55845596
(long)options->jo_term_cols,
5585-
STRNCMP(T_NAME, "xterm", 5) == 0
5586-
? (char *)T_NAME : "xterm");
5597+
term);
5598+
}
55875599
else
55885600
# endif
55895601
set_default_child_environment();

src/version.c

+2
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,8 @@ static char *(features[]) =
762762

763763
static int included_patches[] =
764764
{ /* Add new patch number below this line */
765+
/**/
766+
1665,
765767
/**/
766768
1664,
767769
/**/

0 commit comments

Comments
 (0)