### Command-line Configuration Example Source: https://github.com/dalance/procs/blob/master/_autodocs/architecture.md Demonstrates how command-line arguments override configuration files and built-in defaults. This example shows loading a custom TOML file and then applying specific overrides. ```bash procs --color disable --theme dark --load-config custom.toml ``` -------------------------------- ### Install Procs with Snapcraft Source: https://github.com/dalance/procs/blob/master/README.md Install procs using Snapcraft. This method requires sudo privileges. ```bash sudo snap install procs ``` -------------------------------- ### TOML Configuration Example for Procs Source: https://github.com/dalance/procs/blob/master/README.md This is a complete TOML configuration file example for procs. It demonstrates how to define columns, styles, search parameters, display options, sorting preferences, and Docker integration. Use this as a template for your own configuration. ```toml [[columns]] kind = "Pid" style = "BrightYellow|Yellow" numeric_search = true nonnumeric_search = false [[columns]] kind = "Username" style = "BrightGreen|Green" numeric_search = false nonnumeric_search = true align = "Right" [style] header = "BrightWhite|Black" unit = "BrightWhite|Black" tree = "BrightWhite|Black" [style.by_percentage] color_000 = "BrightBlue|Blue" color_025 = "BrightGreen|Green" color_050 = "BrightYellow|Yellow" color_075 = "BrightRed|Red" color_100 = "BrightRed|Red" [style.by_state] color_d = "BrightRed|Red" color_r = "BrightGreen|Green" color_s = "BrightBlue|Blue" color_t = "BrightCyan|Cyan" color_z = "BrightMagenta|Magenta" color_x = "BrightMagenta|Magenta" color_k = "BrightYellow|Yellow" color_w = "BrightYellow|Yellow" color_p = "BrightYellow|Yellow" [style.by_unit] color_k = "BrightBlue|Blue" color_m = "BrightGreen|Green" color_g = "BrightYellow|Yellow" color_t = "BrightRed|Red" color_p = "BrightRed|Red" color_x = "BrightBlue|Blue" [search] numeric_search = "Exact" nonnumeric_search = "Partial" logic = "And" [display] show_self = false show_thread = false show_thread_in_tree = true cut_to_terminal = true cut_to_pager = false cut_to_pipe = false color_mode = "Auto" [sort] column = 0 order = "Ascending" [docker] path = "unix:///var/run/docker.sock" [pager] mode = "Auto" ``` -------------------------------- ### Example `add` Method Implementation Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/column-trait.md Demonstrates how to implement the `add` method to ingest process PID and format it for storage. ```rust fn add(&mut self, proc: &ProcessInfo) { let raw_content = proc.pid; let fmt_content = format!("{raw_content}"); self.fmt_contents.insert(proc.pid, fmt_content); self.raw_contents.insert(proc.pid, raw_content); } ``` -------------------------------- ### Example TOML Configuration Source: https://github.com/dalance/procs/blob/master/_autodocs/configuration.md A comprehensive TOML configuration example covering column definitions, styling, search parameters, display settings, sorting, and pager mode. ```TOML [[columns]] kind = "Pid" style = "BrightYellow|Yellow" numeric_search = true [[columns]] kind = "User" style = "BrightGreen|Green" nonnumeric_search = true [[columns]] kind = "Cpu" style = "ByPercentage" [[columns]] kind = "Mem" style = "ByPercentage" [style] header = "BrightWhite|Black" unit = "BrightWhite|Black" [search] numeric_search = "Exact" nonnumeric_search = "Partial" logic = "And" [display] show_self = false show_header = true color_mode = "Auto" theme = "Auto" [sort] column = 0 order = "Ascending" [pager] mode = "Auto" ``` -------------------------------- ### Install Procs with Winget (Windows) Source: https://github.com/dalance/procs/blob/master/README.md Install procs on Windows using the winget package manager. ```bash winget install procs ``` -------------------------------- ### Install Procs with Scoop Source: https://github.com/dalance/procs/blob/master/README.md Install procs using the Scoop package manager for Windows. ```bash scoop install procs ``` -------------------------------- ### Install Globally Source: https://github.com/dalance/procs/blob/master/_autodocs/README.md Installs the Procs executable globally on the system, making it accessible from any directory. ```bash cargo install procs ``` -------------------------------- ### Install and Use Procs with X-CMD Source: https://github.com/dalance/procs/blob/master/README.md Install and use procs via x-cmd. The 'x env use procs' command downloads and invokes procs without affecting the current environment. ```bash x env use procs ``` ```bash x procs ``` -------------------------------- ### Configuration Sections Example Source: https://github.com/dalance/procs/blob/master/_autodocs/INDEX.md Lists the main configuration sections and their sub-sections available in the TOML configuration format. ```toml [style] - Header, unit, and value-based colors [style.by_percentage] - Percentage range colors (0%, 25%, 50%, 75%, 100%) [style.by_state] - Process state colors (D, R, S, T, Z, X, K, W, P) [style.by_unit] - Memory unit colors (K, M, G, T, P) [search] - Keyword matching defaults [display] - Output formatting options [sort] - Default sort column and direction [docker] - Docker daemon configuration [pager] - External pager control ``` -------------------------------- ### ConfigColorByTheme Example Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/config-structures.md Instantiate ConfigColorByTheme with specific dark and light theme colors. ```rust ConfigColorByTheme { dark: ConfigColor::BrightWhite, light: ConfigColor::Black, } ``` -------------------------------- ### Install Procs with DNF (Fedora) Source: https://github.com/dalance/procs/blob/master/README.md Install procs on Fedora using the dnf package manager. ```bash sudo dnf install procs ``` -------------------------------- ### Install Procs with Nixpkgs Source: https://github.com/dalance/procs/blob/master/README.md Install procs using the Nix package manager. Ensure the correct repository is enabled. ```bash nix-env --install procs ``` -------------------------------- ### Example TOML for Top-Level Config Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/config-structures.md Illustrates how to define top-level configuration settings in a TOML file, including column definitions, styling, and search preferences. ```toml [[columns]] kind = "Pid" style = "BrightYellow|Yellow" [style] header = "BrightWhite|Black" [search] numeric_search = "Exact" [display] show_header = true ``` -------------------------------- ### Install Procs with RPM Source: https://github.com/dalance/procs/blob/master/README.md Install procs using an RPM package. This command installs a specific version. ```bash sudo rpm -i https://github.com/dalance/procs/releases/download/v0.14.11/procs-0.14.11-1.x86_64.rpm ``` -------------------------------- ### Install Procs with Homebrew Source: https://github.com/dalance/procs/blob/master/README.md Install procs using the Homebrew package manager for macOS and Linux. ```bash brew install procs ``` -------------------------------- ### Install Procs with Arch Linux Source: https://github.com/dalance/procs/blob/master/README.md Install procs on Arch Linux from the extra repository using pacman. ```bash sudo pacman -S procs ``` -------------------------------- ### Install Procs with Cargo Source: https://github.com/dalance/procs/blob/master/README.md Install procs using Cargo, the Rust package manager. This requires Rust to be installed. ```bash cargo install procs ``` -------------------------------- ### Advanced Search Modes Example Source: https://github.com/dalance/procs/blob/master/_autodocs/INDEX.md Shows how to use regular expressions and smart pattern detection for more complex searches. ```bash procs --regex 'bash|zsh' # Regular expression procs --smart 'proc.*' # Auto-detect regex syntax ``` -------------------------------- ### Tree View Output Example Source: https://github.com/dalance/procs/blob/master/_autodocs/README.md Hierarchical tree view of processes, showing parent-child relationships. ```text PID USER COMMAND 1 root /sbin/init ├─ 2 root [kthreadd] │ ├─ 3 root [ksoftirqd/0] │ └─ 4 root [kworker/0:0] ``` -------------------------------- ### Install Procs with Alpine Linux Source: https://github.com/dalance/procs/blob/master/README.md Install procs on Alpine Linux using the apk package manager. Ensure the correct repository is enabled. ```bash sudo apk add procs ``` -------------------------------- ### Logical Search Operations Example Source: https://github.com/dalance/procs/blob/master/_autodocs/INDEX.md Illustrates how to combine search keywords using logical operators like AND, OR, NAND, and NOR. ```bash procs --and bash zsh # Both keywords must match (default) procs --or bash zsh # Either keyword can match procs --nand bash zsh # Not (both keywords match) procs --nor bash zsh # Not (either keyword matches) ``` -------------------------------- ### Tree Output Format Example Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/view-rendering.md Demonstrates the tree format for rendering processes, showing parent-child hierarchies with indentation and connection symbols. ```text PID USER COMMAND 1 root /sbin/init ├─ 2 root /sbin/kthreadd │ ├─ 3 root /sbin/ksoftirqd/0 │ └─ 4 root /sbin/kworker/0:0 ... ``` -------------------------------- ### Table Output Format Example Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/view-rendering.md Illustrates the default table format for displaying process information, including headers, process details, and column separators. ```text PID USER CPU MEM COMMAND 1 root 0.0% 0.1% /sbin/init ... ``` -------------------------------- ### Install Procs with MacPorts Source: https://github.com/dalance/procs/blob/master/README.md Install procs using MacPorts. This command requires sudo privileges. ```bash sudo port install procs ``` -------------------------------- ### Basic Text and Numeric Search Example Source: https://github.com/dalance/procs/blob/master/_autodocs/INDEX.md Demonstrates how to perform basic text and numeric searches using the procs command. ```bash procs bash # Text search (substring match) procs 1234 # Numeric search (exact match) ``` -------------------------------- ### TOML Examples for Column Style Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/config-structures.md Shows how to specify different column styling methods in TOML, such as fixed colors, percentage-based, state-based, or unit-based. ```toml style = "BrightYellow|Yellow" # Fixed color style = "ByPercentage" # By percentage style = "ByState" # By state style = "ByUnit" # By unit (default) ``` -------------------------------- ### Example TOML for a Single Column Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/config-structures.md Demonstrates the TOML syntax for configuring a specific column, including its kind, style, searchability, alignment, and width. ```toml [[columns]] kind = "Pid" style = "BrightYellow|Yellow" numeric_search = true nonnumeric_search = false align = "Right" max_width = 10 min_width = 5 header = "ProcessID" ``` -------------------------------- ### JSON Output Format Example Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/view-rendering.md Shows the JSON output format, where processes are represented as an array of objects with appropriate data types for fields. ```json [ {"PID": 1, "USER": "root", "CPU": 0.0, "COMMAND": "/sbin/init"}, ... ] ``` -------------------------------- ### TOML Serialization for ConfigColor Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/config-structures.md Shows TOML serialization examples for ConfigColor, including named colors, dark variants, 256-color palette entries, and combined dark/light 256-color values. ```toml "BrightWhite" # Named color ``` ```toml "Black" # Dark variant ``` ```toml "223" # 256-color palette entry ``` ```toml "223|112" # Dark: 223, Light: 112 ``` -------------------------------- ### Minimal Text Column Implementation Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/column-trait.md Example of a basic text-based column implementation. It uses `column_default!` with `false` for `is_numeric`. ```rust pub struct Username { header: String, unit: String, fmt_contents: HashMap, width: usize, } impl Column for Username { fn add(&mut self, proc: &ProcessInfo) { let fmt = proc.user.clone(); self.fmt_contents.insert(proc.pid, fmt); } column_default!(String, false); // text column, unsortable numerically } ``` -------------------------------- ### Display only specific columns Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Limit the output to only specified columns. Use `--only` to show just the PID, for example. ```bash procs --only pid # Show only PID column ``` -------------------------------- ### Grant Sudo Privileges for Procs Source: https://github.com/dalance/procs/blob/master/README.md Example of using sudo to run procs when elevated privileges are required for accessing certain process information. ```console $ sudo procs [sudo] password for ...: ``` -------------------------------- ### Format Text for Alignment in Rust Source: https://github.com/dalance/procs/blob/master/_autodocs/INDEX.md Shows a basic text formatting utility in Rust for aligning strings to a specified width, with right alignment as an example. ```rust let aligned = adjust("PID", 10, &ConfigColumnAlign::Right); // " PID" ``` -------------------------------- ### Load custom configuration presets Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Load custom process display configurations using presets or by loading from a file. Also shows how to generate a default configuration file. ```bash procs --use-config large # Use large preset procs --load-config ~/myconfig.toml procs --gen-config > default-config.toml ``` -------------------------------- ### Use Custom Configuration Source: https://github.com/dalance/procs/blob/master/_autodocs/README.md Loads and applies process display settings from a specified TOML configuration file. ```bash procs --load-config ~/.config/procs/minimal.toml ``` -------------------------------- ### Standard Build Source: https://github.com/dalance/procs/blob/master/_autodocs/README.md Builds the project in release mode for optimized performance. ```bash cargo build --release ``` -------------------------------- ### Build and Render a Custom View Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/view-rendering.md Demonstrates the complete process of loading configuration, parsing arguments, creating a view, filtering processes, adjusting column widths, and finally rendering the output to the terminal. ```rust // Load configuration let config = Config::from_file("config.toml")?; // Parse command-line arguments let opt = Opt::parse(); // Create View let mut view = View::new(&opt, &config, false)?; // Filter processes by keyword view.filter(&opt, &config, 1)?; // Adjust column widths let insert_widths = HashMap::new(); view.adjust(&config, &insert_widths); // Render output let theme = get_theme(&opt, &config); view.display(&opt, &config, &theme)?; ``` -------------------------------- ### View::new Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/view-rendering.md Constructs and initializes a View instance. It parses configuration, applies command-line overrides, initializes columns, sets up terminal information, and calculates sorting. ```APIDOC ## new ### Description Constructs and initializes a View. ### Method `pub fn new(opt: &mut Opt, config: &Config, clear_by_line: bool) -> Result` ### Parameters - `opt` (Opt) - Command-line options (can be modified) - `config` (Config) - Configuration (columns, styles, display settings) - `clear_by_line` (bool) - Whether to use line-by-line terminal clearing (for watch mode) ### Returns `Result` - View instance or error ### Process 1. Parses configuration columns and processes Slot/MultiSlot expansions 2. Applies command-line overrides (--insert, --only, --sorta, --sortd) 3. Initializes all 60+ column types (filters by platform availability) 4. Sets up terminal information 5. Calculates sort information from config or command-line ``` -------------------------------- ### Use built-in configuration preset Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Use a built-in configuration preset instead of loading from a file. Presets like 'default' and 'large' offer different sets of columns. ```bash procs --use-config default # Default minimal column set procs --use-config large # Extended column set ``` -------------------------------- ### Load configuration from a file Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Load configuration settings from a specified TOML file. This allows for persistent custom configurations. ```bash procs --load-config /etc/procs/custom.toml ``` -------------------------------- ### Configuration Management Source: https://github.com/dalance/procs/blob/master/_autodocs/README.md Use built-in presets, load custom TOML configurations, or generate default configurations and shell completions. ```bash procs --use-config large # Built-in "large" preset procs --load-config ~/custom.toml # Load custom config procs --gen-config # Print default config procs --gen-completion bash # Generate bash completions ``` -------------------------------- ### Instantiate and Display Process View in Rust Source: https://github.com/dalance/procs/blob/master/_autodocs/INDEX.md Demonstrates the Rust API for creating a process view using configuration and options, filtering, adjusting, and displaying the view. ```rust let config = Config::from_file("config.toml")?; let opt = Opt::parse(); let mut view = View::new(&opt, &config, false)?; view.filter(&opt, &config, 1)?; view.adjust(&config, &HashMap::new()); view.display(&opt, &config, &theme)? ``` -------------------------------- ### Numeric Column with Sorting Implementation Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/column-trait.md Example of a numeric column implementation that supports sorting. It uses `column_default!` with `true` for `is_numeric` and includes `raw_contents` for sorting. ```rust pub struct MemoryUsage { header: String, unit: String, fmt_contents: HashMap, raw_contents: HashMap, width: usize, } impl Column for MemoryUsage { fn add(&mut self, proc: &ProcessInfo) { let raw = proc.vm_rss; let fmt = format_bytes(raw); self.fmt_contents.insert(proc.pid, fmt); self.raw_contents.insert(proc.pid, raw); } column_default!(u64, true); // numeric column, sortable } ``` -------------------------------- ### Display Options Source: https://github.com/dalance/procs/blob/master/_autodocs/README.md Customize the process display with options like tree view, thread inclusion, and continuous updates. ```bash procs --tree # Tree view (hierarchy) procs --thread # Include threads (Linux) procs --watch # Continuous update (1s interval) procs --watch-interval 2.5 # Custom interval procs --json # JSON output procs --no-header # Suppress header row procs --list # Show available column kinds ``` -------------------------------- ### Rust: Get Current Column Width Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/column-trait.md Returns the current calculated width of the column in characters. This value is used by the View for layout and terminal width management. ```rust fn get_width(&self) -> usize ``` -------------------------------- ### Search by Keywords Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Find processes by specifying one or more keywords. Keywords are matched against process information columns like USER and Command. By default, multiple keywords use AND logic. ```bash procs [KEYWORD]... ``` ```bash procs zsh ``` ```bash procs 1234 ``` ```bash procs firefox zsh ``` -------------------------------- ### Rust: Get PIDs Sorted by Column Values Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/column-trait.md Returns a vector of PIDs sorted according to the values in this column. The sorting order (ascending or descending) is specified by the ConfigSortOrder parameter. ```rust fn sorted_pid(&self, order: &ConfigSortOrder) -> Vec ``` -------------------------------- ### Build with Docker Support Source: https://github.com/dalance/procs/blob/master/_autodocs/README.md Builds the project in release mode, including Docker support which is enabled by default. ```bash cargo build --release --features docker ``` -------------------------------- ### Show all processes Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Display all running processes. This is the default behavior when no filters or options are specified. ```bash procs # Show all processes ``` -------------------------------- ### Display Available Column Kinds Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Display a list of all supported column types along with their descriptions, without running the full process display. ```bash procs --list ``` -------------------------------- ### Configure Process Viewer Settings Source: https://github.com/dalance/procs/blob/master/_autodocs/INDEX.md Customize 'procs' behavior using built-in configurations or custom TOML files. Includes options to load, generate, and use specific configurations. ```bash procs --use-config large # Built-in large config procs --load-config custom.toml # Load custom file procs --gen-config # Print default config ``` -------------------------------- ### Configure Display Options Source: https://github.com/dalance/procs/blob/master/_autodocs/configuration.md Controls output formatting, including which process details to show, how to truncate lines, and colorization settings. ```toml [display] show_self = false show_thread = false show_header = true show_footer = false cut_to_terminal = true color_mode = "Auto" separator = "│" ascending = "▲" descending = "▼" tree_symbols = ["│", "─", "┬", "├", "└"] abbr_sid = true theme = "Auto" show_kthreads = true ``` -------------------------------- ### display_content Method Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/column-trait.md Renders the formatted value for a specific process ID. It looks up pre-formatted content, aligns it, and returns it as an Option. ```APIDOC --- ### display_content **Signature:** ```rust fn display_content(&self, pid: i32, align: &ConfigColumnAlign) -> Option ``` **Purpose:** Render the formatted value for a process. **Parameters:** - `pid: i32` — Process ID to lookup - `align: &ConfigColumnAlign` — Text alignment **Returns:** `Option` — Some(formatted_value) if PID exists, None otherwise **Description:** Looks up pre-formatted content for the PID, aligns it, and returns. Usually calls `self.fmt_contents.get(&pid)`. **Macro helper:** The `column_default_display_content!()` macro provides standard implementation. ``` -------------------------------- ### TOML Serialization for ConfigColorByTheme Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/config-structures.md Illustrates different ways to serialize ConfigColorByTheme in TOML format, supporting two-color, single-color, and 256-color options. ```toml header = "BrightWhite|Black" # Two-color format ``` ```toml header = "BrightWhite" # Single color (both themes) ``` ```toml header = "223|112" # 256-color format ``` -------------------------------- ### Show All Processes with Procs Source: https://github.com/dalance/procs/blob/master/README.md Execute the 'procs' command without any arguments to display information for all running processes. ```console procs ``` -------------------------------- ### View::display Method Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/view-rendering.md Renders the process table to the output, handling headers, process rows, colors, and different output destinations like terminal, pager, or pipe. ```rust pub fn display( &mut self, opt: &Opt, config: &Config, theme: &ConfigTheme, ) -> Result<(), Error> ``` -------------------------------- ### View::new Constructor Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/view-rendering.md Constructs and initializes a new View instance. It parses configuration, applies command-line overrides, and sets up terminal and sort information. ```rust pub fn new(opt: &mut Opt, config: &Config, clear_by_line: bool) -> Result ``` -------------------------------- ### File Structure Overview Source: https://github.com/dalance/procs/blob/master/_autodocs/INDEX.md Illustrates the directory and file layout of the Dalance Procs project. ```tree output/ ├── README.md - Start here ├── INDEX.md - This file ├── architecture.md - System design ├── configuration.md - TOML configuration reference ├── types.md - Type definitions ├── api-reference/ │ ├── command-line-options.md - CLI flags reference │ ├── column-trait.md - Column interface │ ├── config-structures.md - Configuration structures │ ├── view-rendering.md - View orchestration │ └── utility-functions.md - Helper functions ``` -------------------------------- ### ConfigDisplay Struct Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/config-structures.md Defines output display options and formatting for process information. Includes settings for showing various process relationships, headers, footers, and truncation behavior. ```rust pub struct ConfigDisplay { pub show_self: bool, pub show_self_parents: bool, pub show_thread: bool, pub show_thread_in_tree: bool, pub show_parent_in_tree: bool, pub show_children_in_tree: bool, pub show_header: bool, pub show_footer: bool, pub show_kthreads: bool, pub cut_to_terminal: bool, pub cut_to_pager: bool, pub cut_to_pipe: bool, pub color_mode: ConfigColorMode, pub separator: String, pub ascending: String, pub descending: String, pub tree_symbols: [String; 5], pub abbr_sid: bool, pub theme: ConfigTheme, } ``` -------------------------------- ### Generate default configuration Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Generate and print the complete default configuration to standard output. This can be redirected to a file for customization. ```bash procs --gen-config > config.toml ``` -------------------------------- ### Display Output in Process Tree Format Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Display the process output in a tree format, showing the parent-child relationship. The process hierarchy is indicated in the leftmost column. ```bash procs --tree ``` -------------------------------- ### Display Processes in Tree View Source: https://github.com/dalance/procs/blob/master/README.md Use the --tree option to display processes sorted by dependency order, showing a dependency tree on the left side. ```console procs --tree ``` -------------------------------- ### Add custom columns to display Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Insert additional columns into the process display. Use `--insert` to add columns like parent PID (ppid) or cgroup. ```bash procs --insert ppid --insert cgroup # Add parent PID and cgroup ``` -------------------------------- ### Opt Struct Source: https://github.com/dalance/procs/blob/master/_autodocs/types.md Represents command-line options parsed using clap. ```rust pub struct Opt { pub keyword: Vec, pub text: bool, pub regex: bool, pub smart: bool, pub and: bool, pub or: bool, pub nand: bool, pub nor: bool, pub list: bool, pub thread: bool, pub tree: bool, pub watch: bool, pub watch_interval: Option, pub watch_mode: bool, pub insert: Vec, pub only: Option, pub sorta: Option, pub sortd: Option, pub color: Option, pub theme: Option, pub pager: Option, pub json: bool, pub interval: u64, pub use_config: Option, pub load_config: Option, pub gen_config: bool, pub gen_completion: Option, pub gen_completion_out: Option, pub gen_man_page: bool, pub no_header: bool, pub procfs: Option, pub debug: bool, } ``` -------------------------------- ### Procs Data Flow (Single Execution) Source: https://github.com/dalance/procs/blob/master/_autodocs/README.md Illustrates the sequence of operations for a single execution of the procs command. ```text Parse CLI → Load config → View::new() → View::filter() → View::adjust() → View::display() → Output ``` -------------------------------- ### Top-Level Configuration Structure Source: https://github.com/dalance/procs/blob/master/_autodocs/types.md The main configuration structure, encompassing all settings for columns, style, search, display, sorting, Docker, and pager. Deserialized from TOML files or created from built-in defaults. ```rust pub struct Config { pub columns: Vec, pub style: ConfigStyle, pub search: ConfigSearch, pub display: ConfigDisplay, pub sort: ConfigSort, pub docker: ConfigDocker, pub pager: ConfigPager, } ``` -------------------------------- ### Sort and Display Processes Source: https://github.com/dalance/procs/blob/master/_autodocs/INDEX.md Control process display by sorting, adding columns, or limiting output. Options include sorting by CPU descending, adding parent PID, showing only PID, and tree format. ```bash procs --sortd cpu # Sort by CPU usage descending procs --insert ppid # Add parent PID column procs --only pid # Show only PID column procs --tree # Display in tree format ``` -------------------------------- ### Procs Data Flow (Watch Mode) Source: https://github.com/dalance/procs/blob/master/_autodocs/README.md Illustrates the sequence of operations for the procs command in watch mode. ```text Parse CLI → Load config → Watcher::start() → Loop: [sleep] → collect processes → render → [loop] ``` -------------------------------- ### Style Configuration by Percentage Source: https://github.com/dalance/procs/blob/master/_autodocs/types.md Defines color schemes for different percentage ranges of values. Each range (0-25%, 25-50%, etc.) can have a distinct theme-aware color. ```rust pub struct ConfigStyleByPercentage { pub color_000: ConfigColorByTheme, pub color_025: ConfigColorByTheme, pub color_050: ConfigColorByTheme, pub color_075: ConfigColorByTheme, pub color_100: ConfigColorByTheme, } ``` -------------------------------- ### Enable Watch Mode with Default Interval Source: https://github.com/dalance/procs/blob/master/README.md Use the --watch option to enable automatic output updates, similar to 'top'. The default update interval is 1 second. ```console procs --watch ``` -------------------------------- ### Enable Watch Mode Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Enable watch mode, which updates the display continuously with a 1-second interval, similar to the 'top' command. Keyboard controls are available for navigation and sorting within watch mode. ```bash procs --watch ``` -------------------------------- ### Style Configuration by Process State Source: https://github.com/dalance/procs/blob/master/_autodocs/types.md Maps process states (e.g., running, sleeping, zombie) to specific colors, using theme-aware color pairs for each state. ```rust pub struct ConfigStyleByState { pub color_d: ConfigColorByTheme, pub color_r: ConfigColorByTheme, pub color_s: ConfigColorByTheme, pub color_t: ConfigColorByTheme, pub color_z: ConfigColorByTheme, pub color_x: ConfigColorByTheme, pub color_k: ConfigColorByTheme, pub color_w: ConfigColorByTheme, pub color_p: ConfigColorByTheme, } ``` -------------------------------- ### Logical AND for Multi-Keyword Search Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Match processes that satisfy ALL specified keywords. This is the default behavior for multiple keywords and conflicts with --or, --nand, and --nor options. ```bash procs --and bash zsh ``` -------------------------------- ### Search Processes by Keyword Source: https://github.com/dalance/procs/blob/master/README.md Use 'procs' with a keyword argument to filter processes. By default, it searches the 'USER' and 'Command' columns. ```console procs zsh ``` -------------------------------- ### Show processes in tree view Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Display processes in a hierarchical tree structure, showing parent-child relationships. Can be combined with filtering. ```bash procs --tree # Show all processes in tree procs --tree firefox # Show firefox and parents/children ``` -------------------------------- ### Configure Passwordless Sudo for Procs Source: https://github.com/dalance/procs/blob/master/README.md Add an entry to the sudoers file to allow passwordless execution of the procs binary. Replace '[user or group]' and '[procs binary path]' with actual values. ```text [user or group] ALL= NOPASSWD: [procs binary path] // ex. myuser ALL= NOPASSWD: /usr/local/bin/procs ``` -------------------------------- ### Force color theme Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Force a specific color theme for styling the output. Options include 'auto', 'dark', and 'light'. ```bash procs --theme dark # Dark theme colors procs --theme light # Light theme colors ``` -------------------------------- ### Configure Style Settings Source: https://github.com/dalance/procs/blob/master/_autodocs/configuration.md Customize the color scheme for various elements in the Procs output, including headers, units, and different styling modes like ByPercentage, ByState, and ByUnit. ```toml [style] header = "BrightWhite|Black" unit = "BrightWhite|Black" tree = "BrightWhite|Black" [style.by_percentage] color_000 = "BrightBlue|Blue" color_025 = "BrightGreen|Green" color_050 = "BrightYellow|Yellow" color_075 = "BrightRed|Red" color_100 = "BrightRed|Red" [style.by_state] color_d = "BrightRed|Red" color_r = "BrightGreen|Green" color_s = "BrightBlue|Blue" color_t = "BrightCyan|Cyan" color_z = "BrightMagenta|Magenta" color_x = "BrightMagenta|Magenta" color_k = "BrightYellow|Yellow" color_w = "BrightYellow|Yellow" color_p = "BrightYellow|Yellow" [style.by_unit] color_k = "BrightBlue|Blue" color_m = "BrightGreen|Green" color_g = "BrightYellow|Yellow" color_t = "BrightRed|Red" color_p = "BrightRed|Red" color_x = "BrightBlue|Blue" ``` -------------------------------- ### Logical NAND for Multi-Keyword Search Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Match processes that do NOT satisfy ALL specified keywords (logical NAND). This conflicts with --and, --or, and --nor options. ```bash procs --nand bash zsh ``` -------------------------------- ### Sorting Options Source: https://github.com/dalance/procs/blob/master/_autodocs/README.md Sort processes by a specified column in ascending or descending order. ```bash procs --sorta cpu # Sort by CPU ascending procs --sortd rss # Sort by memory descending ``` -------------------------------- ### Style Configuration by Unit Source: https://github.com/dalance/procs/blob/master/_autodocs/types.md Assigns theme-aware colors to different memory unit suffixes (K, M, G, T, P, etc.) for consistent display. Used for memory-related values. ```rust pub struct ConfigStyleByUnit { pub color_k: ConfigColorByTheme, pub color_m: ConfigColorByTheme, pub color_g: ConfigColorByTheme, pub color_t: ConfigColorByTheme, pub color_p: ConfigColorByTheme, pub color_x: ConfigColorByTheme, } ``` -------------------------------- ### Error Handling with Anyhow Source: https://github.com/dalance/procs/blob/master/_autodocs/architecture.md Shows a typical error handling pattern using the `anyhow` crate in Rust. It demonstrates how to propagate errors with context and display a user-friendly error chain to stderr. ```rust fn main() { if let Err(x) = run() { let mut cause = x.chain(); eprintln!("error: {}", cause.next().unwrap()); for x in cause { eprintln!(" caused by: {}", x); } std::process::exit(1); } } ``` -------------------------------- ### Theme-aware Color Styling Source: https://github.com/dalance/procs/blob/master/_autodocs/configuration.md Demonstrates how to specify theme-aware colors for styling elements. Supports fixed colors, theme-specific combinations, and 256-color mode. ```TOML style = "BrightWhite|Black" # Bright white on dark theme, black on light theme style = "BrightWhite" # Bright white on both themes style = "223|112" # 256-color mode: color 223 dark, color 112 light ``` -------------------------------- ### Output process information in JSON format Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Output process information in JSON format instead of the default table format. Useful for programmatic processing of the output. ```bash procs --json ``` -------------------------------- ### Sort Processes by CPU Time Ascending Source: https://github.com/dalance/procs/blob/master/README.md Sort processes by CPU time in ascending order using the --sorta option followed by the column keyword 'cpu'. ```console procs --sorta cpu ``` -------------------------------- ### ConfigTheme Enum Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/config-structures.md Defines the color theme for the process display. Options include Auto, Dark, and Light. ```rust pub enum ConfigTheme { Auto, // Detect dark/light from terminal Dark, // Force dark theme colors Light, // Force light theme colors } ``` -------------------------------- ### Basic Search Keywords Source: https://github.com/dalance/procs/blob/master/_autodocs/README.md Use text or numeric keywords to filter processes. Supports AND logic by default. ```bash procs zsh # Text keyword (partial match by default) procs 1234 # Numeric keyword (exact match by default) ``` -------------------------------- ### add Method Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/column-trait.md Ingests process information and stores/formats relevant data. Called for each process, it extracts, formats, and stores data internally, typically keyed by PID. ```APIDOC ## Required Methods ### add **Signature:** ```rust fn add(&mut self, proc: &ProcessInfo) ``` **Purpose:** Ingest process information and store/format relevant data. **Parameters:** - `proc: &ProcessInfo` — Process information from OS-specific reader **Returns:** None **Description:** Called for each process. Implementation extracts the relevant field(s) from `ProcessInfo`, performs formatting, and stores the result internally (typically in HashMaps keyed by PID). **Example implementation:** ```rust fn add(&mut self, proc: &ProcessInfo) { let raw_content = proc.pid; let fmt_content = format!("{raw_content}"); self.fmt_contents.insert(proc.pid, fmt_content); self.raw_contents.insert(proc.pid, raw_content); } ``` ``` -------------------------------- ### Display Formatting Options Source: https://github.com/dalance/procs/blob/master/_autodocs/types.md Controls various display settings such as visibility of self, threads, and parents, header/footer display, color modes, separators, and sorting direction symbols. Also includes theme and abbreviation settings. ```rust pub struct ConfigDisplay { pub show_self: bool, pub show_self_parents: bool, pub show_thread: bool, pub show_thread_in_tree: bool, pub show_parent_in_tree: bool, pub show_children_in_tree: bool, pub show_header: bool, pub show_footer: bool, pub show_kthreads: bool, pub cut_to_terminal: bool, pub cut_to_pager: bool, pub cut_to_pipe: bool, pub color_mode: ConfigColorMode, pub separator: String, pub ascending: String, pub descending: String, pub tree_symbols: [String; 5], pub abbr_sid: bool, pub theme: ConfigTheme, } ``` -------------------------------- ### Show Thread Information Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Include thread information in the output. This option is only applicable on Linux and normally threads are hidden by default. ```bash procs --thread ``` -------------------------------- ### Default Styling for Percentage-Based Colors Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/config-structures.md Provides the default color configurations for different percentage ranges in ConfigStyleByPercentage. ```rust color_000: BrightBlue|Blue // Low percentage color_025: BrightGreen|Green // Medium-low color_050: BrightYellow|Yellow // Medium color_075: BrightRed|Red // High color_100: BrightRed|Red // Very high ``` -------------------------------- ### Column Management Source: https://github.com/dalance/procs/blob/master/_autodocs/README.md Control which columns are displayed and their order. Use --insert to add columns and --only to specify a subset. ```bash procs --insert ppid --insert cgroup # Add columns at Slot positions procs --only pid # Show only one column ``` -------------------------------- ### Generate man page Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Generate and print the man page for procs to standard output. This can be piped to gzip for compression. ```bash procs --gen-man-page | gzip > procs.1.gz ``` -------------------------------- ### Style Configuration Structure Source: https://github.com/dalance/procs/blob/master/_autodocs/types.md Configures various styling aspects, including headers, units, and value-based coloring. It references theme-aware color configurations for different elements. ```rust pub struct ConfigStyle { pub header: ConfigColorByTheme, pub unit: ConfigColorByTheme, pub tree: ConfigColorByTheme, pub by_percentage: ConfigStyleByPercentage, pub by_state: ConfigStyleByState, pub by_unit: ConfigStyleByUnit, } ``` -------------------------------- ### Rust: Default Implementation for Column Availability Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/column-trait.md Provides a default implementation returning true, indicating the column is available. Override this method to return false for columns not supported on specific platforms. ```rust fn available(&self) -> bool { true } ``` -------------------------------- ### Logical OR for Multi-Keyword Search Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/command-line-options.md Match processes that satisfy ANY of the specified keywords. This conflicts with --and, --nand, and --nor options. ```bash procs --or bash zsh ``` -------------------------------- ### Run All Tests Source: https://github.com/dalance/procs/blob/master/_autodocs/README.md Executes all tests defined within the project to ensure code correctness and stability. ```bash cargo test ``` -------------------------------- ### Configure a Display Column Source: https://github.com/dalance/procs/blob/master/_autodocs/configuration.md Define a column to display in the Procs output. Customize its kind, styling, search behavior, alignment, and width. ```toml [[columns]] kind = "Pid" style = "BrightYellow|Yellow" numeric_search = true nonnumeric_search = false align = "Right" max_width = 10 ``` -------------------------------- ### Implement Search in Custom Code Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/utility-functions.md Filters a list of columns to find those matching numeric keywords and then performs an exact search for a specific PID using provided search logic and case sensitivity settings. ```rust // Get all columns that match numeric keywords let numeric_columns: Vec<&dyn Column> = columns .iter() .filter(|ci| ci.numeric_search) .map(|ci| ci.column.as_ref()) .collect(); // Search for PID 1234 if find_exact(&numeric_columns, pid, &["1234"], &ConfigSearchLogic::And, &ConfigSearchCase::Smart) { // Process matches } ``` -------------------------------- ### Build without Docker Support Source: https://github.com/dalance/procs/blob/master/_autodocs/README.md Builds the project in release mode, explicitly disabling default features like Docker support. ```bash cargo build --release --no-default-features ``` -------------------------------- ### Procs Project Structure Source: https://github.com/dalance/procs/blob/master/_autodocs/architecture.md The project is organized into several modules, each handling a specific aspect of the application's functionality, from the entry point to OS-specific process gathering and rendering. ```rust src/ ├── main.rs # Entry point, CLI flow control ├── opt.rs # Command-line argument parsing ├── config.rs # Configuration structures (TOML) ├── column.rs # Column trait definition ├── columns.rs # Column module aggregation ├── columns/ # Individual column implementations │ ├── pid.rs │ ├── user.rs │ ├── vm_rss.rs │ └── 50+ more ├── process.rs # Platform-specific process info ├── process/ # OS-specific process gathering │ ├── linux.rs │ ├── macos.rs │ ├── windows.rs │ └── freebsd.rs ├── view.rs # View orchestration and rendering ├── watcher.rs # Watch mode (continuous updates) ├── style.rs # Color and styling application ├── search_regex.rs # Regex engine selection ├── term_info.rs # Terminal information └── util.rs # Helper functions ``` -------------------------------- ### Default Search Configuration Source: https://github.com/dalance/procs/blob/master/_autodocs/api-reference/config-structures.md Outlines the default settings for numeric and non-numeric search behavior, multi-keyword logic, and case sensitivity in ConfigSearch. ```rust Numeric exact match, text partial match, AND logic, smart case. ``` -------------------------------- ### Configure Docker Daemon Connection Source: https://github.com/dalance/procs/blob/master/_autodocs/configuration.md Sets the connection path for the Docker daemon, used for resolving container names. ```toml [docker] path = "unix:///var/run/docker.sock" ``` -------------------------------- ### Filter and Control Output Format Source: https://github.com/dalance/procs/blob/master/_autodocs/INDEX.md Manage process viewing with options for continuous updates, JSON output, disabling colors, and hiding the header row. ```bash procs --watch # Continuous updates procs --json # JSON output procs --color disable # Disable colors procs --no-header # Hide header row ``` -------------------------------- ### ConfigTheme Enum Source: https://github.com/dalance/procs/blob/master/_autodocs/types.md Defines theme selection for color application in the terminal. ```rust pub enum ConfigTheme { Auto, // Auto-detect theme from terminal Dark, // Dark theme colors Light, // Light theme colors } ```