mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
fix(debug): output shell and version
This commit is contained in:
parent
92c28a2e8d
commit
972ebd4805
7
.github/ISSUE_TEMPLATE/bug.yml
vendored
7
.github/ISSUE_TEMPLATE/bug.yml
vendored
|
@ -47,10 +47,15 @@ body:
|
||||||
label: Which shell are you using?
|
label: Which shell are you using?
|
||||||
multiple: true
|
multiple: true
|
||||||
options:
|
options:
|
||||||
- zsh
|
|
||||||
- bash
|
- bash
|
||||||
|
- elvish
|
||||||
- fish
|
- fish
|
||||||
|
- cmd
|
||||||
|
- nu
|
||||||
- powershell
|
- powershell
|
||||||
|
- xonsh
|
||||||
|
- tcsh
|
||||||
|
- zsh
|
||||||
- other (please specify)
|
- other (please specify)
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: logs
|
id: logs
|
||||||
|
|
|
@ -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
|
// debug will loop through your config file and output the timings for each segments
|
||||||
func (e *Engine) PrintDebug(startTime time.Time, version string) string {
|
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))
|
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())
|
e.write(log.Text("\nSegments:\n\n").Green().Bold().Plain().String())
|
||||||
// console title timing
|
// console title timing
|
||||||
titleStartTime := time.Now()
|
titleStartTime := time.Now()
|
||||||
|
|
|
@ -642,7 +642,7 @@ func (env *Shell) Shell() string {
|
||||||
// this is used for when scoop creates a shim, see
|
// this is used for when scoop creates a shim, see
|
||||||
// https://github.com/jandedobbeleer/oh-my-posh/issues/2806
|
// https://github.com/jandedobbeleer/oh-my-posh/issues/2806
|
||||||
executable, _ := os.Executable()
|
executable, _ := os.Executable()
|
||||||
if name == "cmd.exe" || name == executable {
|
if name == executable {
|
||||||
p, _ = p.Parent()
|
p, _ = p.Parent()
|
||||||
name, err = p.Name()
|
name, err = p.Name()
|
||||||
env.Debug("parent process name: " + name)
|
env.Debug("parent process name: " + name)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
export POSH_THEME=::CONFIG::
|
export POSH_THEME=::CONFIG::
|
||||||
|
export POSH_SHELL_VERSION=$BASH_VERSION
|
||||||
export POWERLINE_COMMAND="oh-my-posh"
|
export POWERLINE_COMMAND="oh-my-posh"
|
||||||
export POSH_PID=$$
|
export POSH_PID=$$
|
||||||
export CONDA_PROMPT_MODIFIER=false
|
export CONDA_PROMPT_MODIFIER=false
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
set-env POSH_PID (to-string (randint 10000000000000 10000000000000000))
|
set-env POSH_PID (to-string (randint 10000000000000 10000000000000000))
|
||||||
set-env POSH_THEME '::CONFIG::'
|
set-env POSH_THEME '::CONFIG::'
|
||||||
|
set-env POSH_SHELL_VERSION (elvish --version)
|
||||||
set-env POWERLINE_COMMAND 'oh-my-posh'
|
set-env POWERLINE_COMMAND 'oh-my-posh'
|
||||||
set-env ELVISH_VERSION (elvish --version)
|
|
||||||
|
|
||||||
var error-code = 0
|
var error-code = 0
|
||||||
|
|
||||||
|
@ -23,12 +23,12 @@ set edit:after-command = [ $@edit:after-command $posh-after-command-hook~ ]
|
||||||
|
|
||||||
set edit:prompt = {
|
set edit:prompt = {
|
||||||
var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000))
|
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 = {
|
set edit:rprompt = {
|
||||||
var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000))
|
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') {
|
if (eq '::UPGRADE::' 'true') {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
set --export POSH_THEME ::CONFIG::
|
set --export POSH_THEME ::CONFIG::
|
||||||
|
set --export POSH_SHELL_VERSION $FISH_VERSION
|
||||||
set --global POWERLINE_COMMAND "oh-my-posh"
|
set --global POWERLINE_COMMAND "oh-my-posh"
|
||||||
set --global POSH_PID $fish_pid
|
set --global POSH_PID $fish_pid
|
||||||
set --global CONDA_PROMPT_MODIFIER false
|
set --global CONDA_PROMPT_MODIFIER false
|
||||||
|
|
|
@ -75,6 +75,7 @@ local function omp_config()
|
||||||
end
|
end
|
||||||
|
|
||||||
os.setenv("POSH_THEME", ::CONFIG::)
|
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
|
-- Execution helpers
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ export-env {
|
||||||
# making it annoying when you have a multiline prompt
|
# making it annoying when you have a multiline prompt
|
||||||
# making the behavior different compared to other shells
|
# making the behavior different compared to other shells
|
||||||
let-env PROMPT_COMMAND_RIGHT = {''}
|
let-env PROMPT_COMMAND_RIGHT = {''}
|
||||||
let-env NU_VERSION = (version | get version)
|
let-env POSH_SHELL_VERSION = (version | get version)
|
||||||
|
|
||||||
# PROMPTS
|
# 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 = {
|
let-env PROMPT_COMMAND = {
|
||||||
# We have to do this because the initial value of `$env.CMD_DURATION_MS` is always `0823`,
|
# 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 clear = (history | last 1 | get 0.command) == "clear"
|
||||||
|
|
||||||
let width = ((term size).columns | into string)
|
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)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
||||||
$script:TransientPrompt = $false
|
$script:TransientPrompt = $false
|
||||||
$script:ToolTipCommand = ""
|
$script:ToolTipCommand = ""
|
||||||
$env:POWERLINE_COMMAND = "oh-my-posh"
|
$env:POWERLINE_COMMAND = "oh-my-posh"
|
||||||
|
$env:POSH_SHELL_VERSION = $script:PSVersion
|
||||||
$env:POSH_PID = $PID
|
$env:POSH_PID = $PID
|
||||||
$env:CONDA_PROMPT_MODIFIER = $false
|
$env:CONDA_PROMPT_MODIFIER = $false
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ import uuid
|
||||||
$POWERLINE_COMMAND = "oh-my-posh"
|
$POWERLINE_COMMAND = "oh-my-posh"
|
||||||
$POSH_THEME = "::CONFIG::"
|
$POSH_THEME = "::CONFIG::"
|
||||||
$POSH_PID = uuid.uuid4().hex
|
$POSH_PID = uuid.uuid4().hex
|
||||||
|
$POSH_SHELL_VERSION = ""
|
||||||
|
|
||||||
def get_command_context():
|
def get_command_context():
|
||||||
last_cmd = __xonsh__.history[-1] if __xonsh__.history else None
|
last_cmd = __xonsh__.history[-1] if __xonsh__.history else None
|
||||||
|
|
|
@ -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_VERSION "";
|
||||||
|
|
||||||
set USER_PRECMD = "`alias precmd`";
|
set USER_PRECMD = "`alias precmd`";
|
||||||
set USER_POSTCMD = "`alias postcmd`";
|
set USER_POSTCMD = "`alias postcmd`";
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
export POSH_THEME=::CONFIG::
|
export POSH_THEME=::CONFIG::
|
||||||
|
export POSH_SHELL_VERSION=$ZSH_VERSION
|
||||||
export POSH_PID=$$
|
export POSH_PID=$$
|
||||||
export POWERLINE_COMMAND="oh-my-posh"
|
export POWERLINE_COMMAND="oh-my-posh"
|
||||||
export CONDA_PROMPT_MODIFIER=false
|
export CONDA_PROMPT_MODIFIER=false
|
||||||
|
|
Loading…
Reference in a new issue