mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
fix(cache): use UUIDs as session IDs
This commit is contained in:
parent
4a81b111a0
commit
4104a9a633
4
src/cache/cache.go
vendored
4
src/cache/cache.go
vendored
|
@ -30,9 +30,9 @@ const (
|
||||||
var SessionFileName = fmt.Sprintf("%s.%s", FileName, sessionID())
|
var SessionFileName = fmt.Sprintf("%s.%s", FileName, sessionID())
|
||||||
|
|
||||||
func sessionID() string {
|
func sessionID() string {
|
||||||
pid := os.Getenv("POSH_PID")
|
pid := os.Getenv("POSH_SESSION_ID")
|
||||||
if len(pid) == 0 {
|
if len(pid) == 0 {
|
||||||
log.Debug("POSH_PID not set, using process pid")
|
log.Debug("POSH_SESSION_ID not set, using PID")
|
||||||
pid = strconv.Itoa(os.Getppid())
|
pid = strconv.Itoa(os.Getppid())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ require (
|
||||||
github.com/alecthomas/repr v0.4.0 // indirect
|
github.com/alecthomas/repr v0.4.0 // indirect
|
||||||
github.com/esimov/stackblur-go v1.1.0
|
github.com/esimov/stackblur-go v1.1.0
|
||||||
github.com/fogleman/gg v1.3.0
|
github.com/fogleman/gg v1.3.0
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0
|
||||||
github.com/gookit/color v1.5.4
|
github.com/gookit/color v1.5.4
|
||||||
github.com/huandu/xstrings v1.5.0 // indirect
|
github.com/huandu/xstrings v1.5.0 // indirect
|
||||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/jandedobbeleer/oh-my-posh/src/log"
|
"github.com/jandedobbeleer/oh-my-posh/src/log"
|
||||||
"github.com/jandedobbeleer/oh-my-posh/src/runtime"
|
"github.com/jandedobbeleer/oh-my-posh/src/runtime"
|
||||||
)
|
)
|
||||||
|
@ -80,6 +81,7 @@ func PrintInit(env runtime.Environment, features Features, startTime *time.Time)
|
||||||
|
|
||||||
shell := env.Flags().Shell
|
shell := env.Flags().Shell
|
||||||
configFile := env.Flags().Config
|
configFile := env.Flags().Config
|
||||||
|
sessionID := uuid.NewString()
|
||||||
|
|
||||||
var script string
|
var script string
|
||||||
|
|
||||||
|
@ -87,38 +89,47 @@ func PrintInit(env runtime.Environment, features Features, startTime *time.Time)
|
||||||
case PWSH, PWSH5:
|
case PWSH, PWSH5:
|
||||||
executable = quotePwshOrElvishStr(executable)
|
executable = quotePwshOrElvishStr(executable)
|
||||||
configFile = quotePwshOrElvishStr(configFile)
|
configFile = quotePwshOrElvishStr(configFile)
|
||||||
|
sessionID = quotePwshOrElvishStr(sessionID)
|
||||||
script = pwshInit
|
script = pwshInit
|
||||||
case ZSH:
|
case ZSH:
|
||||||
executable = QuotePosixStr(executable)
|
executable = QuotePosixStr(executable)
|
||||||
configFile = QuotePosixStr(configFile)
|
configFile = QuotePosixStr(configFile)
|
||||||
|
sessionID = QuotePosixStr(sessionID)
|
||||||
script = zshInit
|
script = zshInit
|
||||||
case BASH:
|
case BASH:
|
||||||
executable = QuotePosixStr(executable)
|
executable = QuotePosixStr(executable)
|
||||||
configFile = QuotePosixStr(configFile)
|
configFile = QuotePosixStr(configFile)
|
||||||
|
sessionID = QuotePosixStr(sessionID)
|
||||||
script = bashInit
|
script = bashInit
|
||||||
case FISH:
|
case FISH:
|
||||||
executable = quoteFishStr(executable)
|
executable = quoteFishStr(executable)
|
||||||
configFile = quoteFishStr(configFile)
|
configFile = quoteFishStr(configFile)
|
||||||
|
sessionID = quoteFishStr(sessionID)
|
||||||
script = fishInit
|
script = fishInit
|
||||||
case CMD:
|
case CMD:
|
||||||
executable = escapeLuaStr(executable)
|
executable = escapeLuaStr(executable)
|
||||||
configFile = escapeLuaStr(configFile)
|
configFile = escapeLuaStr(configFile)
|
||||||
|
sessionID = escapeLuaStr(sessionID)
|
||||||
script = cmdInit
|
script = cmdInit
|
||||||
case NU:
|
case NU:
|
||||||
executable = quoteNuStr(executable)
|
executable = quoteNuStr(executable)
|
||||||
configFile = quoteNuStr(configFile)
|
configFile = quoteNuStr(configFile)
|
||||||
|
sessionID = quoteNuStr(sessionID)
|
||||||
script = nuInit
|
script = nuInit
|
||||||
case TCSH:
|
case TCSH:
|
||||||
executable = quoteCshStr(executable)
|
executable = quoteCshStr(executable)
|
||||||
configFile = quoteCshStr(configFile)
|
configFile = quoteCshStr(configFile)
|
||||||
|
sessionID = quoteCshStr(sessionID)
|
||||||
script = tcshInit
|
script = tcshInit
|
||||||
case ELVISH:
|
case ELVISH:
|
||||||
executable = quotePwshOrElvishStr(executable)
|
executable = quotePwshOrElvishStr(executable)
|
||||||
configFile = quotePwshOrElvishStr(configFile)
|
configFile = quotePwshOrElvishStr(configFile)
|
||||||
|
sessionID = quotePwshOrElvishStr(sessionID)
|
||||||
script = elvishInit
|
script = elvishInit
|
||||||
case XONSH:
|
case XONSH:
|
||||||
executable = quotePythonStr(executable)
|
executable = quotePythonStr(executable)
|
||||||
configFile = quotePythonStr(configFile)
|
configFile = quotePythonStr(configFile)
|
||||||
|
sessionID = quotePythonStr(sessionID)
|
||||||
script = xonshInit
|
script = xonshInit
|
||||||
default:
|
default:
|
||||||
return fmt.Sprintf("echo \"No initialization script available for %s\"", shell)
|
return fmt.Sprintf("echo \"No initialization script available for %s\"", shell)
|
||||||
|
@ -128,6 +139,7 @@ func PrintInit(env runtime.Environment, features Features, startTime *time.Time)
|
||||||
"::OMP::", executable,
|
"::OMP::", executable,
|
||||||
"::CONFIG::", configFile,
|
"::CONFIG::", configFile,
|
||||||
"::SHELL::", shell,
|
"::SHELL::", shell,
|
||||||
|
"::SESSION_ID::", sessionID,
|
||||||
).Replace(script)
|
).Replace(script)
|
||||||
|
|
||||||
shellScript := features.Lines(shell).String(init)
|
shellScript := features.Lines(shell).String(init)
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
export POSH_THEME=::CONFIG::
|
export POSH_THEME=::CONFIG::
|
||||||
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_PID=$$
|
export POSH_SESSION_ID=::SESSION_ID::
|
||||||
export CONDA_PROMPT_MODIFIER=false
|
export CONDA_PROMPT_MODIFIER=false
|
||||||
export OSTYPE=$OSTYPE
|
export OSTYPE=$OSTYPE
|
||||||
|
|
||||||
if [[ $OSTYPE =~ ^(msys|cygwin) ]]; then
|
|
||||||
export POSH_PID=$(command cat /proc/$$/winpid)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# global variables
|
# global variables
|
||||||
_omp_start_time=''
|
_omp_start_time=''
|
||||||
_omp_stack_count=0
|
_omp_stack_count=0
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
set-env POSH_PID (to-string (randint 10000000000000 10000000000000000))
|
set-env POSH_SESSION_ID ::SESSION_ID::
|
||||||
set-env POSH_THEME ::CONFIG::
|
set-env POSH_THEME ::CONFIG::
|
||||||
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,16 +1,12 @@
|
||||||
set --export POSH_THEME ::CONFIG::
|
set --export POSH_THEME ::CONFIG::
|
||||||
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_PID $fish_pid
|
set --export POSH_SESSION_ID ::SESSION_ID::
|
||||||
set --export CONDA_PROMPT_MODIFIER false
|
set --export CONDA_PROMPT_MODIFIER false
|
||||||
|
|
||||||
set --global _omp_tooltip_command ''
|
set --global _omp_tooltip_command ''
|
||||||
set --global _omp_current_rprompt ''
|
set --global _omp_current_rprompt ''
|
||||||
set --global _omp_transient 0
|
set --global _omp_transient 0
|
||||||
|
|
||||||
if command uname -s | string match -qr '^(CYGWIN|MSYS|MINGW)'
|
|
||||||
set --export POSH_PID (command cat /proc/$fish_pid/winpid)
|
|
||||||
end
|
|
||||||
|
|
||||||
set --global _omp_executable ::OMP::
|
set --global _omp_executable ::OMP::
|
||||||
set --global _omp_ftcs_marks 0
|
set --global _omp_ftcs_marks 0
|
||||||
set --global _omp_transient_prompt 0
|
set --global _omp_transient_prompt 0
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
---@diagnostic disable: lowercase-global
|
---@diagnostic disable: lowercase-global
|
||||||
|
|
||||||
-- Cache PID
|
-- Cache PID
|
||||||
os.setenv('POSH_PID', os.getpid())
|
os.setenv('POSH_SESSION_ID', '::SESSION_ID::')
|
||||||
|
|
||||||
-- Helper functions
|
-- Helper functions
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ if ($env.config? | is-not-empty) {
|
||||||
$env.POWERLINE_COMMAND = 'oh-my-posh'
|
$env.POWERLINE_COMMAND = 'oh-my-posh'
|
||||||
$env.POSH_THEME = (echo ::CONFIG::)
|
$env.POSH_THEME = (echo ::CONFIG::)
|
||||||
$env.PROMPT_INDICATOR = ""
|
$env.PROMPT_INDICATOR = ""
|
||||||
$env.POSH_PID = (random uuid)
|
$env.POSH_SESSION_ID = (echo ::SESSION_ID::)
|
||||||
$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::)
|
||||||
|
|
|
@ -40,7 +40,7 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
||||||
|
|
||||||
$env:POWERLINE_COMMAND = "oh-my-posh"
|
$env:POWERLINE_COMMAND = "oh-my-posh"
|
||||||
$env:POSH_SHELL_VERSION = $script:PSVersion
|
$env:POSH_SHELL_VERSION = $script:PSVersion
|
||||||
$env:POSH_PID = $PID
|
$env:POSH_SESSION_ID = ::SESSION_ID::
|
||||||
$env:CONDA_PROMPT_MODIFIER = $false
|
$env:CONDA_PROMPT_MODIFIER = $false
|
||||||
|
|
||||||
# set the default theme
|
# set the default theme
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
setenv POWERLINE_COMMAND "oh-my-posh";
|
setenv POWERLINE_COMMAND "oh-my-posh";
|
||||||
setenv POSH_THEME ::CONFIG::;
|
setenv POSH_THEME ::CONFIG::;
|
||||||
setenv POSH_SHELL_VERSION "$tcsh";
|
setenv POSH_SHELL_VERSION "$tcsh";
|
||||||
setenv POSH_PID $$;
|
setenv POSH_SESSION_ID ::SESSION_ID::;
|
||||||
setenv OSTYPE "$OSTYPE";
|
setenv OSTYPE "$OSTYPE";
|
||||||
|
|
||||||
if ( "$OSTYPE" =~ {msys,cygwin}* ) setenv POSH_PID "`cat /proc/$$/winpid`";
|
|
||||||
|
|
||||||
if ( ! $?_omp_enabled ) alias precmd '
|
if ( ! $?_omp_enabled ) alias precmd '
|
||||||
set _omp_status = $status;
|
set _omp_status = $status;
|
||||||
set _omp_execution_time = -1;
|
set _omp_execution_time = -1;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import uuid
|
|
||||||
|
|
||||||
$POWERLINE_COMMAND = "oh-my-posh"
|
$POWERLINE_COMMAND = "oh-my-posh"
|
||||||
$POSH_THEME = ::CONFIG::
|
$POSH_THEME = ::CONFIG::
|
||||||
$POSH_PID = uuid.uuid4().hex
|
$POSH_SESSION_ID = ::SESSION_ID::
|
||||||
$POSH_SHELL_VERSION = $XONSH_VERSION
|
$POSH_SHELL_VERSION = $XONSH_VERSION
|
||||||
|
|
||||||
_omp_executable = ::OMP::
|
_omp_executable = ::OMP::
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
export POSH_THEME=::CONFIG::
|
export POSH_THEME=::CONFIG::
|
||||||
export POSH_SHELL_VERSION=$ZSH_VERSION
|
export POSH_SHELL_VERSION=$ZSH_VERSION
|
||||||
export POSH_PID=$$
|
export POSH_SESSION_ID=::SESSION_ID::
|
||||||
export POWERLINE_COMMAND='oh-my-posh'
|
export POWERLINE_COMMAND='oh-my-posh'
|
||||||
export CONDA_PROMPT_MODIFIER=false
|
export CONDA_PROMPT_MODIFIER=false
|
||||||
export ZLE_RPROMPT_INDENT=0
|
export ZLE_RPROMPT_INDENT=0
|
||||||
export OSTYPE=$OSTYPE
|
export OSTYPE=$OSTYPE
|
||||||
|
|
||||||
if [[ $OSTYPE =~ ^(msys|cygwin) ]]; then
|
|
||||||
export POSH_PID=$(command cat /proc/$$/winpid)
|
|
||||||
fi
|
|
||||||
|
|
||||||
_omp_executable=::OMP::
|
_omp_executable=::OMP::
|
||||||
_omp_tooltip_command=''
|
_omp_tooltip_command=''
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue