mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-26 19:39:39 -08:00
feat(cmd): transient prompt
This commit is contained in:
parent
5ddb0d8896
commit
79c5ad845f
|
@ -8,7 +8,7 @@ import Tabs from "@theme/Tabs";
|
|||
import TabItem from "@theme/TabItem";
|
||||
|
||||
:::info
|
||||
This feature only works in `zsh` and `powershell` for the time being.
|
||||
This feature only works in `zsh`, `powershell` and `cmd` for the time being.
|
||||
:::
|
||||
|
||||
Transient prompt, when enabled, replaces the prompt with a simpler one to allow more screen real estate.
|
||||
|
@ -66,6 +66,7 @@ properties below. Defaults to `{{ .Shell }}> `
|
|||
groupId="shell"
|
||||
values={[
|
||||
{ label: 'powershell', value: 'pwsh', },
|
||||
{ label: 'cmd', value: 'cmd', },
|
||||
{ label: 'zsh', value: 'zsh', },
|
||||
]
|
||||
}>
|
||||
|
@ -80,6 +81,17 @@ Enable-PoshTransientPrompt
|
|||
|
||||
Restart your shell or reload your `$PROFILE` using `. $PROFILE` for the changes to take effect.
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="cmd">
|
||||
|
||||
Set the transient prompt in [clink][clink] to `always` in the `oh-my-posh.lua` script to enable the feature:
|
||||
|
||||
```shell
|
||||
clink set prompt.transient always
|
||||
```
|
||||
|
||||
Restart your shell for the changes to take effect.
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="zsh">
|
||||
|
||||
|
@ -98,3 +110,4 @@ Restart your shell or reload `.zshrc` using `source ~/.zshrc` for the changes to
|
|||
[go-text-template]: https://golang.org/pkg/text/template/
|
||||
[console-title]: /docs/config-title#console-title-template
|
||||
[sprig]: https://masterminds.github.io/sprig/
|
||||
[clink]: https://chrisant996.github.io/clink/
|
||||
|
|
|
@ -253,7 +253,7 @@ func (e *engine) renderTransientPrompt() string {
|
|||
prompt := fmt.Sprintf("PS1=\"%s\"", strings.ReplaceAll(e.writer.string(), "\"", "\"\""))
|
||||
prompt += "\nRPROMPT=\"\""
|
||||
return prompt
|
||||
case pwsh, powershell5:
|
||||
case pwsh, powershell5, winCMD:
|
||||
return e.writer.string()
|
||||
}
|
||||
return ""
|
||||
|
|
|
@ -47,7 +47,7 @@ local function error_level_option()
|
|||
end
|
||||
|
||||
local function get_posh_prompt(rprompt)
|
||||
local prompt_exe = string.format('::OMP:: --config="::CONFIG::" %s %s --rprompt=%s', execution_time_option(), error_level_option(), rprompt)
|
||||
local prompt_exe = string.format('::OMP:: --shell=cmd --config="::CONFIG::" %s %s --rprompt=%s', execution_time_option(), error_level_option(), rprompt)
|
||||
prompt = io.popen(prompt_exe):read("*a")
|
||||
return prompt
|
||||
end
|
||||
|
@ -60,13 +60,23 @@ function p:rightfilter(prompt)
|
|||
if tip_word == nil then
|
||||
return get_posh_prompt(true), false
|
||||
end
|
||||
local prompt_exe = string.format('::OMP:: --config="::CONFIG::" --command="%s"', tip_word)
|
||||
local prompt_exe = string.format('::OMP:: --shell=cmd --config="::CONFIG::" --command="%s"', tip_word)
|
||||
tooltip = io.popen(prompt_exe):read("*a")
|
||||
if tooltip ~= "" then
|
||||
return tooltip, false
|
||||
end
|
||||
return get_posh_prompt(true), false
|
||||
end
|
||||
function p:transientfilter(prompt)
|
||||
prompt = io.popen('::OMP:: --shell=cmd --config="::CONFIG::" --print-transient'):read("*a")
|
||||
if prompt == "" then
|
||||
prompt = nil
|
||||
end
|
||||
return prompt
|
||||
end
|
||||
function p:transientrightfilter(prompt)
|
||||
return "", false
|
||||
end
|
||||
|
||||
-- Event handlers
|
||||
|
||||
|
|
Loading…
Reference in a new issue