Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aur helper config as colon separeted list #23

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[add] colon-separated list support to FZPAC_PACMAN
  • Loading branch information
a5ob7r committed Oct 22, 2021
commit a8d15d306a3ba792dab088aeec4253ef252a955d
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,32 +176,30 @@ sudo make install

To change the AUR helper command to use, run fzpac with the value of the `"${FZPAC_PACMAN}"` variable set.

This value is a colon-separated list like a `"${PATH}"` variable, elements are but commands not directories. fzpac tries to use each of the commands in `"${FZPAC_PACMAN}"` in turn as a pacman command to find packages. So fallback to following commands if the preceding one isn't found.

If no `"${FZPAC_PACMAN}"` is set or empty, fzpac assumes the value is 'paru:yay:pacman'.

```bash
FZPAC_PACMAN="some-aur-helper-command" fzpac ...
# Elements are command name or path.
FZPAC_PACMAN="aur-helper1:/path/to/aur-helper2:..." fzpac ...

# Precede your favorite AUR helper if you want to give priority to it.
FZPAC_FINDER="yay:paru:..." fzpac ...
```

To always use this setting, add the following line to your `~/.bashrc` or other shell rc file

```bash
export FZPAC_PACMAN="some-aur-helper-command"
export FZPAC_PACMAN="aur-helper1:/path/to/aur-helper2:..."
```

### FZPAC_FINDER

To change the fuzzy finder which is used in fzpac, set the `"${FZPAC_FINDER}"` variable.

This value is colon separated list like a `"${PATH}"` variable, elements are but commands not directories. fzpac trys to use each of commands in `"${FZPAC_FINDER}"` in turn as fuzzy finder to find packages. So fallback to following commands if preceding one isn't found.
Almost the same as `"${FZPAC_PACMAN}"`, but this is to config the fuzzy finder which is used in fzpac.

If no `"${FZPAC_FINDER}"` is set or empty, fzpac assumes the value is 'fzf:sk:peco:gof:fzy'.

```bash
# Elements are command name or path.
FZPAC_FINDER="finder1:/path/to/finder2:..." fzpac ...

# Precede your favorite fuzzy finder if you want to give priority to it.
FZPAC_FINDER="sk:fzf:..." fzpac ...
```

## Contribution

Issue or PR is welcome!❤
22 changes: 8 additions & 14 deletions fzpac
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ SHELL="$(which bash)"
readonly SHELL

readonly THIS_CMD="${0##*/}"
readonly PACMAN="${FZPAC_PACMAN:-pacman}"
readonly PACMAN_LIST=(
"paru"
"yay"
"pacman"
)
readonly FZPAC_PACMAN="${FZPAC_PACMAN:-paru:yay:pacman}"
readonly FZPAC_FINDER="${FZPAC_FINDER:-fzf:sk:peco:gof:fzy}"
readonly STYLE_BOLD=$'\033[1m'
readonly STYLE_UNDERBAR=$'\033[4m'
Expand Down Expand Up @@ -141,19 +136,18 @@ _has() {
}

_pacman() {
if [ ! "${PACMAN}" = "pacman" ]; then
echo -n "${PACMAN}"
return 0
fi

for pac in "${PACMAN_LIST[@]}"; do
if command -v "${pac}" &>/dev/null; then
for pac in ${FZPAC_PACMAN//:/ }; do
if _has "${pac}"; then
echo -n "${pac}"
return 0
fi
done

_err 'The command for pacman or AUR helper was not found.'
if [[ "${FZPAC_PACMAN}" == *:* ]]; then
_err "${FZPAC_PACMAN//:/, } aren't found."
else
_err "${FZPAC_PACMAN} isn't found."
fi
exit 1
}

Expand Down