89 lines
1.7 KiB
Bash
Executable File
89 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# ignore shellcheck's warnings, the script works fine
|
|
|
|
fzf_opts() {
|
|
local argument_input
|
|
|
|
fzf -i -e -m +s \
|
|
--query="$argument_input" \
|
|
--select-1 \
|
|
--cycle \
|
|
--reverse \
|
|
--info=inline \
|
|
--header="TAB to (un)select. ENTER to run. ESC to quit." \
|
|
--preview-window=bottom:45%:wrap \
|
|
--preview 'xbps-query -R {2} ' \
|
|
--prompt="Filter > " | awk '{print $2}'
|
|
}
|
|
|
|
install() {
|
|
local pkg
|
|
pkg="$(xbps-query -Rs "" | sort -u | grep -v "*" | fzf_opts)"
|
|
pkg="$(echo "$pkg" | paste -sd " ")"
|
|
|
|
if [ -n "$pkg" ]; then
|
|
clear
|
|
doas xbps-install $pkg
|
|
fi
|
|
}
|
|
|
|
remove() {
|
|
local pkg
|
|
pkg="$(xbps-query -l | sort -u | fzf_opts)"
|
|
pkg="$(echo "$pkg" | paste -sd " ")"
|
|
|
|
if [ -n "$pkg" ]; then
|
|
clear
|
|
doas xbps-remove -R $pkg
|
|
fi
|
|
}
|
|
|
|
unhold() {
|
|
local pkg
|
|
pkg="$(xbps-query -p hold -s "" | sort -u | fzf)"
|
|
pkg="$(echo "$pkg" | paste -sd " " | tr -d ":")"
|
|
|
|
if [ -n "$pkg" ]; then
|
|
clear
|
|
doas xbps-pkgdb -m unhold $pkg
|
|
fi
|
|
}
|
|
|
|
hold() {
|
|
local pkg
|
|
pkg="$(xbps-query -l | sort -u | fzf_opts)"
|
|
pkg="$(echo "$pkg" | paste -sd " ")"
|
|
|
|
if [ -n "$pkg" ]; then
|
|
clear
|
|
doas xbps-pkgdb -m hold $pkg
|
|
fi
|
|
}
|
|
|
|
cache() {
|
|
doas xbps-remove -Oo
|
|
}
|
|
|
|
case "$1" in
|
|
1) install ;;
|
|
2) remove ;;
|
|
3) hold ;;
|
|
4) unhold ;;
|
|
5) cache ;;
|
|
*) cat << EOF ;;
|
|
xui: FZF xbps ui. Run simple xbps commands to install,
|
|
remove, hold, unhold, update packages, and clear cache.
|
|
|
|
Allowed options:
|
|
1: Install Runs \`xbps-install\`
|
|
2: Remove Runs \`xbps-remove -R\`
|
|
3: Hold Runs \`xbps-pkgdb -m hold\`
|
|
4: Unhold Runs \`xbps-pkgdb -m unhold\`
|
|
5: Clear cache Runs \`xbps-remove -Oo\`
|
|
All else Print this message
|
|
|
|
Enter the number of your choice to execute command.
|
|
EOF
|
|
|
|
esac
|