mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-24 06:05:10 +02:00
feature: Add process_command to default to the process command (#379)
Adds a `process_command` flag and config option to default to showing the full command in the process widget on startup.
This commit is contained in:
parent
30b2c2ea05
commit
60d0117c85
@ -9,7 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- [#333](https://github.com/ClementTsang/bottom/pull/333): Adds an "out of" indicator that can be enabled using `--show_table_scroll_position` to help keep track of scrolled position.
|
- [#333](https://github.com/ClementTsang/bottom/pull/333): Adds an "out of" indicator that can be enabled using `--show_table_scroll_position` (and its corresponding config option) to help keep track of scrolled position.
|
||||||
|
|
||||||
|
- [#379](https://github.com/ClementTsang/bottom/pull/379): Adds `--process_command` flag and corresponding config option to default to showing a process' command.
|
||||||
|
|
||||||
## Changes
|
## Changes
|
||||||
|
|
||||||
|
52
README.md
52
README.md
@ -222,6 +222,7 @@ Use `btm --help` for more information.
|
|||||||
-S, --case_sensitive Enables case sensitivity by default.
|
-S, --case_sensitive Enables case sensitivity by default.
|
||||||
-c, --celsius Sets the temperature type to Celsius.
|
-c, --celsius Sets the temperature type to Celsius.
|
||||||
--color <COLOR SCHEME> Use a color scheme, use --help for supported values.
|
--color <COLOR SCHEME> Use a color scheme, use --help for supported values.
|
||||||
|
--process_command Show processes as their commands by default.
|
||||||
-C, --config <CONFIG PATH> Sets the location of the config file.
|
-C, --config <CONFIG PATH> Sets the location of the config file.
|
||||||
-u, --current_usage Sets process CPU% to be based on current CPU%.
|
-u, --current_usage Sets process CPU% to be based on current CPU%.
|
||||||
-t, --default_time_value <MS> Default time value for graphs in ms.
|
-t, --default_time_value <MS> Default time value for graphs in ms.
|
||||||
@ -531,32 +532,31 @@ The following options can be set under `[flags]` to achieve the same effect as p
|
|||||||
|
|
||||||
These are the following supported flag config values, which correspond to the flag of the same name described in [Flags](#flags):
|
These are the following supported flag config values, which correspond to the flag of the same name described in [Flags](#flags):
|
||||||
|
|
||||||
| Field | Type |
|
| Field | Type | Functionality |
|
||||||
| ---------------------------- | ------------------------------------------------------------------------------------- |
|
| ---------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------- |
|
||||||
| `hide_avg_cpu` | Boolean |
|
| `hide_avg_cpu` | Boolean | Hides the average CPU usage. |
|
||||||
| `dot_marker` | Boolean |
|
| `dot_marker` | Boolean | Uses a dot marker for graphs. |
|
||||||
| `left_legend` | Boolean |
|
| `left_legend` | Boolean | Puts the CPU chart legend to the left side. |
|
||||||
| `current_usage` | Boolean |
|
| `current_usage` | Boolean | Sets process CPU% to be based on current CPU%. |
|
||||||
| `group_processes` | Boolean |
|
| `group_processes` | Boolean | Groups processes with the same name by default. |
|
||||||
| `case_sensitive` | Boolean |
|
| `case_sensitive` | Boolean | Enables case sensitivity by default. |
|
||||||
| `whole_word` | Boolean |
|
| `whole_word` | Boolean | Enables whole-word matching by default. |
|
||||||
| `regex` | Boolean |
|
| `regex` | Boolean | Enables regex by default. |
|
||||||
| `show_disabled_data` | Boolean |
|
| `basic` | Boolean | Hides graphs and uses a more basic look. |
|
||||||
| `basic` | Boolean |
|
| `use_old_network_legend` | Boolean | DEPRECATED - uses the older network legend. |
|
||||||
| `hide_table_count` | Boolean |
|
| `battery` | Boolean | Shows the battery widget. |
|
||||||
| `use_old_network_legend` | Boolean |
|
| `rate` | Unsigned Int (represents milliseconds) | Sets a refresh rate in ms. |
|
||||||
| `battery` | Boolean |
|
| `default_time_value` | Unsigned Int (represents milliseconds) | Default time value for graphs in ms. |
|
||||||
| `rate` | Unsigned Int (represents milliseconds) |
|
| `time_delta` | Unsigned Int (represents milliseconds) | The amount in ms changed upon zooming. |
|
||||||
| `default_time_value` | Unsigned Int (represents milliseconds) |
|
| `temperature_type` | String (one of ["k", "f", "c", "kelvin", "fahrenheit", "celsius"]) | Sets the temperature unit type. |
|
||||||
| `time_delta` | Unsigned Int (represents milliseconds) |
|
| `default_widget_type` | String (one of ["cpu", "proc", "net", "temp", "mem", "disk"], same as layout options) | Sets the default widget type, use --help for more info. |
|
||||||
| `temperature_type` | String (one of ["k", "f", "c", "kelvin", "fahrenheit", "celsius"]) |
|
| `default_widget_count` | Unsigned Int (represents which `default_widget_type`) | Sets the n'th selected widget type as the default. |
|
||||||
| `default_widget_type` | String (one of ["cpu", "proc", "net", "temp", "mem", "disk"], same as layout options) |
|
| `disable_click` | Boolean | Disables mouse clicks. |
|
||||||
| `default_widget_count` | Unsigned Int (represents which `default_widget_type`) |
|
| `color` | String (one of ["default", "default-light", "gruvbox", "gruvbox-light"]) | Use a color scheme, use --help for supported values. |
|
||||||
| `disable_click` | Boolean |
|
| `mem_as_value` | Boolean | Defaults to showing process memory usage by value. |
|
||||||
| `color` | String (one of ["default", "default-light", "gruvbox", "gruvbox-light"]) |
|
| `tree` | Boolean | Defaults to showing the process widget in tree mode. |
|
||||||
| `mem_as_value` | Boolean |
|
| `show_table_scroll_position` | Boolean | Shows the scroll position tracker in table widgets. |
|
||||||
| `tree` | Boolean |
|
| `process_command` | Boolean | Show processes as their commands by default. |
|
||||||
| `show_table_scroll_position` | Boolean |
|
|
||||||
|
|
||||||
#### Theming
|
#### Theming
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ group_processes = false
|
|||||||
case_sensitive = false
|
case_sensitive = false
|
||||||
whole_word = false
|
whole_word = false
|
||||||
regex = true
|
regex = true
|
||||||
show_disabled_data = true
|
|
||||||
default_widget_type = "cpu"
|
default_widget_type = "cpu"
|
||||||
default_widget_count = 1
|
default_widget_count = 1
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ pub struct ProcWidgetState {
|
|||||||
impl ProcWidgetState {
|
impl ProcWidgetState {
|
||||||
pub fn init(
|
pub fn init(
|
||||||
is_case_sensitive: bool, is_match_whole_word: bool, is_use_regex: bool, is_grouped: bool,
|
is_case_sensitive: bool, is_match_whole_word: bool, is_use_regex: bool, is_grouped: bool,
|
||||||
show_memory_as_values: bool, is_tree_mode: bool,
|
show_memory_as_values: bool, is_tree_mode: bool, is_using_command: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut process_search_state = ProcessSearchState::default();
|
let mut process_search_state = ProcessSearchState::default();
|
||||||
|
|
||||||
@ -450,7 +450,7 @@ impl ProcWidgetState {
|
|||||||
scroll_state: AppScrollWidgetState::default(),
|
scroll_state: AppScrollWidgetState::default(),
|
||||||
process_sorting_type,
|
process_sorting_type,
|
||||||
is_process_sort_descending,
|
is_process_sort_descending,
|
||||||
is_using_command: false,
|
is_using_command,
|
||||||
current_column_index: 0,
|
current_column_index: 0,
|
||||||
is_sort_open: false,
|
is_sort_open: false,
|
||||||
columns,
|
columns,
|
||||||
|
33
src/clap.rs
33
src/clap.rs
@ -81,6 +81,15 @@ custom layouts.\n\n",
|
|||||||
"\
|
"\
|
||||||
When searching for a process, enables case sensitivity by default.\n\n",
|
When searching for a process, enables case sensitivity by default.\n\n",
|
||||||
);
|
);
|
||||||
|
let current_usage = Arg::with_name("current_usage")
|
||||||
|
.short("u")
|
||||||
|
.long("current_usage")
|
||||||
|
.help("Sets process CPU% to be based on current CPU%.")
|
||||||
|
.long_help(
|
||||||
|
"\
|
||||||
|
Sets process CPU% usage to be based on the current system CPU% usage
|
||||||
|
rather than total CPU usage.\n\n",
|
||||||
|
);
|
||||||
// TODO: [DEBUG] Add a proper debugging solution.
|
// TODO: [DEBUG] Add a proper debugging solution.
|
||||||
// let debug = Arg::with_name("debug")
|
// let debug = Arg::with_name("debug")
|
||||||
// .long("debug")
|
// .long("debug")
|
||||||
@ -106,7 +115,7 @@ Disables mouse clicks from interacting with the program.\n\n",
|
|||||||
Uses a dot marker for graphs as opposed to the default braille
|
Uses a dot marker for graphs as opposed to the default braille
|
||||||
marker.\n\n",
|
marker.\n\n",
|
||||||
);
|
);
|
||||||
let group = Arg::with_name("group")
|
let group = Arg::with_name("group") // FIXME: Rename this to something like "group_process", would be "breaking" though.
|
||||||
.short("g")
|
.short("g")
|
||||||
.long("group")
|
.long("group")
|
||||||
.help("Groups processes with the same name by default.")
|
.help("Groups processes with the same name by default.")
|
||||||
@ -136,12 +145,13 @@ Hides the spacing between table headers and entries.\n\n",
|
|||||||
"\
|
"\
|
||||||
Completely hides the time scaling from being shown.\n\n",
|
Completely hides the time scaling from being shown.\n\n",
|
||||||
);
|
);
|
||||||
let show_table_scroll_position = Arg::with_name("show_table_scroll_position")
|
let process_command = Arg::with_name("process_command")
|
||||||
.long("show_table_scroll_position")
|
.long("process_command")
|
||||||
.help("Shows the scroll position tracker in table widgets")
|
.help("Show processes as their commands by default.")
|
||||||
.long_help(
|
.long_help(
|
||||||
"\
|
"\
|
||||||
Shows the list scroll position tracker in the widget title for table widgets.\n\n",
|
Show processes as their commands by default in the process widget.
|
||||||
|
",
|
||||||
);
|
);
|
||||||
let left_legend = Arg::with_name("left_legend")
|
let left_legend = Arg::with_name("left_legend")
|
||||||
.short("l")
|
.short("l")
|
||||||
@ -166,14 +176,12 @@ Puts the CPU chart legend to the left side rather than the right side.\n\n",
|
|||||||
"\
|
"\
|
||||||
When searching for a process, enables regex by default.\n\n",
|
When searching for a process, enables regex by default.\n\n",
|
||||||
);
|
);
|
||||||
let current_usage = Arg::with_name("current_usage")
|
let show_table_scroll_position = Arg::with_name("show_table_scroll_position")
|
||||||
.short("u")
|
.long("show_table_scroll_position")
|
||||||
.long("current_usage")
|
.help("Shows the scroll position tracker in table widgets.")
|
||||||
.help("Sets process CPU% to be based on current CPU%.")
|
|
||||||
.long_help(
|
.long_help(
|
||||||
"\
|
"\
|
||||||
Sets process CPU% usage to be based on the current system CPU% usage
|
Shows the list scroll position tracker in the widget title for table widgets.\n\n",
|
||||||
rather than total CPU usage.\n\n",
|
|
||||||
);
|
);
|
||||||
let use_old_network_legend = Arg::with_name("use_old_network_legend")
|
let use_old_network_legend = Arg::with_name("use_old_network_legend")
|
||||||
.long("use_old_network_legend")
|
.long("use_old_network_legend")
|
||||||
@ -277,7 +285,7 @@ use CPU (3) as the default instead.
|
|||||||
.long("default_widget_type")
|
.long("default_widget_type")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.value_name("WIDGET TYPE")
|
.value_name("WIDGET TYPE")
|
||||||
.help("Sets which widget type to use as the default widget.")
|
.help("Sets the default widget type, use --help for more info.")
|
||||||
.long_help(
|
.long_help(
|
||||||
"\
|
"\
|
||||||
Sets which widget type to use as the default widget.
|
Sets which widget type to use as the default widget.
|
||||||
@ -361,6 +369,7 @@ Defaults to showing the process widget in tree mode.\n\n",
|
|||||||
.arg(basic)
|
.arg(basic)
|
||||||
.arg(battery)
|
.arg(battery)
|
||||||
.arg(case_sensitive)
|
.arg(case_sensitive)
|
||||||
|
.arg(process_command)
|
||||||
.arg(config_location)
|
.arg(config_location)
|
||||||
.arg(color)
|
.arg(color)
|
||||||
// .arg(debug)
|
// .arg(debug)
|
||||||
|
@ -398,6 +398,10 @@ pub const OLD_CONFIG_TEXT: &str = r##"# This is a default config file for bottom
|
|||||||
#mem_as_value = false
|
#mem_as_value = false
|
||||||
# Show tree mode by default in the processes widget.
|
# Show tree mode by default in the processes widget.
|
||||||
#tree = false
|
#tree = 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.
|
||||||
|
#process_command = false
|
||||||
|
|
||||||
# These are all the components that support custom theming. Note that colour support
|
# These are all the components that support custom theming. Note that colour support
|
||||||
# will depend on terminal support.
|
# will depend on terminal support.
|
||||||
|
@ -150,6 +150,9 @@ pub struct ConfigFlags {
|
|||||||
|
|
||||||
#[builder(default, setter(strip_option))]
|
#[builder(default, setter(strip_option))]
|
||||||
show_table_scroll_position: Option<bool>,
|
show_table_scroll_position: Option<bool>,
|
||||||
|
|
||||||
|
#[builder(default, setter(strip_option))]
|
||||||
|
pub process_command: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Default, Debug, Deserialize, Serialize)]
|
||||||
@ -254,6 +257,7 @@ pub fn build_app(
|
|||||||
|
|
||||||
let show_memory_as_values = get_mem_as_value(matches, config);
|
let show_memory_as_values = get_mem_as_value(matches, config);
|
||||||
let is_default_tree = get_is_default_tree(matches, config);
|
let is_default_tree = get_is_default_tree(matches, config);
|
||||||
|
let is_default_command = get_is_default_process_command(matches, config);
|
||||||
|
|
||||||
for row in &widget_layout.rows {
|
for row in &widget_layout.rows {
|
||||||
for col in &row.children {
|
for col in &row.children {
|
||||||
@ -322,6 +326,7 @@ pub fn build_app(
|
|||||||
is_grouped,
|
is_grouped,
|
||||||
show_memory_as_values,
|
show_memory_as_values,
|
||||||
is_default_tree,
|
is_default_tree,
|
||||||
|
is_default_command,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -987,3 +992,14 @@ fn get_show_table_scroll_position(matches: &clap::ArgMatches<'static>, config: &
|
|||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_is_default_process_command(matches: &clap::ArgMatches<'static>, config: &Config) -> bool {
|
||||||
|
if matches.is_present("process_command") {
|
||||||
|
return true;
|
||||||
|
} else if let Some(flags) = &config.flags {
|
||||||
|
if let Some(process_command) = flags.process_command {
|
||||||
|
return process_command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user