Browse Source

split pkgsearch into separate functions

develop
DanielFGray 4 years ago
parent
commit
b466465a10
1 changed files with 19 additions and 8 deletions
  1. 19
    8
      pkgsearch

+ 19
- 8
pkgsearch View File

@@ -73,30 +73,41 @@ fzf() {
command fzf -e +s --multi --cycle --ansi --no-hscroll --inline-info --reverse "$@"
}

if [[ -f /etc/debian_version ]]; then
out=$(fzf --query="$*" < <( \
debian() {
local out pkgs
out=$(fzf --query="$1" < <( \
apt-cache search '' |
sort |
sed -u -r "s|^([^ ]+)|${c_green}\1${c_reset}|" ) )
mapfile -t pkgs < <( awk '{print $1}' <<< "$out" )
mapfile -t pkgs < <(awk '{print $1}' <<< "$out")
(( ${#pkgs} > 0 )) || exit
sudo $(select-from 'apt' 'apt-get') install "${pkgs[@]}"
elif [[ -f /etc/arch-release ]]; then
}

arch() {
local search out pkgs
search='pacman'
(( $# > 0)) && search=$(select-from 'pacaur' 'yaourt' 'packer' 'apacman' 'pacman')
out=$(fzf < <( $search -Ss "$@" |
out=$(fzf < <( $search -Ss "$1" |
awk '{
getline descr;
sub(/ */,"", descr);
repo = "[" blue gensub(/\/.*/, "", 1) reset "]";
repo = blue gensub(/\/.*/, "", 1) reset;
name = green gensub(/.*\//, "", 1, $1) reset;
info = gensub(/[^ ]* /, "", 1);
print repo, name, info, descr;
print repo, "\t", name, info, descr;
}' blue="$c_blue" green="$c_green" reset="$c_reset"
)
)
mapfile -t pkgs < <(awk '{print $2}' <<< "out")
mapfile -t pkgs < <(awk '{print $2}' <<< "$out")
(( ${#pkgs} > 0 )) || exit
echo "installing ${pkgs[*]}"
${search/pacman/sudo pacman} -S "${pkgs[@]}"
}

request="$*"
if [[ -f /etc/debian_version ]]; then
debian "$request"
elif [[ -f /etc/arch-release ]]; then
arch "$request"
fi

Loading…
Cancel
Save