Add support for linux 'watch' command
xsilas opened this issue · comments
The linux watch command is used to run a command at an interval and display the output of the command in a refreshing terminal.
In my case i try to display a table from the pterm lib using the watch command but it seems like something with the encoding is getting messed up.
My code looks somehow like this:
func test() error {
tableData := pterm.TableData{
{"Firstname", "Lastname", "Email"},
{"Paul", "Dean", "paul.dean@example.com"},
}
err := pterm.DefaultTable.WithData(tableData).WithHasHeader(true).WithHeaderRowSeparator("─").WithRowSeparator("─").WithBoxed(true).Render()
if err != nil {
return err
}
return nil
}
func main() {
if err := test(); err != nil {
log.Fatal(err)
}
}
with the expected output:
however using the watch command (for example to live fetch data from apis) i see something like this:
Would love to see support for this in pterm as its very useful in a lot of usecases.
Hi @xsilas, by default watch
does not support color output. You can enable it with the -c
flag (watch -c your_command
). Let me know if this fixes your problem :)
Alternatively, you could also disable the colors in PTerm, but that's probably not what you want.
Thanks for the fast response, indeed this fixes it. Did not know that flag - thanks man!