90 lines
1.6 KiB
Bash
Executable File
90 lines
1.6 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 \
|
|
--preview-window=bottom:45%:wrap \
|
|
--preview 'xq -R {2} '
|
|
}
|
|
|
|
install() {
|
|
local pkg
|
|
pkg="$(xrs "" | 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
|
|
}
|
|
|
|
sync() {
|
|
upd
|
|
}
|
|
|
|
case "$1" in
|
|
1) install ;;
|
|
2) remove ;;
|
|
3) sync ;;
|
|
4) hold ;;
|
|
5) unhold ;;
|
|
6) 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: Sync Runs update script
|
|
4: Hold Runs \`xbps-pkgdb -m hold\`
|
|
5: Unhold Runs \`xbps-pkgdb -m unhold\`
|
|
6: Clear cache Runs \`xbps-remove -O\`
|
|
All else Print this message
|
|
|
|
Enter the number of your choice to execute command.
|
|
EOF
|
|
|
|
esac
|