mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-21 02:55:37 -08:00
feat(pwsh): debug prompt
This commit is contained in:
parent
6e3c1af164
commit
d11c39b620
|
@ -29,10 +29,11 @@ var (
|
|||
|
||||
// printCmd represents the prompt command
|
||||
var printCmd = &cobra.Command{
|
||||
Use: "print [primary|secondary|transient|right|tooltip|valid|error]",
|
||||
Use: "print [debug|primary|secondary|transient|right|tooltip|valid|error]",
|
||||
Short: "Print the prompt/context",
|
||||
Long: "Print one of the prompts based on the location/use-case.",
|
||||
ValidArgs: []string{
|
||||
"debug",
|
||||
"primary",
|
||||
"secondary",
|
||||
"transient",
|
||||
|
@ -86,6 +87,8 @@ var printCmd = &cobra.Command{
|
|||
Plain: plain,
|
||||
}
|
||||
switch args[0] {
|
||||
case "debug":
|
||||
fmt.Print(eng.PrintExtraPrompt(engine.Debug))
|
||||
case "primary":
|
||||
fmt.Print(eng.PrintPrimary())
|
||||
case "secondary":
|
||||
|
|
|
@ -40,6 +40,7 @@ type Config struct {
|
|||
ValidLine *ExtraPrompt `json:"valid_line,omitempty"`
|
||||
ErrorLine *ExtraPrompt `json:"error_line,omitempty"`
|
||||
SecondaryPrompt *ExtraPrompt `json:"secondary_prompt,omitempty"`
|
||||
DebugPrompt *ExtraPrompt `json:"debug_prompt,omitempty"`
|
||||
Palette color.Palette `json:"palette,omitempty"`
|
||||
|
||||
format string
|
||||
|
|
|
@ -275,11 +275,14 @@ const (
|
|||
Valid
|
||||
Error
|
||||
Secondary
|
||||
Debug
|
||||
)
|
||||
|
||||
func (e *Engine) PrintExtraPrompt(promptType ExtraPromptType) string {
|
||||
var prompt *ExtraPrompt
|
||||
switch promptType {
|
||||
case Debug:
|
||||
prompt = e.Config.DebugPrompt
|
||||
case Transient:
|
||||
prompt = e.Config.TransientPrompt
|
||||
case Valid:
|
||||
|
@ -297,6 +300,8 @@ func (e *Engine) PrintExtraPrompt(promptType ExtraPromptType) string {
|
|||
return template
|
||||
}
|
||||
switch promptType { // nolint: exhaustive
|
||||
case Debug:
|
||||
return "[DBG]: "
|
||||
case Transient:
|
||||
return "{{ .Shell }}> "
|
||||
case Secondary:
|
||||
|
|
|
@ -67,6 +67,11 @@ function global:Initialize-ModuleSupport {
|
|||
$env:POSH_TRANSIENT = $false
|
||||
return
|
||||
}
|
||||
if (Test-Path variable:/PSDebugContext) {
|
||||
$standardOut = @(&$omp prompt print debug --pwd="$cleanPWD" --pswd="$cleanPSWD" --config="$config" 2>&1)
|
||||
$standardOut -join "`n"
|
||||
return
|
||||
}
|
||||
$errorCode = 0
|
||||
Initialize-ModuleSupport
|
||||
Set-PoshContext
|
||||
|
|
Loading…
Reference in a new issue