mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 20:09:39 -08:00
fix: provide terminal width from CLI
This commit is contained in:
parent
8f3bfd674b
commit
4c4b97fa8b
|
@ -47,10 +47,10 @@ Tell the engine if the block should be left or right-aligned.
|
|||
### Filler
|
||||
|
||||
When you want to join a right and left aligned block with a repeated set of characters, add the character
|
||||
to be repeated to this property. Add this property to the _left_ aligned block.
|
||||
to be repeated to this property. Add this property to the _right_ aligned block.
|
||||
|
||||
```json
|
||||
"alignment": "left",
|
||||
"alignment": "right",
|
||||
"filler": "."
|
||||
```
|
||||
|
||||
|
|
|
@ -89,7 +89,8 @@ function global:Initialize-ModuleSupport {
|
|||
$executionTime = ($history.EndExecutionTime - $history.StartExecutionTime).TotalMilliseconds
|
||||
$global:omp_lastHistoryId = $history.Id
|
||||
}
|
||||
$standardOut = @(&$omp --error="$errorCode" --pwd="$cleanPWD" --pswd="$cleanPSWD" --execution-time="$executionTime" --stack-count="$stackCount" --config="$config" 2>&1)
|
||||
$terminalWidth = $Host.UI.RawUI.WindowSize.Width
|
||||
$standardOut = @(&$omp --error="$errorCode" --pwd="$cleanPWD" --pswd="$cleanPSWD" --execution-time="$executionTime" --stack-count="$stackCount" --config="$config" --terminal-width=$terminalWidth 2>&1)
|
||||
# make sure PSReadLine knows we have a multiline prompt
|
||||
$extraLines = $standardOut.Count - 1
|
||||
if ($extraLines -gt 0) {
|
||||
|
|
|
@ -56,6 +56,7 @@ type Args struct {
|
|||
CachePath *bool
|
||||
Migrate *bool
|
||||
Write *bool
|
||||
TerminalWidth *int
|
||||
}
|
||||
|
||||
type CommandError struct {
|
||||
|
|
|
@ -45,9 +45,12 @@ func (env *ShellEnvironment) IsWsl2() bool {
|
|||
|
||||
func (env *ShellEnvironment) TerminalWidth() (int, error) {
|
||||
defer env.trace(time.Now(), "TerminalWidth")
|
||||
if *env.args.TerminalWidth != 0 {
|
||||
return *env.args.TerminalWidth, nil
|
||||
}
|
||||
width, err := terminal.Width()
|
||||
if err != nil {
|
||||
env.log(Error, "RunCommand", err.Error())
|
||||
env.log(Error, "TerminalWidth", err.Error())
|
||||
}
|
||||
return int(width), err
|
||||
}
|
||||
|
|
|
@ -86,6 +86,9 @@ func (env *ShellEnvironment) IsWsl2() bool {
|
|||
|
||||
func (env *ShellEnvironment) TerminalWidth() (int, error) {
|
||||
defer env.trace(time.Now(), "TerminalWidth")
|
||||
if *env.args.TerminalWidth != 0 {
|
||||
return *env.args.TerminalWidth, nil
|
||||
}
|
||||
handle, err := syscall.Open("CONOUT$", syscall.O_RDWR, 0)
|
||||
if err != nil {
|
||||
env.log(Error, "TerminalWidth", err.Error())
|
||||
|
|
|
@ -129,6 +129,10 @@ func main() {
|
|||
"write",
|
||||
false,
|
||||
"Write the config to the file"),
|
||||
TerminalWidth: flag.Int(
|
||||
"terminal-width",
|
||||
0,
|
||||
"The width of the terminal"),
|
||||
}
|
||||
flag.Parse()
|
||||
if *args.Version {
|
||||
|
|
Loading…
Reference in a new issue