README
pathmaster
Table of Contents
- README
- pathmaster
- pathmaster
Introduction
pathmaster is a powerful command-line tool written in Rust for managing your system's PATH environment variable. It simplifies the process of adding and removing directories from your PATH, ensures backups are created automatically, and provides tools to restore previous configurations.
Managing the PATH variable is crucial for system performance and command execution. pathmaster provides a safe and efficient way to handle PATH modifications, with features designed to prevent errors and maintain system stability.
pathmaster
New in Version 0.2.2
- Enhanced PATH validation and scanning capabilities
- Improved detection of PATH modifications across system
- Accurate identification of PATH entry sources
- Better handling of different shell configurations
- Fixed issues with PATH entry detection and validation
Features
Core Features (Updated in 0.2.2)
- Enhanced PATH Scanning: More accurate detection of PATH modifications
- Source Identification: Identifies whether PATH modifications require sudo
- Improved Validation: Better handling of different PATH modification formats
- Shell Support: Enhanced detection of shell-specific configurations
- Framework Integration: Better support for shell framework configurations
- Safety Features: Automatic backups, configuration preservation, validation
Path Management
- Add/remove directories from PATH
- List current PATH entries
- Validate PATH entries
- Automatic backups
- Configuration preservation
- Detailed feedback
Safety Features
- Automatic backups before modifications
- Shell configuration preservation
- Detailed user feedback
- Recovery options
Usage
Checking PATH Sources
Now provides enhanced output showing:
- Invalid directories in PATH
- Source of each PATH modification
- Whether sudo is required for changes
- Shell-specific configuration details
Flushing Invalid Paths
Improved in v0.2.2 with:
- More accurate invalid path detection
- Better feedback for removed paths
- Enhanced shell configuration handling
- Improved backup creation
Configuration Files
pathmaster now better handles various configuration files:
- Shell-specific files (.bashrc, .zshrc)
- System-wide configurations (/etc/profile, etc.)
- Shell framework configurations
- Distribution-specific locations
Documentation
Please see the man page (man pathmaster) for detailed information about all commands and features.
Technical Details
For v0.2.2, significant improvements were made to:
- PATH modification detection
- Shell configuration handling
- System vs user file differentiation
- Framework integration
- Error handling and reporting
Upgrading
When upgrading to v0.2.2:
- Backup your current configuration
- Update using your package manager or cargo
- Review any system-wide PATH modifications
- Check shell framework compatibility
Known Issues
None in current release.
Coming in Future Releases
- Backup mode configuration (v0.2.3)
- Additional shell framework support
- Enhanced configuration options
- Performance optimizations
Features
- Effortless Management: Easily add or remove directories from your
PATH. - Automatic Backups: Creates time-stamped backups of your
PATHbefore any changes. - Restoration: Restore your
PATHfrom any previous backup. - Listing: View all current entries in your
PATH. - Cross-Platform: Compatible with Unix/Linux and macOS systems.
- Safe Modifications: Validates directories before adding them to prevent errors.
- Persistent Changes: Updates your shell configuration to make changes permanent.
- Enhanced Path Validation: Robust detection and removal of invalid PATH entries
- Shell Configuration Safety: Automatic backup of shell configuration files before modifications
- Detailed Feedback: Clear reporting of all PATH modifications and their outcomes
- Session and Permanent Changes: Updates both current session and shell configuration files
Installation
Prerequisites
-
Rust Toolchain: Ensure you have Rust installed. You can install Rust using rustup:
|
Building from Source
-
Clone the Repository
-
Build the Project
This command compiles the project in release mode, producing an optimized binary.
-
Install the Binary
Optionally, you can install the binary system-wide:
Or add it to your
PATH:
Usage
Command Overview
Commands
add
Add a directory to your PATH.
Usage:
Options:
<directory>: The directory path to add to yourPATH.
remove
Remove a directory from your PATH.
Usage:
Options:
<directory>: The directory path to remove from yourPATH.
list
List all current entries in your PATH.
Usage:
check
Validate current PATH entries and identify invalid or missing directories.
Usage:
Example Output:
flush
The flush command provides a safe way to remove invalid directories from your PATH:
Usage:
# or
Process:
- Creates a backup of current PATH
- Creates a backup of shell configuration file
- Identifies invalid directory entries
- Removes invalid entries from PATH
- Updates shell configuration for persistence
- Provides detailed feedback about changes
Safety Features:
- Automatic PATH backup creation
- Shell configuration file backup
- Detailed removal reporting
- Recovery options via backup system
- Session-only fallback if configuration update fails
Example Output:
)
history
Show the backup history of your PATH.
Usage:
restore
Restore your PATH from a previous backup.
Usage:
Options:
--timestamp <timestamp>: (Optional) The timestamp of the backup to restore. If not provided, the most recent backup is used.
Examples
-
Add a Directory to PATH
-
Remove a Directory from PATH
-
List PATH Entries
Sample Output:
Current PATH entries: - /usr/local/bin - /usr/bin - /bin - /usr/local/sbin - /usr/sbin - /sbin - ~/my/custom/bin -
Show Backup History
Sample Output:
Available backups: - backup_20231007_120000.json - backup_20231008_090000.json -
Restore PATH from a Specific Backup
-
Restore PATH from the Most Recent Backup
Configuration
pathmaster modifies your shell configuration file to make changes to PATH persistent across sessions.
- Supported Shells: Bash (
.bashrc), Zsh (.zshrc), or a generic.profileif the shell is not recognized. - Backup Directory: Backups are stored in
~/.pathmaster_backups.
Note: Always review changes made to your shell configuration files. pathmaster adds an export command to update your PATH.
Backup Management
pathmaster provides flexible backup management with configurable backup modes:
Backup Modes
Use the --backup-mode flag to control what gets backed up:
default: Back up both PATH and shell configurations (default behavior)path: Back up only PATH entriesshell: Back up only shell configurationswitch: Toggle between PATH-only and shell-only backups
Examples:
# Only back up PATH when adding a directory
# Only back up shell config when flushing invalid paths
# Reset to backing up both
# Toggle between backup modes
Backup Storage
- PATH Backups: Stored as JSON files in
~/.pathmaster_backups - Shell Configuration Backups: Created as
.bakfiles alongside your shell config:- Bash:
~/.bashrc.bak - Zsh:
~/.zshrc.bak - Generic:
~/.profile.bak
- Bash:
Contributing
Contributions are welcome! Please follow these steps:
-
Fork the Repository
-
Create a Feature Branch
-
Commit Your Changes
-
Push to the Branch
-
Create a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.