mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
added functionality to get standard default command prompt
This commit is contained in:
@@ -161,6 +161,25 @@ namespace Microsoft.Samples.PowerShell.Host
|
||||
executeHelper(initialScript,null);
|
||||
}
|
||||
|
||||
private string _prompt;
|
||||
|
||||
/// Sets the prompt equal to the output of the prompt function
|
||||
public string Prompt(Runspace rs)
|
||||
{
|
||||
string returnVal = string.Empty;
|
||||
Pipeline pipeline = rs.CreatePipeline();
|
||||
Command promptCommand = new Command("prompt");
|
||||
|
||||
pipeline.Commands.Add(promptCommand);
|
||||
|
||||
Collection<PSObject> output = pipeline.Invoke();
|
||||
foreach (PSObject item in output)
|
||||
{
|
||||
returnVal = item.BaseObject.ToString();
|
||||
}
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
/// <summary>
|
||||
/// A helper class that builds and executes a pipeline that writes
|
||||
/// to the default output path. Any exceptions that are thrown are
|
||||
@@ -362,7 +381,7 @@ namespace Microsoft.Samples.PowerShell.Host
|
||||
}
|
||||
else
|
||||
{
|
||||
prompt = "\nPSL> ";
|
||||
prompt = Prompt(this.myHost.Runspace);
|
||||
}
|
||||
|
||||
this.myHost.UI.Write(ConsoleColor.White, ConsoleColor.Black, prompt);
|
||||
|
||||
Reference in New Issue
Block a user