fix(debug): output shell and version

This commit is contained in:
Jan De Dobbeleer 2023-03-26 17:26:39 +02:00 committed by Jan De Dobbeleer
parent 92c28a2e8d
commit 972ebd4805
12 changed files with 26 additions and 8 deletions

View file

@ -47,10 +47,15 @@ body:
label: Which shell are you using?
multiple: true
options:
- zsh
- bash
- elvish
- fish
- cmd
- nu
- powershell
- xonsh
- tcsh
- zsh
- other (please specify)
- type: textarea
id: logs

View file

@ -254,6 +254,12 @@ func (e *Engine) renderBlock(block *Block, cancelNewline bool) {
// debug will loop through your config file and output the timings for each segments
func (e *Engine) PrintDebug(startTime time.Time, version string) string {
e.write(fmt.Sprintf("\n%s %s\n", log.Text("Version:").Green().Bold().Plain(), version))
sh := e.Env.Shell()
shellVersion := e.Env.Getenv("POSH_SHELL_VERSION")
if len(shellVersion) != 0 {
sh += fmt.Sprintf(" (%s)", shellVersion)
}
e.write(fmt.Sprintf("\n%s %s\n", log.Text("Shell:").Green().Bold().Plain(), sh))
e.write(log.Text("\nSegments:\n\n").Green().Bold().Plain().String())
// console title timing
titleStartTime := time.Now()

View file

@ -642,7 +642,7 @@ func (env *Shell) Shell() string {
// this is used for when scoop creates a shim, see
// https://github.com/jandedobbeleer/oh-my-posh/issues/2806
executable, _ := os.Executable()
if name == "cmd.exe" || name == executable {
if name == executable {
p, _ = p.Parent()
name, err = p.Name()
env.Debug("parent process name: " + name)

View file

@ -1,4 +1,5 @@
export POSH_THEME=::CONFIG::
export POSH_SHELL_VERSION=$BASH_VERSION
export POWERLINE_COMMAND="oh-my-posh"
export POSH_PID=$$
export CONDA_PROMPT_MODIFIER=false

View file

@ -1,7 +1,7 @@
set-env POSH_PID (to-string (randint 10000000000000 10000000000000000))
set-env POSH_THEME '::CONFIG::'
set-env POSH_SHELL_VERSION (elvish --version)
set-env POWERLINE_COMMAND 'oh-my-posh'
set-env ELVISH_VERSION (elvish --version)
var error-code = 0
@ -23,12 +23,12 @@ set edit:after-command = [ $@edit:after-command $posh-after-command-hook~ ]
set edit:prompt = {
var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000))
::OMP:: print primary --config=$E:POSH_THEME --shell=elvish --execution-time=$cmd-duration --error=$error-code --pwd=$pwd --shell-version=$E:ELVISH_VERSION
::OMP:: print primary --config=$E:POSH_THEME --shell=elvish --execution-time=$cmd-duration --error=$error-code --pwd=$pwd --shell-version=$E:POSH_SHELL_VERSION
}
set edit:rprompt = {
var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000))
::OMP:: print right --config=$E:POSH_THEME --shell=elvish --execution-time=$cmd-duration --error=$error-code --pwd=$pwd --shell-version=$E:ELVISH_VERSION
::OMP:: print right --config=$E:POSH_THEME --shell=elvish --execution-time=$cmd-duration --error=$error-code --pwd=$pwd --shell-version=$E:POSH_SHELL_VERSION
}
if (eq '::UPGRADE::' 'true') {

View file

@ -1,4 +1,5 @@
set --export POSH_THEME ::CONFIG::
set --export POSH_SHELL_VERSION $FISH_VERSION
set --global POWERLINE_COMMAND "oh-my-posh"
set --global POSH_PID $fish_pid
set --global CONDA_PROMPT_MODIFIER false

View file

@ -75,6 +75,7 @@ local function omp_config()
end
os.setenv("POSH_THEME", ::CONFIG::)
os.setenv("POSH_SHELL_VERSION", string.format('clink v%s.%s.%s.%s', clink.version_major, clink.version_minor, clink.version_patch, clink.version_commit))
-- Execution helpers

View file

@ -7,10 +7,10 @@ export-env {
# making it annoying when you have a multiline prompt
# making the behavior different compared to other shells
let-env PROMPT_COMMAND_RIGHT = {''}
let-env NU_VERSION = (version | get version)
let-env POSH_SHELL_VERSION = (version | get version)
# PROMPTS
let-env PROMPT_MULTILINE_INDICATOR = (^::OMP:: print secondary $"--config=($env.POSH_THEME)" --shell=nu $"--shell-version=($env.NU_VERSION)")
let-env PROMPT_MULTILINE_INDICATOR = (^::OMP:: print secondary $"--config=($env.POSH_THEME)" --shell=nu $"--shell-version=($env.POSH_SHELL_VERSION)")
let-env PROMPT_COMMAND = {
# We have to do this because the initial value of `$env.CMD_DURATION_MS` is always `0823`,
@ -23,7 +23,7 @@ export-env {
let clear = (history | last 1 | get 0.command) == "clear"
let width = ((term size).columns | into string)
^::OMP:: print primary $"--config=($env.POSH_THEME)" --shell=nu $"--shell-version=($env.NU_VERSION)" $"--execution-time=($cmd_duration)" $"--error=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)" $"--cleared=($clear)"
^::OMP:: print primary $"--config=($env.POSH_THEME)" --shell=nu $"--shell-version=($env.POSH_SHELL_VERSION)" $"--execution-time=($cmd_duration)" $"--error=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)" $"--cleared=($clear)"
}
}

View file

@ -22,6 +22,7 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
$script:TransientPrompt = $false
$script:ToolTipCommand = ""
$env:POWERLINE_COMMAND = "oh-my-posh"
$env:POSH_SHELL_VERSION = $script:PSVersion
$env:POSH_PID = $PID
$env:CONDA_PROMPT_MODIFIER = $false

View file

@ -3,6 +3,7 @@ import uuid
$POWERLINE_COMMAND = "oh-my-posh"
$POSH_THEME = "::CONFIG::"
$POSH_PID = uuid.uuid4().hex
$POSH_SHELL_VERSION = ""
def get_command_context():
last_cmd = __xonsh__.history[-1] if __xonsh__.history else None

View file

@ -1,5 +1,6 @@
setenv POWERLINE_COMMAND "oh-my-posh";
setenv POSH_THEME "::CONFIG::";
setenv POSH_SHELL_VERSION "";
set USER_PRECMD = "`alias precmd`";
set USER_POSTCMD = "`alias postcmd`";

View file

@ -1,4 +1,5 @@
export POSH_THEME=::CONFIG::
export POSH_SHELL_VERSION=$ZSH_VERSION
export POSH_PID=$$
export POWERLINE_COMMAND="oh-my-posh"
export CONDA_PROMPT_MODIFIER=false