diff options
author | Toby Vincent <tobyv13@gmail.com> | 2022-05-01 14:41:46 -0500 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2022-05-01 14:41:46 -0500 |
commit | fbaf84277f0c99e54f3fcc7b60d3bb4df37d5640 (patch) | |
tree | d6367536a59443e1e74a4d4bb5c1c7ca6555eaf3 /paru | |
parent | 37842f72d87e1ca809e12a9da4674c4c7e5cad5e (diff) |
feat: add paru config
Diffstat (limited to 'paru')
-rw-r--r-- | paru/.config/paru/paru.conf | 39 | ||||
-rwxr-xr-x | paru/.local/bin/paruz | 111 |
2 files changed, 150 insertions, 0 deletions
diff --git a/paru/.config/paru/paru.conf b/paru/.config/paru/paru.conf new file mode 100644 index 0000000..43990a2 --- /dev/null +++ b/paru/.config/paru/paru.conf @@ -0,0 +1,39 @@ +# +# $PARU_CONF +# /etc/paru.conf +# ~/.config/paru/paru.conf +# +# See the paru.conf(5) manpage for options + +# +# GENERAL OPTIONS +# +[options] +PgpFetch +Devel +Provides +DevelSuffixes = -git -cvs -svn -bzr -darcs -always -hg -fossil +#AurOnly +BottomUp +#RemoveMake +#SudoLoop +#UseAsk +#SaveChanges +#CombinedUpgrade +#CleanAfter +#UpgradeMenu +NewsOnUpgrade + +#LocalRepo +#Chroot +#Sign +#SignDb +#KeepRepoCache + +# +# Binary OPTIONS +# +#[bin] +#FileManager = vifm +#MFlags = --skippgpcheck +#Sudo = doas diff --git a/paru/.local/bin/paruz b/paru/.local/bin/paruz new file mode 100755 index 0000000..5c91d62 --- /dev/null +++ b/paru/.local/bin/paruz @@ -0,0 +1,111 @@ +#!/usr/bin/env bash + +shopt -s lastpipe + + +export SHELL=bash + +if [[ -z $PARUZ ]]; then + + if command -v paru >/dev/null 2>&1; then + + PARUZ=paru + elif ! command -v pacman >/dev/null 2>&1; then + echo "Neither paru nor pacman found. Is this Arch?" >&2 + exit 1 + elif [[ $EUID -eq 0 ]] || [[ -f /usr/bin/msys-2.0.dll ]]; then + PARUZ=pacman + else + PARUZ='sudo pacman' + fi +fi + +__paruz_help() { + PROG=$(basename "$0") + cat >&2 <<EOF +Usage: $PROG [OPTS] + +A fzf terminal UI for paru or pacman. + +sudo is invoked automatically, if needed. + +Multiple packages can be selected. + +The package manager can be changed with the environment variables: PARUZ + +Keybindings: + TAB Select + Shift+TAB Deselect + +OPTS: + -h, --help Print this message + + All other options are passed to the package manager. + Default: -S (install) + +Examples: + paruz -S --nocleanafter + + paruz -R + PARUZ=yay paruz +EOF + + exit 1 +} + +__fzf_preview() { + $PARUZ --color=always -Si "$1" | grep --color=never -v '^ ' +} + +__paruz_list() { + $PARUZ --color=always -Sl | sed -e 's: :/:; s/ unknown-version//' +} + +# main + + +while [[ -n $1 ]]; do + case $1 in + -h | --help) + __paruz_help + ;; + __fzf_preview) + shift + __fzf_preview "$@" + ;; + *) + + break + ;; + esac + shift +done + +ARGS=("$@") + +if [[ ${#ARGS[@]} -eq 0 ]]; then + ARGS=("-S") +fi + +declare -a PICKS +__paruz_list | + fzf \ + --multi \ + --ansi \ + + --preview="'${BASH_SOURCE[0]}' __fzf_preview {1}" | + readarray -t PICKS + +if [[ ${#PICKS[@]} -eq 0 ]]; then + exit 0 + +fi + + +declare -a PKGS +for PICK in "${PICKS[@]}"; do + PKGS+=("${PICK%% *}") +done + +exec $PARUZ "${ARGS[@]}" "${PKGS[@]}" + |