From f681d3a1c1d1b1caf064a1130d858351c59b874c Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Mon, 23 Aug 2021 10:01:04 -0700 Subject: [PATCH] When there's no profile or title, invent a title from the commandline (#10998) This supports a future world where we give commandline-only invocations their own tabs. It was easier to promote the commandline to a title at the time of argument parsing, rather than later, but I am happy to change this if anyone disagrees. --- src/cascadia/TerminalApp/AppCommandlineArgs.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cascadia/TerminalApp/AppCommandlineArgs.cpp b/src/cascadia/TerminalApp/AppCommandlineArgs.cpp index a2da96205..ae8bced53 100644 --- a/src/cascadia/TerminalApp/AppCommandlineArgs.cpp +++ b/src/cascadia/TerminalApp/AppCommandlineArgs.cpp @@ -603,6 +603,13 @@ NewTerminalArgs AppCommandlineArgs::_getNewTerminalArgs(AppCommandlineArgs::NewT args.Profile(winrt::to_hstring(_profileName)); } + if (!*subcommand.profileNameOption && !_commandline.empty()) + { + // If there's no profile, but there IS a command line, set the tab title to the first part of the command + // This will ensure that the tab we spawn has a name (since it didn't get one from its profile!) + args.TabTitle(winrt::to_hstring(til::at(_commandline, 0))); + } + if (*subcommand.startingDirectoryOption) { args.StartingDirectory(winrt::to_hstring(_startingDirectory));