feat(pkg): cross-platform package manager support #31
@@ -294,13 +294,13 @@ rm -f file.txt # Falls through to standard rm -f
|
|||||||
| `gitui` | Fast terminal Git UI |
|
| `gitui` | Fast terminal Git UI |
|
||||||
| `gi` | Generate and append `.gitignore` patterns from gitignore.io; `gi` (no args) appends boilerplate then prompts interactively; `gi <targets>` appends named patterns; `gi -s <targets>` prints to stdout; `gi -l` lists all targets |
|
| `gi` | Generate and append `.gitignore` patterns from gitignore.io; `gi` (no args) appends boilerplate then prompts interactively; `gi <targets>` appends named patterns; `gi -s <targets>` prints to stdout; `gi -l` lists all targets |
|
||||||
|
|
||||||
### Package Management (Arch / paru / yay)
|
### Package Management
|
||||||
|
|
||||||
| Function | Description |
|
| Function | Description |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `pkg <name>...` | Toggle package: installs if missing, removes (`-Rns`) if installed; `-i` force-install, `-u` force-uninstall |
|
| `pkg <name>...` | Toggle package: installs if missing, removes if present; `-i` force-install, `-u` force-uninstall. Auto-detects the system package manager (paru, yay, pacman, apt, dnf, zypper, yum, brew, pkg) |
|
||||||
| `search <query>` | Search/install interactively: `paru <query>` |
|
| `search <query>` | Search/install interactively: `paru <query>` (Arch only) |
|
||||||
| `upgrade` | Full system upgrade: `paru -Syu --noconfirm` |
|
| `upgrade` | Full system upgrade: `paru -Syu --noconfirm` (Arch only) |
|
||||||
| `cleanup` | Log and remove orphaned packages |
|
| `cleanup` | Log and remove orphaned packages |
|
||||||
|
|
||||||
`conf.d/paru-wrapper.fish` and `conf.d/yay-wrapper.fish` auto-generate thin wrapper scripts at `~/.local/bin/paru` and `~/.local/bin/yay` on first shell start (when the respective AUR helper is installed). These wrappers tee all output to timestamped log files in `SCROLLBACK_HISTORY_DIR` and prune old logs to stay under `SCROLLBACK_HISTORY_MAX_FILES`.
|
`conf.d/paru-wrapper.fish` and `conf.d/yay-wrapper.fish` auto-generate thin wrapper scripts at `~/.local/bin/paru` and `~/.local/bin/yay` on first shell start (when the respective AUR helper is installed). These wrappers tee all output to timestamped log files in `SCROLLBACK_HISTORY_DIR` and prune old logs to stay under `SCROLLBACK_HISTORY_MAX_FILES`.
|
||||||
|
|||||||
@@ -6,13 +6,13 @@
|
|||||||
#
|
#
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
# Detects and prints the name of the first available system package manager
|
# Detects and prints the name of the first available system package manager
|
||||||
# from the priority list: paru, yay, pacman, apt, brew, pkg, dnf, yum.
|
# from the priority list: paru, yay, pacman, apt, brew, pkg, dnf, zypper, yum.
|
||||||
# Prints an empty string if none are found.
|
# Prints an empty string if none are found.
|
||||||
#
|
#
|
||||||
# EXAMPLE
|
# EXAMPLE
|
||||||
# set pm (_fish_deps_detect_pm)
|
# set pm (_fish_deps_detect_pm)
|
||||||
function _fish_deps_detect_pm
|
function _fish_deps_detect_pm
|
||||||
for pm in paru yay pacman apt brew pkg dnf yum
|
for pm in paru yay pacman apt brew pkg dnf zypper yum
|
||||||
if type -q $pm
|
if type -q $pm
|
||||||
echo $pm
|
echo $pm
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
# Copyright (C) 2026 Rootiest
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
||||||
|
|
||||||
# SYNOPSIS
|
|
||||||
# claude [args...]
|
|
||||||
#
|
|
||||||
# DESCRIPTION
|
|
||||||
# Wrapper for the claude CLI that always injects --remote-control unless it
|
|
||||||
# is already present in the argument list.
|
|
||||||
#
|
|
||||||
# ARGUMENTS
|
|
||||||
# args... Arguments passed through to the claude command
|
|
||||||
#
|
|
||||||
# EXAMPLE
|
|
||||||
# claude "Refactor the auth module"
|
|
||||||
function claude --wraps='claude --remote-control' --description 'claude with --remote-control always enabled'
|
|
||||||
if contains -- --remote-control $argv
|
|
||||||
command claude $argv
|
|
||||||
else
|
|
||||||
command claude --remote-control $argv
|
|
||||||
end
|
|
||||||
end
|
|
||||||
+143
-44
@@ -5,8 +5,10 @@
|
|||||||
# pkg [-h] [-i|-u] <package> [package...]
|
# pkg [-h] [-i|-u] <package> [package...]
|
||||||
#
|
#
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
# Installs or removes Arch Linux packages via paru or yay. In auto mode
|
# Installs or removes packages using the system's available package manager.
|
||||||
# (no flag), detects whether each package is installed and toggles it.
|
# Supports paru, yay, pacman, apt, dnf, zypper, yum, brew, and pkg.
|
||||||
|
# In auto mode (no flag), detects whether each package is installed and
|
||||||
|
# toggles it — installing if absent, removing if present.
|
||||||
#
|
#
|
||||||
# ARGUMENTS
|
# ARGUMENTS
|
||||||
# -h, --help Show help message
|
# -h, --help Show help message
|
||||||
@@ -16,20 +18,18 @@
|
|||||||
#
|
#
|
||||||
# RETURNS
|
# RETURNS
|
||||||
# 0 Operation completed
|
# 0 Operation completed
|
||||||
# 1 No AUR helper found, unknown flag, or package operation failed
|
# 1 No supported package manager found, unknown flag, or package operation failed
|
||||||
#
|
#
|
||||||
# EXAMPLE
|
# EXAMPLE
|
||||||
# pkg firefox
|
# pkg firefox
|
||||||
function pkg --description 'Install or remove packages via paru or yay'
|
# pkg -i ripgrep fd-find
|
||||||
# ── AUR helper detection ─────────────────────────────────────
|
# pkg -u cowsay
|
||||||
set -l aur ""
|
function pkg --description 'Install or remove packages via the system package manager'
|
||||||
if type -q paru
|
# ── Package manager detection ────────────────────────────────
|
||||||
set aur paru
|
set -l pm (_fish_deps_detect_pm)
|
||||||
else if type -q yay
|
if test -z "$pm"
|
||||||
set aur yay
|
|
||||||
else
|
|
||||||
set_color red
|
set_color red
|
||||||
echo "error: no AUR helper found (install paru or yay)" >&2
|
echo "error: no supported package manager found" >&2
|
||||||
set_color normal
|
set_color normal
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
@@ -44,24 +44,21 @@ function pkg --description 'Install or remove packages via paru or yay'
|
|||||||
set -l c_dim (set_color brblack)
|
set -l c_dim (set_color brblack)
|
||||||
set -l c_reset (set_color normal)
|
set -l c_reset (set_color normal)
|
||||||
|
|
||||||
# ── Help ─────────────────────────────────────────────────────
|
# ── Installed-check helper ───────────────────────────────────
|
||||||
function _pkg_help
|
# Uses only its own arguments — safe to define as an inner function.
|
||||||
echo "$c_head""Usage:$c_reset $c_cmd""pkg$c_reset " \
|
function __pkg_is_installed --argument-names _pm _pkg
|
||||||
"$c_flag""[-h] [-i] [-u]$c_reset $c_dim""<package>...$c_reset"
|
switch $_pm
|
||||||
echo
|
case paru yay pacman
|
||||||
echo " Install or remove Arch packages via paru/yay."
|
pacman -Qi $_pkg &>/dev/null
|
||||||
echo
|
case apt
|
||||||
echo "$c_head""Flags:$c_reset"
|
dpkg -s $_pkg &>/dev/null
|
||||||
echo " $c_flag-h$c_reset, $c_flag--help$c_reset " \
|
case dnf zypper yum
|
||||||
"Show this help message"
|
rpm -q $_pkg &>/dev/null
|
||||||
echo " $c_flag-i$c_reset, $c_flag--install$c_reset " \
|
case brew
|
||||||
"Force install"
|
brew list $_pkg &>/dev/null
|
||||||
echo " $c_flag-u$c_reset, $c_flag--uninstall$c_reset " \
|
case pkg
|
||||||
"Force uninstall"
|
pkg info $_pkg &>/dev/null
|
||||||
echo
|
end
|
||||||
echo "$c_head""Auto mode (no flag):$c_reset"
|
|
||||||
echo " Checks if each package is installed and installs" \
|
|
||||||
"or removes accordingly."
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# ── Argument parsing ─────────────────────────────────────────
|
# ── Argument parsing ─────────────────────────────────────────
|
||||||
@@ -74,7 +71,7 @@ function pkg --description 'Install or remove packages via paru or yay'
|
|||||||
echo "$c_head""Usage:$c_reset $c_cmd""pkg$c_reset " \
|
echo "$c_head""Usage:$c_reset $c_cmd""pkg$c_reset " \
|
||||||
"$c_flag""[-h] [-i] [-u]$c_reset $c_dim""<package>...$c_reset"
|
"$c_flag""[-h] [-i] [-u]$c_reset $c_dim""<package>...$c_reset"
|
||||||
echo
|
echo
|
||||||
echo " Install or remove Arch packages via paru/yay."
|
echo " Install or remove packages via $pm."
|
||||||
echo
|
echo
|
||||||
echo "$c_head""Flags:$c_reset"
|
echo "$c_head""Flags:$c_reset"
|
||||||
echo " $c_flag-h$c_reset, $c_flag--help$c_reset " \
|
echo " $c_flag-h$c_reset, $c_flag--help$c_reset " \
|
||||||
@@ -87,15 +84,17 @@ function pkg --description 'Install or remove packages via paru or yay'
|
|||||||
echo "$c_head""Auto mode (no flag):$c_reset"
|
echo "$c_head""Auto mode (no flag):$c_reset"
|
||||||
echo " Checks if each package is installed and installs" \
|
echo " Checks if each package is installed and installs" \
|
||||||
"or removes accordingly."
|
"or removes accordingly."
|
||||||
|
functions -e __pkg_is_installed
|
||||||
return 0
|
return 0
|
||||||
case -i --install
|
case -i --install
|
||||||
set mode install
|
set mode install
|
||||||
case -u --uninstall
|
case -u --uninstall
|
||||||
set mode uninstall
|
set mode uninstall
|
||||||
case --
|
case --
|
||||||
# stop flag parsing (remaining args handled above)
|
# stop flag parsing
|
||||||
case '-*'
|
case '-*'
|
||||||
echo "$c_err""error:$c_reset unknown flag $c_flag$arg$c_reset" >&2
|
echo "$c_err""error:$c_reset unknown flag $c_flag$arg$c_reset" >&2
|
||||||
|
functions -e __pkg_is_installed
|
||||||
return 1
|
return 1
|
||||||
case '*'
|
case '*'
|
||||||
set packages $packages $arg
|
set packages $packages $arg
|
||||||
@@ -103,42 +102,142 @@ function pkg --description 'Install or remove packages via paru or yay'
|
|||||||
end
|
end
|
||||||
|
|
||||||
if test (count $packages) -eq 0
|
if test (count $packages) -eq 0
|
||||||
_pkg_help
|
echo "$c_head""Usage:$c_reset $c_cmd""pkg$c_reset " \
|
||||||
|
"$c_flag""[-h] [-i] [-u]$c_reset $c_dim""<package>...$c_reset"
|
||||||
|
echo
|
||||||
|
echo " Install or remove packages via $pm."
|
||||||
|
echo
|
||||||
|
echo "$c_head""Flags:$c_reset"
|
||||||
|
echo " $c_flag-h$c_reset, $c_flag--help$c_reset " \
|
||||||
|
"Show this help message"
|
||||||
|
echo " $c_flag-i$c_reset, $c_flag--install$c_reset " \
|
||||||
|
"Force install"
|
||||||
|
echo " $c_flag-u$c_reset, $c_flag--uninstall$c_reset " \
|
||||||
|
"Force uninstall"
|
||||||
|
echo
|
||||||
|
echo "$c_head""Auto mode (no flag):$c_reset"
|
||||||
|
echo " Checks if each package is installed and installs" \
|
||||||
|
"or removes accordingly."
|
||||||
|
functions -e __pkg_is_installed
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# ── Dispatch ─────────────────────────────────────────────────
|
# ── Mode dispatch ────────────────────────────────────────────
|
||||||
switch $mode
|
switch $mode
|
||||||
case install
|
case install
|
||||||
echo "$c_ok""→ Installing:$c_reset $packages"
|
echo "$c_ok""→ Installing:$c_reset $packages"
|
||||||
$aur -S $packages
|
switch $pm
|
||||||
|
case paru yay
|
||||||
|
$pm -S $packages
|
||||||
|
case pacman
|
||||||
|
sudo pacman -S $packages
|
||||||
|
case apt
|
||||||
|
sudo apt install -y $packages
|
||||||
|
case dnf
|
||||||
|
sudo dnf install -y $packages
|
||||||
|
case zypper
|
||||||
|
sudo zypper install -y $packages
|
||||||
|
case brew
|
||||||
|
brew install $packages
|
||||||
|
case pkg
|
||||||
|
sudo pkg install -y $packages
|
||||||
|
case yum
|
||||||
|
sudo yum install -y $packages
|
||||||
|
end
|
||||||
|
|
||||||
case uninstall
|
case uninstall
|
||||||
echo "$c_warn""→ Removing:$c_reset $packages"
|
echo "$c_warn""→ Removing:$c_reset $packages"
|
||||||
$aur -Rns $packages
|
switch $pm
|
||||||
|
case paru yay
|
||||||
|
$pm -Rns $packages
|
||||||
|
case pacman
|
||||||
|
sudo pacman -Rns $packages
|
||||||
|
case apt
|
||||||
|
sudo apt remove -y $packages
|
||||||
|
case dnf
|
||||||
|
sudo dnf remove -y $packages
|
||||||
|
case zypper
|
||||||
|
sudo zypper remove -y $packages
|
||||||
|
case brew
|
||||||
|
brew uninstall $packages
|
||||||
|
case pkg
|
||||||
|
sudo pkg delete -y $packages
|
||||||
|
case yum
|
||||||
|
sudo yum remove -y $packages
|
||||||
|
end
|
||||||
|
|
||||||
case auto
|
case auto
|
||||||
set -l to_install
|
set -l to_install
|
||||||
set -l to_remove
|
set -l to_remove
|
||||||
|
|
||||||
for pkg in $packages
|
for p in $packages
|
||||||
if pacman -Qi $pkg &>/dev/null
|
if __pkg_is_installed $pm $p
|
||||||
set to_remove $to_remove $pkg
|
set to_remove $to_remove $p
|
||||||
else
|
else
|
||||||
set to_install $to_install $pkg
|
set to_install $to_install $p
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if test (count $to_install) -gt 0
|
if test (count $to_install) -gt 0
|
||||||
echo "$c_ok""→ Installing:$c_reset $to_install"
|
echo "$c_ok""→ Installing:$c_reset $to_install"
|
||||||
$aur -S $to_install
|
switch $pm
|
||||||
or return $status
|
case paru yay
|
||||||
|
$pm -S $to_install
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
case pacman
|
||||||
|
sudo pacman -S $to_install
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
case apt
|
||||||
|
sudo apt install -y $to_install
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
case dnf
|
||||||
|
sudo dnf install -y $to_install
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
case zypper
|
||||||
|
sudo zypper install -y $to_install
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
case brew
|
||||||
|
brew install $to_install
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
case pkg
|
||||||
|
sudo pkg install -y $to_install
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
case yum
|
||||||
|
sudo yum install -y $to_install
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if test (count $to_remove) -gt 0
|
if test (count $to_remove) -gt 0
|
||||||
echo "$c_warn""→ Removing:$c_reset $to_remove"
|
echo "$c_warn""→ Removing:$c_reset $to_remove"
|
||||||
$aur -Rns $to_remove
|
switch $pm
|
||||||
or return $status
|
case paru yay
|
||||||
|
$pm -Rns $to_remove
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
case pacman
|
||||||
|
sudo pacman -Rns $to_remove
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
case apt
|
||||||
|
sudo apt remove -y $to_remove
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
case dnf
|
||||||
|
sudo dnf remove -y $to_remove
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
case zypper
|
||||||
|
sudo zypper remove -y $to_remove
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
case brew
|
||||||
|
brew uninstall $to_remove
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
case pkg
|
||||||
|
sudo pkg delete -y $to_remove
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
case yum
|
||||||
|
sudo yum remove -y $to_remove
|
||||||
|
or begin; functions -e __pkg_is_installed; return $status; end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
functions -e __pkg_is_installed
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user