mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-14 08:22:46 +08:00
DNF5 completion support (#11035)
* dnf5 completions
* address comments
(cherry picked from commit 00c7baf68c
)
This commit is contained in:
parent
f36a7262db
commit
d6dccc3c88
|
@ -2,6 +2,10 @@
|
||||||
# Completions for the dnf command
|
# Completions for the dnf command
|
||||||
#
|
#
|
||||||
|
|
||||||
|
function __dnf_is_dnf5
|
||||||
|
path resolve -- $PATH/dnf | path filter | string match -q -- '*/dnf5'
|
||||||
|
end
|
||||||
|
|
||||||
function __dnf_list_installed_packages
|
function __dnf_list_installed_packages
|
||||||
dnf repoquery --cacheonly "$cur*" --qf "%{name}\n" --installed </dev/null
|
dnf repoquery --cacheonly "$cur*" --qf "%{name}\n" --installed </dev/null
|
||||||
end
|
end
|
||||||
|
@ -15,9 +19,14 @@ function __dnf_list_available_packages
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
set -l results
|
set -l results
|
||||||
|
if __dnf_is_dnf5
|
||||||
|
# dnf5 provides faster completions than repoquery, but does not maintain the
|
||||||
|
# same sqlite db as dnf4
|
||||||
|
set results (dnf --complete=2 dnf install "$tok*")
|
||||||
|
else if type -q sqlite3
|
||||||
# dnf --cacheonly list --available gives a list of non-installed packages dnf is aware of,
|
# dnf --cacheonly list --available gives a list of non-installed packages dnf is aware of,
|
||||||
# but it is slow as molasses. Unfortunately, sqlite3 is not available oob (Fedora Server 32).
|
# but it is slow as molasses. Unfortunately, sqlite3 is not available oob (Fedora Server 32).
|
||||||
if type -q sqlite3
|
|
||||||
# This schema is bad, there is only a "pkg" field with the full
|
# This schema is bad, there is only a "pkg" field with the full
|
||||||
# packagename-version-release.fedorarelease.architecture
|
# packagename-version-release.fedorarelease.architecture
|
||||||
# tuple. We are only interested in the packagename.
|
# tuple. We are only interested in the packagename.
|
||||||
|
@ -37,7 +46,7 @@ function __dnf_list_available_packages
|
||||||
end
|
end
|
||||||
|
|
||||||
function __dnf_list_transactions
|
function __dnf_list_transactions
|
||||||
if type -q sqlite3
|
if not __dnf_is_dnf5 && type -q sqlite3
|
||||||
sqlite3 /var/lib/dnf/history.sqlite "SELECT id, cmdline FROM trans" 2>/dev/null | string replace "|" \t
|
sqlite3 /var/lib/dnf/history.sqlite "SELECT id, cmdline FROM trans" 2>/dev/null | string replace "|" \t
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user