diff --git a/src/cli/toggle.go b/src/cli/toggle.go index abcc60e5..55e8f1c7 100644 --- a/src/cli/toggle.go +++ b/src/cli/toggle.go @@ -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) }, } diff --git a/src/platform/shell.go b/src/platform/shell.go index 01da8dc2..f7519662 100644 --- a/src/platform/shell.go +++ b/src/platform/shell.go @@ -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 { diff --git a/src/shell/scripts/omp.bash b/src/shell/scripts/omp.bash index b189db1c..2adce612 100644 --- a/src/shell/scripts/omp.bash +++ b/src/shell/scripts/omp.bash @@ -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="" diff --git a/src/shell/scripts/omp.fish b/src/shell/scripts/omp.fish index 62f41d44..cffdbff7 100644 --- a/src/shell/scripts/omp.fish +++ b/src/shell/scripts/omp.fish @@ -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 diff --git a/src/shell/scripts/omp.nu b/src/shell/scripts/omp.nu index c59c39c6..eac85b65 100644 --- a/src/shell/scripts/omp.nu +++ b/src/shell/scripts/omp.nu @@ -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 diff --git a/src/shell/scripts/omp.ps1 b/src/shell/scripts/omp.ps1 index fc5f9414..24d16aeb 100644 --- a/src/shell/scripts/omp.ps1 +++ b/src/shell/scripts/omp.ps1 @@ -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 diff --git a/src/shell/scripts/omp.zsh b/src/shell/scripts/omp.zsh index 3fe21c42..97cf9d7a 100644 --- a/src/shell/scripts/omp.zsh +++ b/src/shell/scripts/omp.zsh @@ -1,4 +1,5 @@ export POSH_THEME=::CONFIG:: +export POSH_PID=$$ export POWERLINE_COMMAND="oh-my-posh" export CONDA_PROMPT_MODIFIER=false