Skip to content
Closed
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
36 changes: 31 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ tui = "0.19.0"
typed-builder = "0.10.0"
unicode-segmentation = "1.10.0"
unicode-width = "0.1.10"
gethostname = "0.4.1"

[target.'cfg(unix)'.dependencies]
libc = "0.2.124"
Expand Down
2 changes: 2 additions & 0 deletions sample_configs/default_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
#mem_as_value = false
# Show tree mode by default in the processes widget.
#tree = false
# Set terminal name to hostname
#title_has_hostname = false
# Shows an indicator in table widgets tracking where in the list you are.
#show_table_scroll_position = false
# Show processes as their commands by default in the process widget.
Expand Down
11 changes: 8 additions & 3 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use bottom::{
use crossterm::{
event::{EnableBracketedPaste, EnableMouseCapture},
execute,
terminal::{enable_raw_mode, EnterAlternateScreen},
terminal::{enable_raw_mode, EnterAlternateScreen, SetTitle},
};
use tui::{backend::CrosstermBackend, Terminal};

Expand All @@ -42,7 +42,7 @@ fn main() -> Result<()> {
check_if_terminal();

// Read from config file.
let config_path = read_config(matches.value_of("config_location"))
let config_path = read_config(matches.get_one::<String>("config_location"))
.context("Unable to access the given config file location.")?;
let mut config: Config = create_or_get_config(&config_path)
.context("Unable to properly parse or create the config file.")?;
Expand Down Expand Up @@ -123,8 +123,13 @@ fn main() -> Result<()> {
stdout_val,
EnterAlternateScreen,
EnableMouseCapture,
EnableBracketedPaste
EnableBracketedPaste,
)?;

if let Some(hostname) = get_use_terminal_name(&matches, &config) {
execute!(stdout_val, SetTitle(hostname),)?;
}

enable_raw_mode()?;

let mut terminal = Terminal::new(CrosstermBackend::new(stdout_val))?;
Expand Down
10 changes: 8 additions & 2 deletions src/clap.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use clap::builder::PossibleValuesParser;
use clap::*;

const TEMPLATE: &str = "\
Expand Down Expand Up @@ -237,14 +238,14 @@ pub fn build_app() -> Command<'static> {
.long("color")
.takes_value(true)
.value_name("COLOR SCHEME")
.possible_values([
.value_parser(PossibleValuesParser::new([
"default",
"default-light",
"gruvbox",
"gruvbox-light",
"nord",
"nord-light",
])
]))
.hide_possible_values(true)
.help("Use a color scheme, use --help for info.")
.long_help(
Expand Down Expand Up @@ -338,6 +339,10 @@ use CPU (3) as the default instead.
.help("The amount in ms changed upon zooming.")
.long_help("The amount of time in milliseconds changed when zooming in/out. The minimum is 1s (1000), and defaults to 15s (15000).");

let title = Arg::new("title")
.long("title")
.help("Sets the title of the current terminal to \"btm ($hostname)\".");

let tree = Arg::new("tree")
.short('T')
.long("tree")
Expand Down Expand Up @@ -410,6 +415,7 @@ use CPU (3) as the default instead.
.arg(rate)
.arg(regex)
.arg(time_delta)
.arg(title)
.arg(tree)
.arg(network_use_bytes)
.arg(network_use_log)
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ pub fn handle_key_event_or_break(
false
}

pub fn read_config(config_location: Option<&str>) -> error::Result<Option<PathBuf>> {
pub fn read_config(config_location: Option<&String>) -> error::Result<Option<PathBuf>> {
let config_path = if let Some(conf_loc) = config_location {
Some(PathBuf::from(conf_loc))
} else if cfg!(target_os = "windows") {
Expand Down
Loading