1c55a0fe5246487ec9f18e03b7f28862b76cb7ab
- Author
- Marcus Müller <marcus@hostalia.de>
- Committer
- GitHub <noreply@github.com>
- Date
Message
feat(dnf): use `dnf5` if available (#11904)
Co-authored-by: Marcus Müller <marcus_ohmyzsh@baseband.digital>
Diff
1diff --git a/plugins/dnf/README.md b/plugins/dnf/README.md
2index dc0d1e0a08b0e75b18860945d81bec0480723d22..f45c8778c8b49b46937c2fb3d6847049f3b54277 100644
3--- a/plugins/dnf/README.md
4+++ b/plugins/dnf/README.md
5@@ -10,6 +10,9 @@ To use it, add `dnf` to the plugins array in your zshrc file:
6 plugins=(... dnf)
7 ```
8
9+Classic `dnf` is getting superseded by `dnf5`; this plugin detects the presence
10+of `dnf5` and uses it as drop-in alternative to the slower `dnf`.
11+
12 ## Aliases
13
14 | Alias | Command | Description |
15diff --git a/plugins/dnf/dnf.plugin.zsh b/plugins/dnf/dnf.plugin.zsh
16index 653ce7dda0446975140f9c4da3df67a78b28b7f8..642422fe1e3d92b2279680afa8a9d767481c8f81 100644
17--- a/plugins/dnf/dnf.plugin.zsh
18+++ b/plugins/dnf/dnf.plugin.zsh
19@@ -1,15 +1,19 @@
20 ## Aliases
21+local dnfprog="dnf"
22
23-alias dnfl="dnf list" # List packages
24-alias dnfli="dnf list installed" # List installed packages
25-alias dnfgl="dnf grouplist" # List package groups
26-alias dnfmc="dnf makecache" # Generate metadata cache
27-alias dnfp="dnf info" # Show package information
28-alias dnfs="dnf search" # Search package
29+# Prefer dnf5 if installed
30+command -v dnf5 > /dev/null && dnfprog=dnf5
31
32-alias dnfu="sudo dnf upgrade" # Upgrade package
33-alias dnfi="sudo dnf install" # Install package
34-alias dnfgi="sudo dnf groupinstall" # Install package group
35-alias dnfr="sudo dnf remove" # Remove package
36-alias dnfgr="sudo dnf groupremove" # Remove package group
37-alias dnfc="sudo dnf clean all" # Clean cache
38+alias dnfl="${dnfprog} list" # List packages
39+alias dnfli="${dnfprog} list installed" # List installed packages
40+alias dnfgl="${dnfprog} grouplist" # List package groups
41+alias dnfmc="${dnfprog} makecache" # Generate metadata cache
42+alias dnfp="${dnfprog} info" # Show package information
43+alias dnfs="${dnfprog} search" # Search package
44+
45+alias dnfu="sudo ${dnfprog} upgrade" # Upgrade package
46+alias dnfi="sudo ${dnfprog} install" # Install package
47+alias dnfgi="sudo ${dnfprog} groupinstall" # Install package group
48+alias dnfr="sudo ${dnfprog} remove" # Remove package
49+alias dnfgr="sudo ${dnfprog} groupremove" # Remove package group
50+alias dnfc="sudo ${dnfprog} clean all" # Clean cache