add command line string as $argv[1] for fish_title

This commit is contained in:
jianjun 2014-07-14 23:34:15 +08:00 committed by ridiculousfish
parent 556680cf5e
commit 87abcecca6
3 changed files with 13 additions and 6 deletions

View file

@ -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();
reader_write_title(j->command_wcstr());
make_first(j);
job_set_flag(j, JOB_FOREGROUND, 1);

View file

@ -902,7 +902,7 @@ bool reader_thread_job_is_stale()
return (void*)(uintptr_t) s_generation_count != pthread_getspecific(generation_count_key);
}
void reader_write_title()
void reader_write_title(const wchar_t *cmd)
{
const wchar_t *title;
const env_var_t term_str = env_get_string(L"TERM");
@ -946,7 +946,12 @@ void reader_write_title()
}
title = function_exists(L"fish_title")?L"fish_title":DEFAULT_TITLE;
wcstring fish_title = L"fish_title";
if (cmd) {
fish_title.append(L" ");
fish_title.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;
@ -1015,7 +1020,7 @@ static void exec_prompt()
}
/* Write the screen title */
reader_write_title();
reader_write_title(0);
}
void reader_init()
@ -2535,7 +2540,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();
reader_write_title(cmd.c_str());
term_donate();

View file

@ -116,8 +116,10 @@ void reader_pop_current_filename();
Write the title to the titlebar. This function is called just
before a new application starts executing and just after it
finishes.
\param cmd Command line string passed to \c fish_title if is defined.
*/
void reader_write_title();
void reader_write_title(const wchar_t *cmd);
/**
Call this function to tell the reader that a repaint is needed, and