Browse Source

pkgsearch: use an exported function to compute package names

pull/6/head
DanielFGray 3 years ago
parent
commit
0c9461eeb4
1 changed files with 29 additions and 19 deletions
  1. 29
    19
      pkgsearch

+ 29
- 19
pkgsearch View File

@@ -79,34 +79,44 @@ install() {
}

debian() {
packageName() {
cut -d' ' -f1
}
export packageName

fzf --bind="Ctrl-X:execute[p={} ;
less < <(apt-cache show \$(awk '{print \$1}' <<< \$p)) > /dev/tty]" \
--query="$1" < <(apt-cache search '' |
sort |
sed -u -r "s|^([^ ]+)|${c_green}\1${c_reset}|") |
cut -d' ' -f1 |
less < <(apt-cache show
\$(packageName <<< \$p)) > /dev/tty]" \
--query="$1" \
< <(apt-cache search '' | sort |
sed -u -r "s|^([^ ]+)|${c_green}\1${c_reset}|") |
packageName |
install "sudo $(select-from 'apt' 'aptitude' 'apt-get') install"
}

arch() {
local search
packageName() {
cut -d' ' -f2
}
export packageName

local search packages
search='pacman'
[[ -n "$1" ]] && search=$(select-from 'pacaur' 'yaourt' 'packer' 'apacman' 'pacman')
fzf \
--bind="Ctrl-X:execute[p={} ;
less < <($search -Si \$(awk '{print \$2}' <<< \$p)) > /dev/tty]" \
packages=$(fzf --bind="Ctrl-X:execute[p={} ;
less < <($search -Si \$(packageName <<< \$p)) > /dev/tty]" \
< <( $search -Ss "$1" |
awk '{
getline descr;
sub(/ */,"", descr);
repo = blue "[" gensub(/\/.*/, "", 1) "]" reset;
name = green gensub(/.*\//, "", 1, $1) reset;
info = gensub(/[^ ]* /, "", 1);
print repo, name, info, descr;
awk '{
getline descr;
sub(/ */,"", descr);
repo = blue "[" gensub(/\/.*/, "", 1) "]" reset;
name = green gensub(/.*\//, "", 1, $1) reset;
info = gensub(/[^ ]* /, "", 1);
print repo, name, info, descr;
}' blue="$c_blue" green="$c_green" reset="$c_reset"
) |
cut -d' ' -f2 |
install "${search/pacman/sudo pacman} -S"
) | packageName)
[[ "$search" == "pacman" ]] && search="sudo pacman"
install "$search -S" <<< "$packages"
}

while true; do

Loading…
Cancel
Save