mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 13:04:04 -08:00
feat(cmd): toggle rprompt from configuration
This commit is contained in:
parent
450ee25f77
commit
877ac59f5f
|
@ -64,6 +64,11 @@ func runInit(shellName string) {
|
|||
shell.Transient = cfg.TransientPrompt != nil
|
||||
shell.ErrorLine = cfg.ErrorLine != nil || cfg.ValidLine != nil
|
||||
shell.Tooltips = len(cfg.Tooltips) > 0
|
||||
for _, block := range cfg.Blocks {
|
||||
if block.Type == engine.RPrompt {
|
||||
shell.RPrompt = true
|
||||
}
|
||||
}
|
||||
if print {
|
||||
init := shell.PrintInit(env)
|
||||
fmt.Print(init)
|
||||
|
|
|
@ -38,6 +38,7 @@ var (
|
|||
Transient bool
|
||||
ErrorLine bool
|
||||
Tooltips bool
|
||||
RPrompt bool
|
||||
)
|
||||
|
||||
func getExecutablePath(env platform.Environment) (string, error) {
|
||||
|
@ -225,6 +226,7 @@ func PrintInit(env platform.Environment) string {
|
|||
"::TRANSIENT::", toggleSetting(Transient),
|
||||
"::ERROR_LINE::", toggleSetting(ErrorLine),
|
||||
"::TOOLTIPS::", toggleSetting(Tooltips),
|
||||
"::RPROMPT::", strconv.FormatBool(RPrompt),
|
||||
).Replace(script)
|
||||
}
|
||||
|
||||
|
|
|
@ -23,10 +23,7 @@ end
|
|||
local endedit_time = 0
|
||||
local last_duration = 0
|
||||
local tooltips_enabled = ::TOOLTIPS::
|
||||
local rprompt_enabled = true
|
||||
-- REVIEW: OMP could set rprompt_enabled = ::HASRPROMPT:: which could speed up
|
||||
-- performance for configs that don't have an rprompt, by not needing to invoke
|
||||
-- OMP an extra time for the rprompt.
|
||||
local rprompt_enabled = ::RPROMPT::
|
||||
|
||||
local cached_prompt = {}
|
||||
-- Fields in cached_prompt:
|
||||
|
@ -232,9 +229,6 @@ function p:rightfilter(prompt)
|
|||
return (cached_prompt.tooltip or cached_prompt.right), false
|
||||
end
|
||||
function p:transientfilter(prompt)
|
||||
-- REVIEW: this can potentially be expensive and noticable for users; consider
|
||||
-- optimizing this so the Lua script can natively generate the transient prompt
|
||||
-- when feasible.
|
||||
local prompt_exe = string.format('%s print transient --shell=cmd --config=%s %s', omp_exe(), omp_config(), error_level_option())
|
||||
prompt = run_posh_command(prompt_exe)
|
||||
if prompt == "" then
|
||||
|
|
Loading…
Reference in a new issue