Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export the current output width to watched program as COLUMNS environment variable #140

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@ the following to your `.bashrc`:
export HWATCH="--no-title --color --no-help-banner --border --with-scrollbar"
```

## Execution environment

When running a command, `hwatch` sets the `COLUMNS`. Many commands recognize it
automatically (try `git diff --stat`), some others accept column width as a
command-line argument.

TODO: Link to standard.

Some versions of `bash` might reset the value of `COLUMNS`; for this reason the `HWATCH_COLUMNS` environment variable is set to the same value.

## Example

### interval 10 second
Expand Down
6 changes: 3 additions & 3 deletions src/ansi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use termwiz::escape::{
parser::Parser,
Action, ControlCode,
};
use tui::style::{Color, Modifier, Style};
use tui::text::{Span,Text};
use tui::prelude::Line;
use tui::style::{Color, Modifier, Style};
use tui::text::{Span, Text};

/// Converts ANSI-escaped strings to tui-rs compatible text
pub fn bytes_to_text<'a, B: AsRef<[u8]>>(bytes: B) -> Text<'a> {
Expand Down Expand Up @@ -127,7 +127,7 @@ pub fn bytes_to_text<'a, B: AsRef<[u8]>>(bytes: B) -> Text<'a> {
let rgb_tuple = rgb.to_srgb_u8();
span_style =
span_style.bg(Color::Rgb(rgb_tuple.0, rgb_tuple.1, rgb_tuple.2));
},
}
},
_ => {}
}
Expand Down
Loading