Crates.io | pathmaster |
lib.rs | pathmaster |
version | 0.2.3 |
source | src |
created_at | 2024-10-23 03:28:42.988237 |
updated_at | 2024-10-28 00:28:11.451627 |
description | pathmaster is a powerful command-line tool written in Rust for managing your system's PATH environment variable. |
homepage | |
repository | https://github.com/jwliles/pathmaster |
max_upload_size | |
id | 1419635 |
size | 117,413 |
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.
# Only back up PATH when adding a directory
pathmaster --backup-mode path add ~/bin
# Only back up shell config when flushing invalid paths
pathmaster --backup-mode shell flush
# Reset to backing up both
pathmaster --backup-mode default
# Toggle between backup modes
pathmaster --backup-mode switch
pathmaster check
Now provides enhanced output showing:
pathmaster flush
Improved in v0.2.2 with:
pathmaster now better handles various configuration files:
Please see the man page (man pathmaster
) for detailed information about all commands and features.
For v0.2.2, significant improvements were made to:
When upgrading to v0.2.2:
None in current release.
PATH
.PATH
before any changes.PATH
from any previous backup.PATH
.Rust Toolchain: Ensure you have Rust installed. You can install Rust using rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Clone the Repository
git clone https://github.com/jwliles/pathmaster.git
cd pathmaster
Build the Project
cargo build --release
This command compiles the project in release mode, producing an optimized binary.
Install the Binary
Optionally, you can install the binary system-wide:
sudo cp target/release/pathmaster /usr/local/bin/
Or add it to your PATH
:
export PATH="$PATH:$(pwd)/target/release"
pathmaster [COMMAND] [OPTIONS]
Add a directory to your PATH
.
Usage:
pathmaster add <directory>
Options:
<directory>
: The directory path to add to your PATH
.Remove a directory from your PATH
.
Usage:
pathmaster remove <directory>
Options:
<directory>
: The directory path to remove from your PATH
.List all current entries in your PATH
.
Usage:
pathmaster list
Validate current PATH entries and identify invalid or missing directories.
Usage:
pathmaster check
Example Output:
Invalid directories in PATH:
/home/user/.config/emacs/bin
/home/user/old/scripts
The flush
command provides a safe way to remove invalid directories from your PATH:
Usage:
pathmaster flush
# or
pathmaster -f
Process:
Safety Features:
Example Output:
Created backup of shell config at: /home/user/.bashrc.bak
Removing invalid path: /home/user/.config/emacs/bin
Removing invalid path: /home/user/old/scripts
Successfully removed 2 invalid path(s) and updated shell configuration.
Show the backup history of your PATH
.
Usage:
pathmaster history
Restore your PATH
from a previous backup.
Usage:
pathmaster restore [--timestamp <timestamp>]
Options:
--timestamp <timestamp>
: (Optional) The timestamp of the backup to restore. If not provided, the most recent backup is used.Add a Directory to PATH
pathmaster add ~/my/custom/bin
Remove a Directory from PATH
pathmaster remove ~/my/old/bin
List PATH Entries
pathmaster list
Sample Output:
Current PATH entries:
- /usr/local/bin
- /usr/bin
- /bin
- /usr/local/sbin
- /usr/sbin
- /sbin
- ~/my/custom/bin
Show Backup History
pathmaster history
Sample Output:
Available backups:
- backup_20231007_120000.json
- backup_20231008_090000.json
Restore PATH from a Specific Backup
pathmaster restore --timestamp 20231007_120000
Restore PATH from the Most Recent Backup
pathmaster restore
pathmaster now supports configurable backup modes to provide more control over what gets backed up during operations. This can be especially useful when:
pathmaster
modifies your shell configuration file to make changes to PATH
persistent across sessions.
.bashrc
), Zsh (.zshrc
), or a generic .profile
if the shell is not recognized.~/.pathmaster_backups
.Note: Always review changes made to your shell configuration files. pathmaster
adds an export command to update your PATH
.
pathmaster provides flexible backup management with configurable 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 backupsExamples:
# Only back up PATH when adding a directory
pathmaster --backup-mode path add ~/bin
# Only back up shell config when flushing invalid paths
pathmaster --backup-mode shell flush
# Reset to backing up both
pathmaster --backup-mode default
# Toggle between backup modes
pathmaster --backup-mode switch
~/.pathmaster_backups
.bak
files alongside your shell config:
~/.bashrc.bak
~/.zshrc.bak
~/.profile.bak
Contributions are welcome! Please follow these steps:
Fork the Repository
Create a Feature Branch
git checkout -b feature/your-feature
Commit Your Changes
git commit -am 'Add your feature'
Push to the Branch
git push origin feature/your-feature
Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.