flesh out some more fzf features

This commit is contained in:
Aaron Bieber 2020-08-29 02:58:09 +00:00
parent e5a6aeb185
commit d898f86d81
2 changed files with 41 additions and 2 deletions

View File

@ -1,3 +1,40 @@
h() {
fc -ln | fzf | ksh
zh() {
fc -ln | eval `fzf`
}
zpkg() {
local _pkg _usage
_usage="zpkg add|rm"
if [ ! -f /usr/local/share/sqlports ]; then
echo "please install sqlports"
return 1
fi
if [ ! -e /usr/local/bin/sqlite3 ]; then
echo "please install sqlite3"
return 1
fi
if [ -z $1 ]; then
echo $_usage
return 1
else
case $1 in
add)
_pkg=$(/usr/local/bin/sqlite3 -separator " " \
/usr/local/share/sqlports \
"select distinct fullpkgname from Ports;" |\
fzf --preview "/usr/sbin/pkg_info {1}")
[ ! -z $_pkg ] && ${OHMY_DO} /usr/sbin/pkg_add $_pkg
;;
rm)
_pkg=$(ls -1 /var/db/pkg | fzf --preview "/usr/sbin/pkg_info {1}")
[ ! -z $_pkg ] && ${OHMY_DO} /usr/sbin/pkg_delete $_pkg
;;
*)
echo $_usage
esac
fi
}

View File

@ -2,6 +2,8 @@
#${DEBUG}
OHMY_DO=${OHMY_DO:-doas}
# Stub our load functions
paths() {
return 0