mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
feat(debug): remove the need to specify shell
This commit is contained in:
parent
b21c2d2c71
commit
bebadac664
2
.github/ISSUE_TEMPLATE/bug.yml
vendored
2
.github/ISSUE_TEMPLATE/bug.yml
vendored
|
@ -61,7 +61,7 @@ body:
|
||||||
id: logs
|
id: logs
|
||||||
attributes:
|
attributes:
|
||||||
label: Log output
|
label: Log output
|
||||||
description: Please copy and paste the output generated by `oh-my-posh debug <shell> --plain`.
|
description: Please copy and paste the output generated by `oh-my-posh debug --plain`.
|
||||||
render: Shell
|
render: Shell
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jandedobbeleer/oh-my-posh/src/build"
|
"github.com/jandedobbeleer/oh-my-posh/src/build"
|
||||||
|
@ -24,30 +25,25 @@ func init() {
|
||||||
|
|
||||||
func createDebugCmd() *cobra.Command {
|
func createDebugCmd() *cobra.Command {
|
||||||
debugCmd := &cobra.Command{
|
debugCmd := &cobra.Command{
|
||||||
Use: "debug [bash|zsh|fish|powershell|pwsh|cmd|nu|tcsh|elvish|xonsh]",
|
Use: "debug",
|
||||||
Short: "Print the prompt in debug mode",
|
Short: "Print the prompt in debug mode",
|
||||||
Long: "Print the prompt in debug mode.",
|
Long: "Print the prompt in debug mode.",
|
||||||
ValidArgs: supportedShells,
|
Run: func(_ *cobra.Command, _ []string) {
|
||||||
Args: NoArgsOrOneValidArg,
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
if len(args) == 0 {
|
|
||||||
_ = cmd.Help()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Enable()
|
log.Enable()
|
||||||
log.Debug("debug mode enabled")
|
log.Debug("debug mode enabled")
|
||||||
|
|
||||||
|
shell := os.Getenv("POSH_SHELL")
|
||||||
|
|
||||||
configFile := config.Path(configFlag)
|
configFile := config.Path(configFlag)
|
||||||
cfg := config.Load(configFile, args[0], false)
|
cfg := config.Load(configFile, shell, false)
|
||||||
|
|
||||||
flags := &runtime.Flags{
|
flags := &runtime.Flags{
|
||||||
Config: configFile,
|
Config: configFile,
|
||||||
Debug: true,
|
Debug: true,
|
||||||
PWD: pwd,
|
PWD: pwd,
|
||||||
Shell: args[0],
|
Shell: shell,
|
||||||
Plain: plain,
|
Plain: plain,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +57,7 @@ func createDebugCmd() *cobra.Command {
|
||||||
env.Close()
|
env.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
terminal.Init(args[0])
|
terminal.Init(shell)
|
||||||
terminal.BackgroundColor = cfg.TerminalBackground.ResolveTemplate()
|
terminal.BackgroundColor = cfg.TerminalBackground.ResolveTemplate()
|
||||||
terminal.Colors = cfg.MakeColors(env)
|
terminal.Colors = cfg.MakeColors(env)
|
||||||
terminal.Plain = plain
|
terminal.Plain = plain
|
||||||
|
|
|
@ -62,7 +62,7 @@ func Path(config string) string {
|
||||||
hasConfig := len(config) > 0
|
hasConfig := len(config) > 0
|
||||||
|
|
||||||
if poshTheme := os.Getenv("POSH_THEME"); len(poshTheme) > 0 && !hasConfig {
|
if poshTheme := os.Getenv("POSH_THEME"); len(poshTheme) > 0 && !hasConfig {
|
||||||
log.Debug("config set using POSH_THEME: %s", poshTheme)
|
log.Debug("config set using POSH_THEME:", poshTheme)
|
||||||
return poshTheme
|
return poshTheme
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
export POSH_THEME=::CONFIG::
|
export POSH_THEME=::CONFIG::
|
||||||
|
export POSH_SHELL='bash'
|
||||||
export POSH_SHELL_VERSION=$BASH_VERSION
|
export POSH_SHELL_VERSION=$BASH_VERSION
|
||||||
export POWERLINE_COMMAND='oh-my-posh'
|
export POWERLINE_COMMAND='oh-my-posh'
|
||||||
export POSH_SESSION_ID=::SESSION_ID::
|
export POSH_SESSION_ID=::SESSION_ID::
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
set-env POSH_SESSION_ID ::SESSION_ID::
|
set-env POSH_SESSION_ID ::SESSION_ID::
|
||||||
set-env POSH_THEME ::CONFIG::
|
set-env POSH_THEME ::CONFIG::
|
||||||
|
set-env POSH_SHELL elvish
|
||||||
set-env POSH_SHELL_VERSION $version
|
set-env POSH_SHELL_VERSION $version
|
||||||
set-env POWERLINE_COMMAND oh-my-posh
|
set-env POWERLINE_COMMAND oh-my-posh
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
set --export POSH_THEME ::CONFIG::
|
set --export POSH_THEME ::CONFIG::
|
||||||
|
set --export POSH_SHELL fish
|
||||||
set --export POSH_SHELL_VERSION $FISH_VERSION
|
set --export POSH_SHELL_VERSION $FISH_VERSION
|
||||||
set --export POWERLINE_COMMAND oh-my-posh
|
set --export POWERLINE_COMMAND oh-my-posh
|
||||||
set --export POSH_SESSION_ID ::SESSION_ID::
|
set --export POSH_SESSION_ID ::SESSION_ID::
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
---@diagnostic disable: undefined-field
|
---@diagnostic disable: undefined-field
|
||||||
---@diagnostic disable: lowercase-global
|
---@diagnostic disable: lowercase-global
|
||||||
|
|
||||||
-- Cache PID
|
-- Environment variables
|
||||||
os.setenv('POSH_SESSION_ID', '::SESSION_ID::')
|
os.setenv('POSH_SESSION_ID', '::SESSION_ID::')
|
||||||
|
os.setenv('POSH_SHELL', 'cmd')
|
||||||
|
|
||||||
-- Helper functions
|
-- Helper functions
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ $env.POWERLINE_COMMAND = 'oh-my-posh'
|
||||||
$env.POSH_THEME = (echo ::CONFIG::)
|
$env.POSH_THEME = (echo ::CONFIG::)
|
||||||
$env.PROMPT_INDICATOR = ""
|
$env.PROMPT_INDICATOR = ""
|
||||||
$env.POSH_SESSION_ID = (echo ::SESSION_ID::)
|
$env.POSH_SESSION_ID = (echo ::SESSION_ID::)
|
||||||
|
$env.POSH_SHELL = "nu"
|
||||||
$env.POSH_SHELL_VERSION = (version | get version)
|
$env.POSH_SHELL_VERSION = (version | get version)
|
||||||
|
|
||||||
let _omp_executable: string = (echo ::OMP::)
|
let _omp_executable: string = (echo ::OMP::)
|
||||||
|
|
|
@ -39,6 +39,7 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
||||||
$script:JobCount = 0
|
$script:JobCount = 0
|
||||||
|
|
||||||
$env:POWERLINE_COMMAND = "oh-my-posh"
|
$env:POWERLINE_COMMAND = "oh-my-posh"
|
||||||
|
$env:POSH_SHELL = "pwsh"
|
||||||
$env:POSH_SHELL_VERSION = $script:PSVersion
|
$env:POSH_SHELL_VERSION = $script:PSVersion
|
||||||
$env:POSH_SESSION_ID = ::SESSION_ID::
|
$env:POSH_SESSION_ID = ::SESSION_ID::
|
||||||
$env:CONDA_PROMPT_MODIFIER = $false
|
$env:CONDA_PROMPT_MODIFIER = $false
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
setenv POWERLINE_COMMAND "oh-my-posh";
|
setenv POWERLINE_COMMAND "oh-my-posh";
|
||||||
setenv POSH_THEME ::CONFIG::;
|
setenv POSH_THEME ::CONFIG::;
|
||||||
|
setenv POSH_SHELL "tcsh";
|
||||||
setenv POSH_SHELL_VERSION "$tcsh";
|
setenv POSH_SHELL_VERSION "$tcsh";
|
||||||
setenv POSH_SESSION_ID ::SESSION_ID::;
|
setenv POSH_SESSION_ID ::SESSION_ID::;
|
||||||
setenv OSTYPE "$OSTYPE";
|
setenv OSTYPE "$OSTYPE";
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
$POWERLINE_COMMAND = "oh-my-posh"
|
$POWERLINE_COMMAND = "oh-my-posh"
|
||||||
$POSH_THEME = ::CONFIG::
|
$POSH_THEME = ::CONFIG::
|
||||||
$POSH_SESSION_ID = ::SESSION_ID::
|
$POSH_SESSION_ID = ::SESSION_ID::
|
||||||
|
$POSH_SHELL = "xonsh"
|
||||||
$POSH_SHELL_VERSION = $XONSH_VERSION
|
$POSH_SHELL_VERSION = $XONSH_VERSION
|
||||||
|
|
||||||
_omp_executable = ::OMP::
|
_omp_executable = ::OMP::
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
export POSH_THEME=::CONFIG::
|
export POSH_THEME=::CONFIG::
|
||||||
|
export POSH_SHELL='zsh'
|
||||||
export POSH_SHELL_VERSION=$ZSH_VERSION
|
export POSH_SHELL_VERSION=$ZSH_VERSION
|
||||||
export POSH_SESSION_ID=::SESSION_ID::
|
export POSH_SESSION_ID=::SESSION_ID::
|
||||||
export POWERLINE_COMMAND='oh-my-posh'
|
export POWERLINE_COMMAND='oh-my-posh'
|
||||||
|
|
Loading…
Reference in a new issue