mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 20:39:40 -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
|
### Filler
|
||||||
|
|
||||||
When you want to join a right and left aligned block with a repeated set of characters, add the character
|
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
|
```json
|
||||||
"alignment": "left",
|
"alignment": "right",
|
||||||
"filler": "."
|
"filler": "."
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,8 @@ function global:Initialize-ModuleSupport {
|
||||||
$executionTime = ($history.EndExecutionTime - $history.StartExecutionTime).TotalMilliseconds
|
$executionTime = ($history.EndExecutionTime - $history.StartExecutionTime).TotalMilliseconds
|
||||||
$global:omp_lastHistoryId = $history.Id
|
$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
|
# make sure PSReadLine knows we have a multiline prompt
|
||||||
$extraLines = $standardOut.Count - 1
|
$extraLines = $standardOut.Count - 1
|
||||||
if ($extraLines -gt 0) {
|
if ($extraLines -gt 0) {
|
||||||
|
|
|
@ -56,6 +56,7 @@ type Args struct {
|
||||||
CachePath *bool
|
CachePath *bool
|
||||||
Migrate *bool
|
Migrate *bool
|
||||||
Write *bool
|
Write *bool
|
||||||
|
TerminalWidth *int
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommandError struct {
|
type CommandError struct {
|
||||||
|
|
|
@ -45,9 +45,12 @@ func (env *ShellEnvironment) IsWsl2() bool {
|
||||||
|
|
||||||
func (env *ShellEnvironment) TerminalWidth() (int, error) {
|
func (env *ShellEnvironment) TerminalWidth() (int, error) {
|
||||||
defer env.trace(time.Now(), "TerminalWidth")
|
defer env.trace(time.Now(), "TerminalWidth")
|
||||||
|
if *env.args.TerminalWidth != 0 {
|
||||||
|
return *env.args.TerminalWidth, nil
|
||||||
|
}
|
||||||
width, err := terminal.Width()
|
width, err := terminal.Width()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.log(Error, "RunCommand", err.Error())
|
env.log(Error, "TerminalWidth", err.Error())
|
||||||
}
|
}
|
||||||
return int(width), err
|
return int(width), err
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,9 @@ func (env *ShellEnvironment) IsWsl2() bool {
|
||||||
|
|
||||||
func (env *ShellEnvironment) TerminalWidth() (int, error) {
|
func (env *ShellEnvironment) TerminalWidth() (int, error) {
|
||||||
defer env.trace(time.Now(), "TerminalWidth")
|
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)
|
handle, err := syscall.Open("CONOUT$", syscall.O_RDWR, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.log(Error, "TerminalWidth", err.Error())
|
env.log(Error, "TerminalWidth", err.Error())
|
||||||
|
|
|
@ -129,6 +129,10 @@ func main() {
|
||||||
"write",
|
"write",
|
||||||
false,
|
false,
|
||||||
"Write the config to the file"),
|
"Write the config to the file"),
|
||||||
|
TerminalWidth: flag.Int(
|
||||||
|
"terminal-width",
|
||||||
|
0,
|
||||||
|
"The width of the terminal"),
|
||||||
}
|
}
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if *args.Version {
|
if *args.Version {
|
||||||
|
|
Loading…
Reference in a new issue