fix(pid): cache PID from init

resolves #3096
This commit is contained in:
Jan De Dobbeleer 2022-11-19 22:35:13 +01:00 committed by Jan De Dobbeleer
parent 40a065da5a
commit 0d8b8591cc
7 changed files with 16 additions and 4 deletions

View file

@ -44,7 +44,7 @@ var toggleCmd = &cobra.Command{
newToggles = append(newToggles, segment)
}
cache.Set(platform.TOGGLECACHE, strings.Join(newToggles, ","), -1)
cache.Set(platform.TOGGLECACHE, strings.Join(newToggles, ","), 1440)
},
}

View file

@ -35,11 +35,18 @@ const (
LINUX = "linux"
)
func getPID() string {
pid := os.Getenv("POSH_PID")
if len(pid) == 0 {
pid = strconv.Itoa(os.Getppid())
}
return pid
}
var (
pid = os.Getppid()
lock = sync.RWMutex{}
TEMPLATECACHE = fmt.Sprintf("template_cache_%d", pid)
TOGGLECACHE = fmt.Sprintf("toggle_cache_%d", pid)
TEMPLATECACHE = fmt.Sprintf("template_cache_%s", getPID())
TOGGLECACHE = fmt.Sprintf("toggle_cache_%s", getPID())
)
type Flags struct {

View file

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

View file

@ -1,5 +1,6 @@
set --export POSH_THEME ::CONFIG::
set --global POWERLINE_COMMAND "oh-my-posh"
set --global POSH_PID $fish_pid
set --global CONDA_PROMPT_MODIFIER false
set --global omp_tooltip_prompt ""
set --global has_omp_tooltip false

View file

@ -2,6 +2,7 @@ export-env {
let-env POWERLINE_COMMAND = 'oh-my-posh'
let-env POSH_THEME = ::CONFIG::
let-env PROMPT_INDICATOR = ""
let-env POSH_PID = (random uuid)
# By default displays the right prompt on the first line
# making it annoying when you have a multiline prompt
# making the behavior different compared to other shells

View file

@ -21,6 +21,7 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
$script:PSVersion = $PSVersionTable.PSVersion.ToString()
$script:TransientPrompt = $false
$env:POWERLINE_COMMAND = "oh-my-posh"
$env:POSH_PID = $PID
$env:CONDA_PROMPT_MODIFIER = $false
if ((::CONFIG:: -ne '') -and (Test-Path -LiteralPath ::CONFIG::)) {
$env:POSH_THEME = (Resolve-Path -Path ::CONFIG::).ProviderPath

View file

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