mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-31 22:07:25 -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.Transient = cfg.TransientPrompt != nil
|
||||||
shell.ErrorLine = cfg.ErrorLine != nil || cfg.ValidLine != nil
|
shell.ErrorLine = cfg.ErrorLine != nil || cfg.ValidLine != nil
|
||||||
shell.Tooltips = len(cfg.Tooltips) > 0
|
shell.Tooltips = len(cfg.Tooltips) > 0
|
||||||
|
for _, block := range cfg.Blocks {
|
||||||
|
if block.Type == engine.RPrompt {
|
||||||
|
shell.RPrompt = true
|
||||||
|
}
|
||||||
|
}
|
||||||
if print {
|
if print {
|
||||||
init := shell.PrintInit(env)
|
init := shell.PrintInit(env)
|
||||||
fmt.Print(init)
|
fmt.Print(init)
|
||||||
|
|
|
@ -38,6 +38,7 @@ var (
|
||||||
Transient bool
|
Transient bool
|
||||||
ErrorLine bool
|
ErrorLine bool
|
||||||
Tooltips bool
|
Tooltips bool
|
||||||
|
RPrompt bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func getExecutablePath(env platform.Environment) (string, error) {
|
func getExecutablePath(env platform.Environment) (string, error) {
|
||||||
|
@ -225,6 +226,7 @@ func PrintInit(env platform.Environment) string {
|
||||||
"::TRANSIENT::", toggleSetting(Transient),
|
"::TRANSIENT::", toggleSetting(Transient),
|
||||||
"::ERROR_LINE::", toggleSetting(ErrorLine),
|
"::ERROR_LINE::", toggleSetting(ErrorLine),
|
||||||
"::TOOLTIPS::", toggleSetting(Tooltips),
|
"::TOOLTIPS::", toggleSetting(Tooltips),
|
||||||
|
"::RPROMPT::", strconv.FormatBool(RPrompt),
|
||||||
).Replace(script)
|
).Replace(script)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,7 @@ end
|
||||||
local endedit_time = 0
|
local endedit_time = 0
|
||||||
local last_duration = 0
|
local last_duration = 0
|
||||||
local tooltips_enabled = ::TOOLTIPS::
|
local tooltips_enabled = ::TOOLTIPS::
|
||||||
local rprompt_enabled = true
|
local rprompt_enabled = ::RPROMPT::
|
||||||
-- 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 cached_prompt = {}
|
local cached_prompt = {}
|
||||||
-- Fields in cached_prompt:
|
-- Fields in cached_prompt:
|
||||||
|
@ -232,9 +229,6 @@ function p:rightfilter(prompt)
|
||||||
return (cached_prompt.tooltip or cached_prompt.right), false
|
return (cached_prompt.tooltip or cached_prompt.right), false
|
||||||
end
|
end
|
||||||
function p:transientfilter(prompt)
|
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())
|
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)
|
prompt = run_posh_command(prompt_exe)
|
||||||
if prompt == "" then
|
if prompt == "" then
|
||||||
|
|
Loading…
Reference in a new issue