diff --git a/builtin.cpp b/builtin.cpp index 7ffcb773b..cb06481f0 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -3251,7 +3251,7 @@ static int builtin_fg(parser_t &parser, wchar_t **argv) const wcstring ft = tok_first(j->command_wcstr()); if (! ft.empty()) env_set(L"_", ft.c_str(), ENV_EXPORT); - reader_write_title(j->command_wcstr()); + reader_write_title(j->command()); make_first(j); job_set_flag(j, JOB_FOREGROUND, 1); diff --git a/reader.cpp b/reader.cpp index 336513d80..2f1e6c2dc 100644 --- a/reader.cpp +++ b/reader.cpp @@ -902,9 +902,8 @@ bool reader_thread_job_is_stale() return (void*)(uintptr_t) s_generation_count != pthread_getspecific(generation_count_key); } -void reader_write_title(const wchar_t *cmd) +void reader_write_title(const wcstring &cmd) { - const wchar_t *title; const env_var_t term_str = env_get_string(L"TERM"); /* @@ -934,7 +933,6 @@ void reader_write_title(const wchar_t *cmd) { char *n = ttyname(STDIN_FILENO); - if (contains(term, L"linux")) { return; @@ -942,24 +940,23 @@ void reader_write_title(const wchar_t *cmd) if (strstr(n, "tty") || strstr(n, "/vc/")) return; - - } - wcstring fish_title = L"fish_title"; - if (cmd) { - fish_title.append(L" "); - fish_title.append(parse_util_escape_string_with_quote(cmd, L'\0')); + wcstring fish_title_command = DEFAULT_TITLE; + if (function_exists(L"fish_title")) + { + fish_title_command = L"fish_title"; + if (! cmd.empty()) + { + fish_title_command.append(L" "); + fish_title_command.append(parse_util_escape_string_with_quote(cmd, L'\0')); + } } - title = function_exists(L"fish_title")?fish_title.c_str():DEFAULT_TITLE; - - if (wcslen(title) ==0) - return; wcstring_list_t lst; proc_push_interactive(0); - if (exec_subshell(title, lst, false /* do not apply exit status */) != -1) + if (exec_subshell(fish_title_command, lst, false /* do not apply exit status */) != -1) { if (! lst.empty()) { @@ -1020,7 +1017,7 @@ static void exec_prompt() } /* Write the screen title */ - reader_write_title(0); + reader_write_title(L""); } void reader_init() @@ -2540,7 +2537,7 @@ void reader_run_command(parser_t &parser, const wcstring &cmd) if (! ft.empty()) env_set(L"_", ft.c_str(), ENV_GLOBAL); - reader_write_title(cmd.c_str()); + reader_write_title(cmd); term_donate(); diff --git a/reader.h b/reader.h index cd39915f5..f89bd50e9 100644 --- a/reader.h +++ b/reader.h @@ -119,7 +119,7 @@ void reader_pop_current_filename(); \param cmd Command line string passed to \c fish_title if is defined. */ -void reader_write_title(const wchar_t *cmd); +void reader_write_title(const wcstring &cmd); /** Call this function to tell the reader that a repaint is needed, and