pkgs
is a command-line too
8000
l that provides a unified interface for package management across different operating
systems. It wraps around native package managers like apt
, dnf
, yum
, apk
, pacman
, and brew
, allowing you
to use the same commands regardless of the underlying system.
- Unified commands across different operating systems (Linux distributions and macOS)
- Automatic detection of the system's package manager
- Support for common package management operations
- Intelligent privilege handling:
- Automatic sudo elevation on Linux when required
- No sudo usage on macOS with Homebrew (as recommended)
- Intelligent handling of package manager-specific behaviors
brew
(macOS)apt
(Debian, Ubuntu)dnf
(Fedora, RHEL 8+)yum
(CentOS, RHEL 7 and earlier)apk
(Alpine)pacman
(Arch)
git clone https://github.com/mobydeck/pkgs.git
cd pkgs
just build
sudo just install
git clone https://github.com/mobydeck/pkgs.git
cd pkgs
go build
sudo mv pkgs /usr/local/bin/
The project includes a justfile with the following commands:
# Build the application
just build
# Install the application to /usr/local/bin
just install
# Clean build artifacts
just clean
# Show the current version
just version
# Build for specific platforms
just build-linux-amd64
just build-macos-arm64
just build-windows-amd64
# Build for all platforms
just build-all
# Create release packages
just package
These commands handle the package manager-specific details, making it easier to manage packages across different systems:
# Install packages
pkgs install nginx
pkgs i vim git curl
# Reinstall packages
pkgs reinstall nginx
pkgs ri vim git curl
# Remove packages
pkgs remove nginx
pkgs rm vim git curl
# Search for packages
pkgs search nginx
pkgs s python
# Show package information
pkgs info nginx
pkgs show vim
# Update package lists
pkgs update
pkgs up
# Upgrade all packages
pkgs upgrade
pkgs ug
# Remove unused packages
pkgs autoremove
# Clean package cache
pkgs clean
# Show which package manager is being used
pkgs which
# Show only the package manager name (useful for scripting)
pkgs which -s
For example, a script could now do something like:
PM=$(pkgs which -s)
if [ "$PM" = "apt" ]; then
# Do something specific for apt systems
elif [ "$PM" = "brew" ]; then
# Do something specific for Homebrew systems
fi
These commands handle the package manager-specific details, making it easier to manage repositories across different systems:
# Add a repository key
pkgs add-key [name] url
# Examples:
# For apt-based systems (Debian/Ubuntu)
pkgs add-key nodesource https://deb.nodesource.com/gpgkey/nodesource.gpg.key
# For Alpine Linux
pkgs add-key alpine-key https://alpine-keys.example.com/key.rsa.pub
# Add a repository
pkgs add-repo [name] url
# Examples:
# For apt-based systems (Debian/Ubuntu)
pkgs add-repo nodesource "deb [signed-by=/etc/apt/keyrings/nodesource.asc] https://deb.nodesource.com/node_20.x nodistro main"
# For dnf/yum-based systems (Fedora/RHEL/CentOS)
pkgs add-repo https://download.docker.com/linux/fedora/docker-ce.repo
# For Alpine Linux
pkgs add-repo edge-testing https://dl-cdn.alpinelinux.org/alpine/edge/testing
# For Homebrew
pkgs add-repo homebrew/cask-fonts
# Enable a repository
pkgs enable-repo name
# Examples:
# For apt-based systems (Debian/Ubuntu)
pkgs enable-repo nodesource
# For dnf/yum-based systems
pkgs enable-repo docker-ce
# For Alpine Linux
pkgs enable-repo edge-testing
# Disable a repository
pkgs disable-repo name
# Examples:
# For apt-based systems (Debian/Ubuntu)
pkgs disable-repo nodesource
# For dnf/yum-based systems
pkgs disable-repo docker-ce
# For Alpine Linux
pkgs disable-repo edge-testing
# List all repositories with their status (enabled/disabled)
pkgs list-repos
# Show general help
pkgs --help
# Show command-specific help
pkgs install --help
# Show version information
pkgs --version
For CI/CD pipelines and automation scripts, you can use the --yes
or -y
flag to run commands non-interactively:
# Install packages without prompting
pkgs -y install nginx
# Update and upgrade without prompting
pkgs -y update && pkgs -y upgrade
# Remove packages without prompting
pkgs -y remove nginx
This flag automatically adds the appropriate non-interactive flag to the underlying package manager:
-y
for apt, dnf, and yum--noconfirm
for pacman- No additional flag for brew and apk (as they're already non-interactive by default)
Alternatively, you can set the PKGS_YES
environment variable to achieve the same effect:
# Set the environment variable for the current session
export PKGS_YES=true
# Now all commands will run in non-interactive mode
pkgs install nginx
pkgs update
pkgs remove nginx
# You can also set it for a single command
PKGS_YES=1 pkgs install nginx
The PKGS_YES
environment variable accepts the following values (case-insensitive):
true
,yes
,1
,y
: Enable non-interactive mode- Any other value or unset: Use the default interactive mode
On macOS systems, pkgs
automatically detects and uses Homebrew. Some key differences when using Homebrew:
- Commands never use sudo (as recommended by Homebrew)
autoremove
runs bothbrew autoremove
to remove unused dependencies andbrew cleanup
to remove old versionsremove
usesbrew uninstall
instead of remove/purgereinstall
usesbrew reinstall
to reinstall packagesadd-repo
usesbrew tap
to add new tapsadd-key
is not applicable for Homebrewlist-repos
shows all taps
Each Linux package manager has its own specific implementation:
apt
(Debian/Ubuntu):- Uses
--purge
for thorough removal - Uses
--reinstall
flag for reinstalling packages add-key
saves keys to/etc/apt/keyrings/name.asc
add-repo
creates files in/etc/apt/sources.list.d/name.list
enable-repo
uncomments entries in repository filesdisable-repo
comments out entries in repository fileslist-repos
shows repositories from/etc/apt/sources.list
and/etc/apt/sources.list.d/
- Uses
dnf
/yum
(RedHat):- Uses
check-update
for the update command - Has a dedicated
reinstall
command add-repo
creates files in/etc/yum.repos.d/
directoryadd-key
provides guidance for usingrpm --import
enable-repo
setsenabled=1
in repository filesdisable-repo
setsenabled=0
in repository fileslist-repos
shows repositories from/etc/yum.repos.d/
- Uses
apk
(Alpine):- Uses
add
anddel
instead of install/remove - Uses
add --force-overwrite
for reinstalling add-key
adds keys to/etc/apk/keys/
add-repo
adds repositories to/etc/apk/repositories
enable-repo
uncomments repository entriesdisable-repo
comments out repository entrieslist-repos
shows repositories from/etc/apk/repositories
- Uses
pacman
(Arch):- Uses special flags like
-S
,-Rns
, etc. - Uses
-S --needed
for reinstalling packages add-key
provides guidance for usingpacman-key --add
add-repo
provides guidance for manually editing/etc/pacman.conf
enable-repo
anddisable-repo
provide guidance for manually editing/etc/pacman.conf
list-repos
shows repositories from/etc/pacman.conf
- Uses special flags like
On Linux systems, package management operations typically require root privileges. The pkgs
tool will:
- Check if the current user has root privileges
- If not, automatically use
sudo
to elevate privileges for commands that require it - If
sudo
is not available, provide a clear error message
Commands that require privilege elevation:
- install
- reinstall
- remove
- update
- upgrade
- autoremove
- clean
- add-key
- add-repo
- enable-repo
- disable-repo
- list-repos
MIT License
Contributions are welcome! Please feel free to submit a Pull Request.