From 54823c924374061751ed5a89227fbc81db7ca220 Mon Sep 17 00:00:00 2001 From: Allen Sobot Date: Wed, 5 Aug 2020 20:01:19 +0200 Subject: [PATCH] Implement XBPS completions (#7239) --- CHANGELOG.rst | 1 + share/completions/xbps-alternatives.fish | 20 +++++++++++ share/completions/xbps-checkvers.fish | 18 ++++++++++ share/completions/xbps-create.fish | 36 ++++++++++++++++++++ share/completions/xbps-dgraph.fish | 21 ++++++++++++ share/completions/xbps-digest.fish | 10 ++++++ share/completions/xbps-fbulk.fish | 14 ++++++++ share/completions/xbps-fetch.fish | 13 ++++++++ share/completions/xbps-install.fish | 31 +++++++++++++++++ share/completions/xbps-pkgdb.fish | 19 +++++++++++ share/completions/xbps-query.fish | 39 ++++++++++++++++++++++ share/completions/xbps-reconfigure.fish | 20 +++++++++++ share/completions/xbps-remove.fish | 25 ++++++++++++++ share/completions/xbps-rindex.fish | 22 ++++++++++++ share/completions/xbps-uchroot.fish | 12 +++++++ share/completions/xbps-uhelper.fish | 12 +++++++ share/functions/__fish_print_packages.fish | 21 ++++++++++++ 17 files changed, 334 insertions(+) create mode 100644 share/completions/xbps-alternatives.fish create mode 100644 share/completions/xbps-checkvers.fish create mode 100644 share/completions/xbps-create.fish create mode 100644 share/completions/xbps-dgraph.fish create mode 100644 share/completions/xbps-digest.fish create mode 100644 share/completions/xbps-fbulk.fish create mode 100644 share/completions/xbps-fetch.fish create mode 100644 share/completions/xbps-install.fish create mode 100644 share/completions/xbps-pkgdb.fish create mode 100644 share/completions/xbps-query.fish create mode 100644 share/completions/xbps-reconfigure.fish create mode 100644 share/completions/xbps-remove.fish create mode 100644 share/completions/xbps-rindex.fish create mode 100644 share/completions/xbps-uchroot.fish create mode 100644 share/completions/xbps-uhelper.fish diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f0f3087af..a6ac134d4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -136,6 +136,7 @@ Completions - ``tig`` - ``windscribe`` - ``wireshark``, ``tshark``, and ``dumpcap`` + - ``xbps-*`` - ``xxhsum``, ``xxh32sum``, ``xxh64sum`` and ``xxh128sum`` - ``yadm`` - ``zopfli``, and ``zopflipng`` diff --git a/share/completions/xbps-alternatives.fish b/share/completions/xbps-alternatives.fish new file mode 100644 index 000000000..3310c7b3f --- /dev/null +++ b/share/completions/xbps-alternatives.fish @@ -0,0 +1,20 @@ +# xbps-alternatives +# Author: Allen Sobot + +set -l progname xbps-alternatives + +set -l listinstalled "(__fish_print_packages -i)" + +complete -c $progname -f +complete -c $progname -a "$listinstalled" + +complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s d -d 'Enables extra debugging shown to stderr.' +complete -c $progname -s g -d 'Alternative group name to match. To be used with the set mode.' +complete -c $progname -s h -d 'Show the help message.' +complete -c $progname -s r -d 'Specifies a full path for the target root directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s v -d 'Enables verbose messages.' +complete -c $progname -s V -d 'Show the version information.' +complete -c $progname -s l -n "not __fish_contains_opt -s s" -d 'Lists all current alternative groups or only from PKG, or just a specific group with -g.' +complete -c $progname -s s -n "not __fish_contains_opt -s l" -d 'Set alternative groups specified by PKG or just a specific group with -g.' + diff --git a/share/completions/xbps-checkvers.fish b/share/completions/xbps-checkvers.fish new file mode 100644 index 000000000..00c6dd3a3 --- /dev/null +++ b/share/completions/xbps-checkvers.fish @@ -0,0 +1,18 @@ +# Completions for xbps-checkvers +# Author: Allen Sobot + +set -l progname xbps-checkvers + +complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s D -d 'Specifies a full path to the void-packages repository.' -xa "(__fish_complete_directories)" +complete -c $progname -s d -d 'Enables extra debugging shown to stderr.' +complete -c $progname -s f -d 'Format according to the string format, inspired by printf.' -x +complete -c $progname -s h -d 'Show the help message.' +complete -c $progname -s i -d 'Ignore repositories defined in configuration files.' +complete -c $progname -s I -d 'Check for outdated installed packages rather than in repositories.' +complete -c $progname -s m -d 'Only process listed files.' +complete -c $progname -s R -d 'Repository to be added to the top of the list.' +complete -c $progname -s r -d 'Specifies a full path for the target root directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s s -d 'List all packages found in the void-packages tree and prints available version.' +complete -c $progname -s V -d 'Show the version information.' + diff --git a/share/completions/xbps-create.fish b/share/completions/xbps-create.fish new file mode 100644 index 000000000..54d4939f9 --- /dev/null +++ b/share/completions/xbps-create.fish @@ -0,0 +1,36 @@ +# Completions for xbps-create +# Author: Allen Sobot + +set -l progname xbps-create +set -l modes none gzip bzip2 xz lz4 zstd + +complete -c $progname -f -a "(__fish_complete_directories)" + +complete -c $progname -s A -d 'The target architecture for this package (required).' -x +complete -c $progname -s B -d 'The package builder string, free form.' -x +complete -c $progname -s C -d 'A list of package patterns that this package should conflict with, separated by whitespaces.' -x +complete -c $progname -s D -d 'A list of package patterns this package depends on, separated by whitespaces.' -x +complete -c $progname -s F -d 'A list of configuration files this package provides, separated by whitespace.' -x +complete -c $progname -s G -d 'This sets a string with the git revisions of the sourcepkg that was used to binary package.' -x +complete -c $progname -s H -d 'The package homepage string.' -x +complete -c $progname -s h -d 'Show the help message.' +complete -c $progname -s l -d 'The package license.' -x +complete -c $progname -s M -d 'A list of mutable files this package provides, separated by whitespaces.' -x +complete -c $progname -s m -d 'The package maintainer name and/or email contact.' -x +complete -c $progname -s n -d 'The package name/version tuple, e. g: \'foo-1. 0_1\'.' -x +complete -c $progname -s P -d 'A list of virtual packages this package provides, separated by whitespaces.' -x +complete -c $progname -s p -d 'If set the package files will be preserved after being updated.' +complete -c $progname -s q -d 'Enable quiet operation.' +complete -c $progname -s R -d 'A list of package patterns this package replaces, separated by whitespaces.' -x +complete -c $progname -s r -d 'A list of versions this package reverts, separated by whitespaces.' -x +complete -c $progname -s S -d 'A long description for this package.' -x +complete -c $progname -s s -d 'A short description for this package, one line with less than 80 characters.' -x +complete -c $progname -s t -d 'A list of tags (categories) this package should be part of, separated by whit…' -x +complete -c $progname -s V -d 'Show the version information.' +complete -c $progname -l build-options -d 'A string containing the build options used in package.' -x +complete -c $progname -l compression -d 'Set the binary package compression format. If unset, defaults to zstd.' -xa "$modes" +complete -c $progname -l shlib-provides -d 'A list of provided shared libraries, separated by whitespaces.' -x +complete -c $progname -l shlib-requires -d 'A list of required shared libraries, separated by whitespaces.' -x +complete -c $progname -l alternatives -d 'A list of alternatives provided by this package, separated by whitespaces.' -x +complete -c $progname -s c -d 'The package changelog string.' -x + diff --git a/share/completions/xbps-dgraph.fish b/share/completions/xbps-dgraph.fish new file mode 100644 index 000000000..956884360 --- /dev/null +++ b/share/completions/xbps-dgraph.fish @@ -0,0 +1,21 @@ +# Completions for xbps-dgraph +# Author: Allen Sobot + +set -l progname xbps-dgraph + +complete -c $progname -f +complete -c $progname -a "(__fish_print_packages -i)" +complete -c $progname -n "__fish_contains_opt -s R" -a "(__fish_print_packages)" + +complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s c -d 'Specifies a path to the graph configuration file.' -F +complete -c $progname -s d -d 'Enables extra debugging shown to stderr.' +complete -c $progname -s h -d 'Show the help message.' +complete -c $progname -s M -d 'For remote repositories, the data is fetched and stored in memory.' +complete -c $progname -s R -d 'Enable repository mode.' +complete -c $progname -s r -d 'Specifies a full path for the target root directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s V -d 'Show the version information.' +complete -c $progname -s g -n "not __fish_contains_opt -s f" -n "not __fish_contains_opt -s m" -d 'Generates a graph configuration file in the current working directory.' +complete -c $progname -s f -n "not __fish_contains_opt -s m" -n "not __fish_contains_opt -s g" -d 'Generates a full dependency graph of the target package.' +complete -c $progname -s m -n "not __fish_contains_opt -s f" -n "not __fish_contains_opt -s g" -d 'Generates a metadata graph of the target package.' # TODO: kinda fix this, can't exactly figure out how to make these last 3 modes mutually exclusive + diff --git a/share/completions/xbps-digest.fish b/share/completions/xbps-digest.fish new file mode 100644 index 000000000..21bd14567 --- /dev/null +++ b/share/completions/xbps-digest.fish @@ -0,0 +1,10 @@ +# Completions for xbps-digest +# Author: Allen Sobot + +set -l progname xbps-digest +set -l modes sha256 + +complete -c $progname -s m -d 'Sets the message digest mode. If unset, defaults to sha256' -xa "$modes" +complete -c $progname -s h -d 'Show the help message.' +complete -c $progname -s V -d 'Show the version information.' + diff --git a/share/completions/xbps-fbulk.fish b/share/completions/xbps-fbulk.fish new file mode 100644 index 000000000..b58cd54d9 --- /dev/null +++ b/share/completions/xbps-fbulk.fish @@ -0,0 +1,14 @@ +# Completions for xbps-fbulk +# Author: Allen Sobot + +set -l progname xbps-fbulk + +complete -c $progname -f -a "(__fish_complete_directories) (__fish_print_packages)" + +complete -c $progname -s a -d 'Set a different target architecture, useful for cross compiling.' -x +complete -c $progname -s j -d 'Set number of parallel builds running at the same time. By default set to 1.' -x +complete -c $progname -s l -d 'Set the log directory. By default set to `log. `.' -x +complete -c $progname -s d -d 'Enables extra debugging shown to stderr.' +complete -c $progname -s h -d 'Show the help message.' +complete -c $progname -s v -d 'Enables verbose messages.' +complete -c $progname -s V -d 'Show the version information.' diff --git a/share/completions/xbps-fetch.fish b/share/completions/xbps-fetch.fish new file mode 100644 index 000000000..0d0a8c85c --- /dev/null +++ b/share/completions/xbps-fetch.fish @@ -0,0 +1,13 @@ +# Completions for xbps-fetch +# Author: Allen Sobot + +set -l progname xbps-fetch + +complete -c $progname -f + +complete -c $progname -s d -d 'Enables debug messages on stderr.' +complete -c $progname -s h -d 'Show the help message.' +complete -c $progname -s o -d 'Rename file from specified URL to output.' -F +complete -c $progname -s v -d 'Enables verbose messages.' +complete -c $progname -s V -d 'Show the version information.' + diff --git a/share/completions/xbps-install.fish b/share/completions/xbps-install.fish new file mode 100644 index 000000000..d95729af1 --- /dev/null +++ b/share/completions/xbps-install.fish @@ -0,0 +1,31 @@ +# Completions for xbps-install +# Author: Allen Sobot + +set -l progname xbps-install + +set -l listall "(__fish_print_packages)" + +complete -c $progname -f +complete -c $progname -a "$listall" + +complete -c $progname -s A -d 'Enables automatic installation mode, i. e. treat as orphan unless dependency of already installed package.' +complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s c -d 'Specifies a path to the cache directory, where binary packages are stored.' -xa "(__fish_complete_directories)" +complete -c $progname -s d -d 'Enables extra debugging shown to stderr.' +complete -c $progname -s D -d 'Only download packages to the cache, do not do any other installation steps.' +complete -c $progname -s f -d 'Force downgrade/reinstall package (pass option twice to reinstall config files as well).' +complete -c $progname -s h -d 'Show the help message.' +complete -c $progname -s I -d 'Ignore detected file conflicts in a transaction.' +complete -c $progname -s i -d 'Ignore repositories defined in configuration files.' +complete -c $progname -s M -d 'For remote repositories, the data is fetched and stored in memory.' +complete -c $progname -s n -d 'Dry-run mode. Show what actions would be done but don\'t do anything.' +complete -c $progname -s R -d 'Enable repository mode.' +complete -c $progname -l repository -d 'Appends the specified repository to the top of the list.' +complete -c $progname -s r -d 'Specifies a full path for the target root directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s S -d 'Synchronize remote repository index files.' +complete -c $progname -s U -d 'If set, packages to be installed or upgraded in the transaction won\'t be configured.' +complete -c $progname -s u -d 'Performs a full system upgrade (except for packages on hold).' +complete -c $progname -s v -d 'Enables verbose messages.' +complete -c $progname -s y -d 'Assume yes to all questions and avoid interactive questions.' +complete -c $progname -s V -d 'Show the version information.' + diff --git a/share/completions/xbps-pkgdb.fish b/share/completions/xbps-pkgdb.fish new file mode 100644 index 000000000..fad797319 --- /dev/null +++ b/share/completions/xbps-pkgdb.fish @@ -0,0 +1,19 @@ +# Completions for xbps-pkgdb +# Author: Allen Sobot + +set -l progname xbps-pkgdb +set -l modes auto manual hold unhold repolock repounlock + +complete -c $progname -f + +complete -c $progname -s a -d 'Process all registered packages, regardless of its state.' +complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s d -d 'Enables extra debugging shown to stderr.' +complete -c $progname -s h -d 'Show the help message.' +complete -c $progname -s m -d 'Set mode of PKGNAME' -xa "$modes" +complete -c $progname -n "__fish_seen_subcommand_from $modes" -xa "(__fish_print_packages -i)" +complete -c $progname -s r -d 'Specifies a full path for the target root directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s u -d 'Updates the pkgdb format to the latest version making the necessary conversions.' +complete -c $progname -s v -d 'Enables verbose messages.' +complete -c $progname -s V -d 'Show the version information.' + diff --git a/share/completions/xbps-query.fish b/share/completions/xbps-query.fish new file mode 100644 index 000000000..fa0e93d2f --- /dev/null +++ b/share/completions/xbps-query.fish @@ -0,0 +1,39 @@ +# Completions for xbps-query +# Author: Allen Sobot + +set -l progname xbps-query + +set -l listall "(__fish_print_packages)" +set -l listinstalled "(__fish_print_packages -i)" + + +complete -c $progname -f +complete -c $progname -a "$listinstalled" +complete -c $progname -n "__fish_contains_opt -s R" -a "$listall" + +complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s c -d 'Specifies a path to the cache directory, where binary packages are stored.' -xa "(__fish_complete_directories)" +complete -c $progname -s d -d 'Enables extra debugging shown to stderr.' +complete -c $progname -s h -d 'Show the help message.' +complete -c $progname -s i -d 'Ignore repositories defined in configuration files.' +complete -c $progname -s M -d 'For remote repositories, the data is fetched and stored in memory only.' +complete -c $progname -s p -d 'Only match this package property.' +complete -c $progname -s R -d 'Enable repository mode.' +complete -c $progname -l repository -d 'Appends the specified repository to the top of the list.' +complete -c $progname -l regex -d 'Enables string matching by using Extended Regular Expressions in compatible modes' +complete -c $progname -l fulldeptree -d 'Prints a full dependency tree in the show dependencies mode.' +complete -c $progname -s r -d 'Specifies a full path for the target root directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s v -d 'Enables verbose messages.' +complete -c $progname -s V -d 'Show the version information.' +complete -c $progname -s l -d 'Lists registered packages in the package database (pkgdb).' +complete -c $progname -s H -d 'List registered packages in the package database (pkgdb) that are on hold.' +complete -c $progname -s L -d 'Lists repositories and the number of packages contained on them.' +complete -c $progname -s m -d 'Lists registered packages in the package database (pkgdb) that were installed manually' +complete -c $progname -s O -d 'Lists package orphans in the package database (pkgdb)' +complete -c $progname -s o -d 'Search for installed package files by matching PATTERN.' +complete -c $progname -s S -d 'Shows information of an installed package.' -x +complete -c $progname -s s -d 'Search for packages by matching PATTERN on its pkgver and/or short_desc properties' +complete -c $progname -s f -d 'Show the package files for PKG.' -x +complete -c $progname -s x -d 'Show the required dependencies for PKG. Only direct dependencies are shown.' -x +complete -c $progname -s X -d 'Show the reverse dependencies for PKG.' -x +complete -c $progname -l cat -d 'Prints the file FILE stored in binary package PKG to stdout.' -F diff --git a/share/completions/xbps-reconfigure.fish b/share/completions/xbps-reconfigure.fish new file mode 100644 index 000000000..bc46823e3 --- /dev/null +++ b/share/completions/xbps-reconfigure.fish @@ -0,0 +1,20 @@ +# Completions for xbps-reconfigure +# Author: Allen Sobot + +set -l progname xbps-reconfigure + +set -l listinstalled "(__fish_print_packages -i)" + +complete -c $progname -f +complete -c $progname -a "$listinstalled" + +complete -c $progname -s a -d 'Configures all packages.' +complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s d -d 'Enables extra debugging shown to stderr.' +complete -c $progname -s f -d 'Forcefully reconfigure package even if it was configured previously.' +complete -c $progname -s h -d 'Show the help message.' +complete -c $progname -s i -n "__fish_contains_opt -s a" -d 'Ignore PKG when configuring all packages, can be specified multiple times.' -xa "$listinstalled" +complete -c $progname -s r -d 'Specifies a path for the target root directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s v -d 'Enables verbose messages.' +complete -c $progname -s V -d 'Show the version information.' + diff --git a/share/completions/xbps-remove.fish b/share/completions/xbps-remove.fish new file mode 100644 index 000000000..d6c267f72 --- /dev/null +++ b/share/completions/xbps-remove.fish @@ -0,0 +1,25 @@ +# Completions for xbps-remove +# Author: Allen Sobot + +set -l progname xbps-remove + +set -l listinstalled "(__fish_print_packages -i)" + +complete -c $progname -f +complete -c $progname -a "$listinstalled" + +complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s c -d 'Specifies a path to the cache directory, where binary packages are stored.' -xa "(__fish_complete_directories)" +complete -c $progname -s d -d 'Enables extra debugging shown to stderr.' +complete -c $progname -s F -d 'Forcefully remove package even if there are reverse dependencies and/or broke…' +complete -c $progname -s f -d 'Forcefully remove package files even if they have been modified.' +complete -c $progname -s h -d 'Show the help message.' +complete -c $progname -s n -d 'Dry-run mode. Show what actions would be done but don\'t do anything.' +complete -c $progname -s O -d 'Cleans cache directory removing obsolete binary packages.' +complete -c $progname -s o -d 'Removes installed package orphans that were installed automatically (as dependencies)' +complete -c $progname -s R -d 'Recursively remove packages that were installed by PKGNAME and aren\'t required by any other package' +complete -c $progname -s r -d 'Specifies a full path for the target root directory.' -xa "(__fish_complete_directories)" +complete -c $progname -s v -d 'Enables verbose messages.' +complete -c $progname -s y -d 'Assume yes to all questions and avoid interactive questions.' +complete -c $progname -s V -d 'Show the version information.' + diff --git a/share/completions/xbps-rindex.fish b/share/completions/xbps-rindex.fish new file mode 100644 index 000000000..9cdea99bc --- /dev/null +++ b/share/completions/xbps-rindex.fish @@ -0,0 +1,22 @@ +# Completions for xbps-rindex +# Author: Allen Sobot + +set -l progname xbps-rindex +set -l modes none gzip bzip2 xz lz4 zstd + +complete -c $progname -f + +complete -c $progname -s d -d 'Enables extra debugging shown to stderr.' +complete -c $progname -l compression -d 'Set the repodata compression format. If unset, defaults to zstd.' -xa "$modes" +complete -c $progname -s C -d 'Check not only for file existence but for the correct file hash while cleaning.' +complete -c $progname -s f -d 'Forcefully register binary package into the local repository, overwriting existing entry.' +complete -c $progname -s h -d 'Show the help message.' +complete -c $progname -s V -d 'Show the version information.' +complete -c $progname -l signedby -d 'Name and email of person signing the repository.' +complete -c $progname -l privkey -d 'Path to the private RSA key to sign the repository. Defaults to ~/.ssh/id_rsa' -F + +complete -c $progname -s a -d 'Registers the binary package into the local repository.' -xa "(__fish_complete_suffix .xbps)" +complete -c $progname -s c -d 'Removes obsolete entries found in the local repository.' -xa "(__fish_complete_directories)" +complete -c $progname -s r -d 'Removes obsolete and currently unregistered packages from the local repository.' -xa "(__fish_complete_directories)" +complete -c $progname -s s -d 'Initializes a signed repository with your specified RSA key.' -xa "(__fish_complete_directories)" +complete -c $progname -s S -d 'Signs a binary package archive with your specified RSA key.' -xa "(__fish_complete_suffix .xbps)" diff --git a/share/completions/xbps-uchroot.fish b/share/completions/xbps-uchroot.fish new file mode 100644 index 000000000..6394276f9 --- /dev/null +++ b/share/completions/xbps-uchroot.fish @@ -0,0 +1,12 @@ +# Completions for xbps-uchroot +# Author: Allen Sobot + +set -l progname xbps-uchroot + +complete -c $progname -f -a "(__fish_complete_directories)" + +complete -c $progname -s b -d 'Bind mounts src into CHROOTDIR/dest.' -F +complete -c $progname -s O -d 'Setups a temporary directory and then creates an overlay layer (via overlayfs).' +complete -c $progname -s o -d 'Arguments passed to the tmpfs mount, if the O and t options are specified.' +complete -c $progname -s t -d 'This makes the temporary directory to be mounted in tmpfs, so that everything is stored in RAM. Used only with -O.' + diff --git a/share/completions/xbps-uhelper.fish b/share/completions/xbps-uhelper.fish new file mode 100644 index 000000000..d66936fee --- /dev/null +++ b/share/completions/xbps-uhelper.fish @@ -0,0 +1,12 @@ +# Completions for xbps-uhelper +# Author: Allen Sobot + +set -l progname xbps-uhelper +set -l actions binpkgarch binpkgver cmpver getpkgdepname getpkgdepversion getpkgname getpkgrevision getpkgversion pkgmatch version real-version + +complete -c $progname -f -a "$actions (__fish_print_packages -i)" + +complete -c $progname -s C -d 'Path to xbps.conf file.' -rF +complete -c $progname -s d -d 'Debugging messages to stderr.' +complete -c $progname -s r -d 'Path to rootdir.' -xa "(__fish_complete_directories)" +complete -c $progname -s V -d 'Prints the XBPS release version.' diff --git a/share/functions/__fish_print_packages.fish b/share/functions/__fish_print_packages.fish index 0dbaa19ab..7e480409f 100644 --- a/share/functions/__fish_print_packages.fish +++ b/share/functions/__fish_print_packages.fish @@ -242,4 +242,25 @@ function __fish_print_packages end end + # Caches for 5 minutes + if type -q -f xbps-query + if not set -q only_installed + set -l cache_file $xdg_cache_home/.xbps-cache.$USER + if test -f $cache_file + cat $cache_file + set -l age (math (date +%s) - (stat -c '%Y' $cache_file)) + set -l max_age 300 + if test $age -lt $max_age + return + end + end + # prints: Package + xbps-query -Rsl | sed 's/^... \([^ ]*\)-.* .*/\1/; s/$/\t'Package'/' > $cache_file & + return + else + xbps-query -l | sed 's/^.. \([^ ]*\)-.* .*/\1/' # TODO: actually put package versions in tab for locally installed packages + return + end + end + end