Path-keeper is a powerful command-line tool for managing, organizing, and executing frequently-used commands with ease. It features multi-level categorization, execution logging, shell aliases, and extensive customization options.
This version includes significant bug fixes and new features:
- Fixed missing method implementations
- Resolved shell script integration issues
- Improved error handling and parameter passing
- Enhanced interactive command detection
- Stabilized editor mode and multi-line support
- Command Recording: Add, view, and execute command history
- Multi-level Categorization: Supports command categorization (e.g., 1.2 represents the second command under the first category)
- Configuration Management: Configurable default execution shell and editor
- Recent Command Execution: Quickly re-run your most recently executed command
- Shell Integration: Seamless bash/zsh integration with automatic interactive program detection
- Execution Logging: Optional per-command logging with timestamp and output capture
- Interactive Search: Use fzf for fuzzy-find command selection
- Hash Verification: Verify command integrity to detect configuration tampering
- Shell Aliases: Create convenient shell aliases for frequently used command indices
- Multi-line Commands: Support for editor-based multi-line command entry
- Flexible Log Control: Per-command logging override with global fallback settings
- Fzf and tmux needing if you want to use searching and command logging functions
- Quick Execution: Use the
-pparameter to execute a command without updating the recent record - Categorization Management: Properly categorize commands when adding them for easier retrieval
- Multi-line Commands: Press enter without input to open editor mode when adding commands
- Shell Integration: Source the pk.sh script in your shell for proper command execution and terminal handling
# View current directory and run recent command (if set)
pk
# Add a new command record
pk -a
# View all records
pk -s
# Execute the first category command
pk -e 1
# Execute a specific command (e.g., 2nd command in 1st category)
pk -e 1.2
# Execute without updating recent record
pk -p 1
# Set the recent command for quick access
pk -c-a, --add Add new command record (single-line or multi-line editor mode)
-e [index] Execute command by index and update recent record
-p [index] Execute command by index without updating recent record
-s, --show Display all recorded commands organized by category
-c, --configure Set the recent command record
-v, --version Display version information
-V, --version-verbose
Display detailed version and build information
-h, --help Show detailed help message
Configuration Management:
config Open config file in default editor
config -editor Set editor interactively (or specify directly)
config -editor vim Set editor to specific command
Advanced Features:
alias add <name> <index> Add alias for quick command execution
alias remove <name> Remove alias
alias list List all aliases
alias install Generate shell alias file (~/.pk_aliases.sh)
search Interactive search with fzf
verify Verify command integrity
rehash Regenerate and save command hashes
log List and view log files
When adding commands, you can choose logging behavior:
y (Force Log): Command output always logged
n (Force No Log): Command output never logged
Empty/Enter: Uses global log.enabled setting
The pk.sh script provides the following features:
- Automatic Stdout/Stderr Handling: Command output properly captured and executed
- Interactive Program Detection: Automatically detects vim, nano, emacs, less, more, htop, man
- Robust Command Extraction: Handles logging wrapper commands and removes debug output
- Terminal Compatibility: Works with bash, zsh, dash, ksh, and fish
Shell integration is enabled by sourcing pk.sh in your shell configuration:
source /usr/local/share/path-keeper/pk.sh# Ubuntu/Debian:
sudo apt update
sudo apt install cmake pkg-config libjsoncpp-dev build-essential
sudo apt install qt5-qmake qt5-default
# CentOS/RHEL:
sudo yum install cmake pkgconfig jsoncpp-devel gcc-c++
sudo yum install qt5-devel
# Fedora:
sudo dnf install cmake pkgconfig jsoncpp-devel gcc-c++
sudo dnf install qt5-develTip
This programe needs fzf and tmux.It should be executed in a tmux session to record outputs.
Install fzf and tmux:
sudo apt install fzf tmuxClone the repository and build:
git clone https://github.com/upupwrite/path-keeper.git
cd path-keeper
mkdir build && cd build
cmake ..
makeInstall to the system (requires sudo privileges):
sudo make installEnable shell integration by adding to ~/.bashrc or ~/.zshrc:
source /usr/local/share/path-keeper/pk.shYou can add pk initiate script with this command:
echo 'source /usr/local/share/path-keeper/pk.sh' >> ~/.bashrcHash Verification:
Verify that your command configuration has not been tampered with:
pk verify # Check command integrity
pk rehash # Regenerate hashes after manual editsLog File Management:
- Timestamped log entries for audit trail
- Per-command execution tracking
Path-keeper supports multiple languages through Qt translations:
- English (en)
- Simplified Chinese (zh_CN)
The application automatically detects system locale and loads appropriate translations.
To build and run tests (if available):
cd build
cmake .. -DBUILD_TESTS=ON
make
ctestRun in the build directory:
sudo make uninstallAlternatively, uninstall manually:
sudo rm /usr/local/bin/pk
sudo rm -rf /usr/local/share/path-keeperOr manually delete installed files:
sudo rm /usr/local/bin/pkIssue: "pk: binary not found" Solution: Ensure /usr/local/bin is in your PATH
echo $PATH
which pkIssue: "No editors found" Solution: Install a common editor
sudo apt install vim # or nano, emacs, etc.Issue: "Failed to load translation" Solution: Verify Qt5/Qt6 installation
pkg-config --modversion Qt5CoreIssue: Commands not executing Solution: Check shell integration is sourced
grep "source.*pk.sh" ~/.bashrc
# If not found, add to ~/.bashrc:
echo "source /usr/local/share/path-keeper/pk.sh" >> ~/.bashrc
source ~/.bashrcIssue: Log files not created Solution: Ensure log directory exists and is writable
mkdir -p ~/.pk_logs
chmod 700 ~/.pk_logs- Command records are saved in a local file (~/.pk.json). Remember to back up important records.
- When using the -e parameter, ensure the index is valid.
- When adding commands, you can choose per-command logging behavior.
- Multi-line commands can be entered using the editor mode.
- Shell variables and aliases work in recorded commands.
- Environment is preserved from the directory specified in the record.
Search and Filter:
Use the search subcommand for fuzzy-find command selection:
pk search # Interactive search with fzf (requires fzf)View Logs:
List and view execution logs:
pk log # Show available log filesContributions and improvement suggestions are welcome! Please follow open-source community norms and submit PRs or Issues.
This project adheres to an open-source license. For details, please refer to the LICENSE file in the project root directory.
This project is licensed under the GNU General Public License v3.0 (GPLv3)
See the LICENSE file in the project root directory for full details.
For more information about GPLv3: https://www.gnu.org/licenses/gpl-3.0.html
For further details about the code, you can review the source code of the corresponding modules.
GitHub: https://github.com/upupwrite/path-keeper Author: upupwrite