├── .github
└── workflows
│ └── test.yml
├── LICENSE
├── Makefile
├── README.md
├── aur
└── PKGBUILD
├── completions
├── bash
│ └── fzpac
├── fish
│ └── fzpac.fish
└── zsh
│ └── _fzpac
├── fzpac
├── subcmds.tsv
└── tools
└── linter
└── Dockerfile
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: test
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | paths-ignore:
8 | - 'LICENSE'
9 | - 'README.*'
10 | pull_request:
11 | paths-ignore:
12 | - 'LICENSE'
13 | - 'README.*'
14 |
15 | jobs:
16 | format:
17 | runs-on: ubuntu-latest
18 | steps:
19 | - uses: actions/checkout@v2
20 | - name: Install formatter
21 | run: make setup_tools
22 | - name: Format
23 | run: make check_format_on_docker
24 |
25 | lint:
26 | runs-on: ubuntu-latest
27 | steps:
28 | - uses: actions/checkout@v2
29 | - name: Install formatter
30 | run: make setup_tools
31 | - name: Format
32 | run: make lint_on_docker
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Sheepla
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | NAME = fzpac
2 |
3 | PREFIX ?= /usr/local
4 | BINDIR := $(PREFIX)/bin
5 | SHAREDIR := $(PREFIX)/share
6 |
7 | FZPAC_SRC_PATH := fzpac
8 | FZPAC_DEST_PATH := $(BINDIR)/fzpac
9 |
10 | BASH_COMPLETION_SRC_PATH := completions/bash/fzpac
11 | BASH_COMPLETION_DEST_PATH := $(SHAREDIR)/bash-completion/completions/fzpac
12 |
13 | FISH_COMPLETION_SRC_PATH := completions/fish/fzpac.fish
14 | FISH_COMPLETION_DEST_PATH := $(SHAREDIR)/fish/completions/fzpac.fish
15 |
16 | ZSH_COMPLETION_SRC_PATH := completions/zsh/_fzpac
17 | ZSH_COMPLETION_DEST_PATH := $(SHAREDIR)/zsh/site-functions/_fzpac
18 |
19 | LICENSE_SRC_PATH := LICENSE
20 | LICENSE_DEST_PATH := $(SHAREDIR)/licenses/$(NAME)/LICENSE
21 |
22 | README_SRC_PATH := README.md
23 | README_DEST_PATH := $(SHAREDIR)/doc/$(NAME)/README.md
24 |
25 | DOCKER_TOOL_IMAGE := tools
26 | DOCKER_LINT_CMD := docker run --rm -v $$PWD:/work -w /work $(DOCKER_TOOL_IMAGE)
27 |
28 | .PHONY: help
29 | help: ## Print help documents
30 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
31 |
32 | .PHONY: echo
33 | echo: ## Print source paths and destination paths
34 | echo FZPAC_SRC_PATH: $(FZPAC_SRC_PATH)
35 | echo FZPAC_DEST_PATH: $(FZPAC_DEST_PATH)
36 | echo BASH_COMPLETION_SRC_PATH: $(BASH_COMPLETION_SRC_PATH)
37 | echo BASH_COMPLETION_DEST_PATH: $(BASH_COMPLETION_DEST_PATH)
38 | echo FISH_COMPLETION_SRC_PATH: $(FISH_COMPLETION_SRC_PATH)
39 | echo FISH_COMPLETION_DEST_PATH: $(FISH_COMPLETION_DEST_PATH)
40 | echo ZSH_COMPLETION_SRC_PATH: $(ZSH_COMPLETION_SRC_PATH)
41 | echo ZSH_COMPLETION_DEST_PATH: $(ZSH_COMPLETION_DEST_PATH)
42 | echo README_SRC_PATH: $(README_SRC_PATH)
43 | echo README_DEST_PATH: $(README_DEST_PATH)
44 | echo LICENSE_SRC_PATH: $(LICENSE_SRC_PATH)
45 | echo LICENSE_DEST_PATH: $(LICENSE_DEST_PATH)
46 |
47 | .PHONY: install
48 | install: ## Install programs
49 | install -Dm 0755 $(FZPAC_SRC_PATH) $(FZPAC_DEST_PATH)
50 | install -Dm 0644 $(BASH_COMPLETION_SRC_PATH) $(BASH_COMPLETION_DEST_PATH)
51 | install -Dm 0644 $(FISH_COMPLETION_SRC_PATH) $(FISH_COMPLETION_DEST_PATH)
52 | install -Dm 0644 $(ZSH_COMPLETION_SRC_PATH) $(ZSH_COMPLETION_DEST_PATH)
53 | install -Dm 0644 $(README_SRC_PATH) $(README_DEST_PATH)
54 | install -Dm 0644 $(LICENSE_SRC_PATH) $(LICENSE_DEST_PATH)
55 |
56 | .PHONY: uninstall
57 | uninstall: ## Uninstall programs
58 | rm -f $(FZPAC_DEST_PATH)
59 | rm -f $(BASH_COMPLETION_DEST_PATH)
60 | rm -f $(FISH_COMPLETION_DEST_PATH)
61 | rm -f $(ZSH_COMPLETION_DEST_PATH)
62 | rm -f $(README_DEST_PATH)
63 | rm -f $(LICENSE_DEST_PATH)
64 |
65 | .PHONY: format
66 | format: ## Format code and write a file
67 | shfmt -w $(FZPAC_SRC_PATH)
68 | #shfmt -w $(BASH_COMPLETION_SRC_PATH)
69 | #shfmt -w $(FISH_COMPLETION_SRC_PATH)
70 | #shfmt -w $(ZSH_COMPLETION_SRC_PATH)
71 |
72 | .PHONY: lint
73 | lint: ## Lint code
74 | shellcheck $(FZPAC_SRC_PATH)
75 | #shellcheck $(BASH_COMPLETION_SRC_PATH)
76 | #shellcheck $(ZSH_COMPLETION_SRC_PATH)
77 |
78 | .PHONY: setup_tools
79 | setup_tools: ## Setup linter tools
80 | docker build -t $(DOCKER_TOOL_IMAGE) tools/linter
81 |
82 | .PHONY: check_format_on_docker
83 | check_format_on_docker: ## Check format code on docker
84 | $(DOCKER_LINT_CMD) shfmt -d $(FZPAC_SRC_PATH)
85 |
86 | .PHONY: lint_on_docker
87 | lint_on_docker: ## Lint code on docker
88 | $(DOCKER_LINT_CMD) shellcheck $(FZPAC_SRC_PATH)
89 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
🔎 fzpac
2 |
3 |
4 |

5 |

6 |
7 |
8 |
9 |
10 | `fzpac` is a `pacman` wrapper, an Arch Linux package finder with fuzzy finder.
11 |
12 |
13 |
14 | ## Demo
15 |
16 |
17 |

18 |
19 |
20 | ## Features
21 |
22 | - [x] Quickly find the packages you are looking for with **fuzzy search and preview**.
23 | - [x] Uses easy-to-use **APT-like subcommands**.
24 | - [x] You can immediately **install** / **uninstall** the packages that you selected.
25 | - [x] Supports **Tab completion** in multiple shells.
26 | - `bash` (`bash-completion` package required)
27 | - `fish`
28 | - `zsh` (`zsh-completions` package required)
29 | - [x] Supports **multiple AUR helpers** such as [paru](https://github.com/Morganamilo/paru) and [yay](https://github.com/Jguer/yay) .
30 | - [x] Supports **multiple fuzzy finders** such as [fzf](https://github.com/junegunn/fzf) and [skim](https://https://github.com/lotabout/skim) .
31 |
32 | ## Try fzpac
33 |
34 | To try `fzpac` quickly, run the following command:
35 |
36 | ```bash
37 | curl -LO git.io/fzpac && chmod +x fzpac
38 | ```
39 |
40 | ## Usage
41 |
42 | 1. Run this command
43 | 2. Select the packages with fuzzy finder
44 | 3. You can view the package info or install / uninstall it immediately
45 |
46 | ### Help Message
47 |
48 | ```
49 | fzpac -- Arch Linux package finder with fuzzy finder
50 |
51 | USAGE
52 | fzpac SUBCMD [KEYWORDS...]
53 | fzpac --help|--version
54 |
55 | SUBCMD
56 | s, search search for all available packages
57 | l, local search for already installed packages
58 | S, install select packages and INSTALL it
59 | R, remove select packages and UNINSTALL it
60 | A, autoremove select packages that are no longer needed and UNINSTALL it.
61 | h, help show help message
62 | v, version show version
63 |
64 | OPTIONS
65 | -h, --help show help message
66 | -v, --version show version
67 |
68 | KEY BINDINGS
69 | , move focus down
70 | , move focus up
71 | show information of the package
72 | select a package
73 | confirm selection
74 | ```
75 |
76 | ## Installation
77 |
78 | ### Dependence
79 |
80 | Requires `fzf`, `sk` or your favorite fuzzy finder, but recommended one is `fzf` or `sk` to use full features.
81 |
82 | - [junegunn/fzf](https://github.com/junegunn/fzf)
83 | - [lotabout/skim](https://https://github.com/lotabout/skim)
84 |
85 | If `fzf` or `sk` is not installed, install it with the following command:
86 |
87 | ```bash
88 | sudo pacman -S fzf
89 | # or
90 | sudo pacman -S sk
91 | ```
92 |
93 | If you want to use other fuzzy finder, see **FZPAC_FINDER** section in Configuration.
94 |
95 | ### Optional
96 |
97 | #### AUR Helper
98 |
99 | If you have the following AUR helpers installed, `fzpac` will use that command in preference to `pacman` .
100 |
101 |
105 |
106 | #### Tab Completion on the Shells
107 |
108 | ##### bash
109 |
110 | To use Tab completion with bash, install the `bash-completion` package.
111 |
112 | ```bash
113 | sudo pacman -S bash-completion
114 | ```
115 |
116 | then, add the following contents to your `~/.bashrc` .
117 |
118 | ```bash
119 | _set_completion() {
120 | local bash_completion
121 | bash_completion='/usr/share/bash-completion/bash_completion'
122 | [ -f "${bash_completion}" ] && source "${bash_completion}"
123 | }
124 |
125 | _set_completion
126 | ```
127 |
128 | ##### fish
129 |
130 | Complete functions are built into `fish` so you don't need to install any additional packages.
131 |
132 | ##### zsh
133 |
134 | To use Tab completion with zsh, requires `zsh-completions` package.
135 |
136 | ```zsh
137 | sudo pacman -S zsh-completions
138 | ```
139 |
140 | then, append this commands on your `.zshrc` to activate completion.
141 |
142 | ```.zshrc
143 | autoload -U compinit
144 | compinit -u
145 | ```
146 |
147 | ### Install with PKGBUILD (Recommend)
148 |
149 | Run below if you want to install the latest stable version with `PKGBUILD` .
150 | After a successful installation, you can manage `fzpac` as an Arch Linux package.
151 |
152 | ```bash
153 | # install base-devel package
154 | sudo pacman -S --needed base-devel
155 | # cd to some empty directory to build package
156 | cd "$(mktemp -d)"
157 | # download PKGBUILD file
158 | curl -O https://raw.githubusercontent.com/sheepla/fzpac/main/aur/PKGBUILD
159 | # build package and install
160 | makepkg -si
161 | ```
162 |
163 | ### Install from the latest commit
164 |
165 | Run below if you want to install the latest commit version.
166 |
167 | ```bash
168 | git clone https://github.com/sheepla/fzpac
169 | cd fzpac
170 | sudo make install
171 | ```
172 |
173 | ## Configurations
174 |
175 | ### FZPAC_PACMAN
176 |
177 | To change the AUR helper command to use, run fzpac with the value of the `"${FZPAC_PACMAN}"` variable set.
178 |
179 | 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.
180 |
181 | If no `"${FZPAC_PACMAN}"` is set or empty, fzpac assumes the value is `paru:yay:pacman`.
182 |
183 | Note that fzpac assumes commands in `"${FZPAC_PACMAN}"` supports pacman compatible arguments. So maybe fzpac doesn't work as expected if the commands don't support them.
184 |
185 | ```bash
186 | # Elements are command name or path.
187 | FZPAC_PACMAN="aur-helper1:/path/to/aur-helper2:..." fzpac ...
188 |
189 | # Precede your favorite AUR helper if you want to give priority to it.
190 | FZPAC_FINDER="yay:paru:..." fzpac ...
191 | ```
192 |
193 | To always use this setting, add the following line to your `~/.bashrc` or other shell rc file
194 |
195 | ```bash
196 | export FZPAC_PACMAN="aur-helper1:/path/to/aur-helper2:..."
197 | ```
198 |
199 | ### FZPAC_FINDER
200 |
201 | Almost the same as `"${FZPAC_PACMAN}"`, but this is to config the fuzzy finder which is used in fzpac.
202 |
203 | If no `"${FZPAC_FINDER}"` is set or empty, fzpac assumes the value is `fzf:sk:peco:gof:fzy` .
204 |
205 | ## Contribution
206 |
207 | Issue or PR is welcome!❤
208 |
--------------------------------------------------------------------------------
/aur/PKGBUILD:
--------------------------------------------------------------------------------
1 | # Maintainer sheepla
2 |
3 | pkgname=fzpac
4 | pkgver=2.0.5
5 | pkgrel=1
6 | pkgdesc="Arch Linux package finder with fzf"
7 | arch=("any")
8 | url="https://github.com/sheepla/fzpac"
9 | license=("MIT")
10 | groups=()
11 | depends=("fzf")
12 | makedepends=()
13 | optdepends=(
14 | "skim: for another fuzzy finder support"
15 | "bash-completion: for bash completion support"
16 | "zsh-completions: for zsh completion support"
17 | "fish: for fish completion support"
18 | "yay: for AUR helper support"
19 | "paru: for AUR helper support"
20 | )
21 | provides=()
22 | conflicts=("fzpac-git")
23 | replaces=()
24 | backup=()
25 | options=()
26 | install=
27 | changelog=
28 | source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz")
29 | noextract=()
30 | sha256sums=("ef2f8cac36ac8270b5f08169865d3998f8cb68ebf5e252623e5be36ad0c92cfe")
31 |
32 | package() {
33 | cd "${srcdir}/${pkgname}-${pkgver}"
34 | PREFIX="${pkgdir}/usr" make install
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/completions/bash/fzpac:
--------------------------------------------------------------------------------
1 | # fzpac(1) completion -*- shell-script -*-
2 |
3 | _fzpac_module() {
4 | local cur prev cword
5 | _get_comp_words_by_ref -n : cur prev cword
6 |
7 | if [[ "${cword}" -eq 1 ]]; then
8 | local subcmds="search local install remove autoremove help version"
9 | COMPREPLY=($(compgen -W "${subcmds}" -- "${cur}"))
10 | fi
11 | }
12 |
13 | complete -F _fzpac_module fzpac
14 |
--------------------------------------------------------------------------------
/completions/fish/fzpac.fish:
--------------------------------------------------------------------------------
1 | complete -c fzpac -x
2 |
3 | complete -c fzpac -n '__fish_use_subcommand' -x -a 's select' -d 'search for all available packages'
4 | complete -c fzpac -n '__fish_use_subcommand' -x -a 's search' -d 'search for all available packages'
5 | complete -c fzpac -n '__fish_use_subcommand' -x -a 'l local' -d 'search for already installed packages'
6 | complete -c fzpac -n '__fish_use_subcommand' -x -a 'S install' -d 'select packages and INSTALL it'
7 | complete -c fzpac -n '__fish_use_subcommand' -x -a 'R remove' -d 'select packages and UNINSTALL it'
8 | complete -c fzpac -n '__fish_use_subcommand' -x -a 'A autoremove' -d 'select packages that are no longer needed and UNINSTALL it'
9 | complete -c fzpac -n '__fish_use_subcommand' -x -a 'h help' -d 'show help message'
10 | complete -c fzpac -n '__fish_use_subcommand' -x -a 'v version' -d 'show version'
11 |
--------------------------------------------------------------------------------
/completions/zsh/_fzpac:
--------------------------------------------------------------------------------
1 | #compdef fzpac
2 |
3 | _fzpac() {
4 | _values \
5 | "sub-commands" \
6 | {s,search}"[search for all available packages]" \
7 | {l,local}"[search for already installed packages]" \
8 | {S,install}"[select packages and INSTALL it]" \
9 | {R,remove}"[select packages and UNINSTALL it]" \
10 | {A,autoremove}"[select packages that are no longer needed and UNINSTALL it]" \
11 | {h,help}"[show help message]" \
12 | {v,version}"[show version]"
13 | }
14 |
15 | compdef _fzpac fzpac
16 |
17 | # vim: ft=zsh
18 |
--------------------------------------------------------------------------------
/fzpac:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -o errexit
4 | set -o nounset
5 |
6 | SHELL="$(which bash)"
7 | readonly SHELL
8 |
9 | readonly THIS_CMD="${0##*/}"
10 | readonly FZPAC_PACMAN="${FZPAC_PACMAN:-paru:yay:pacman}"
11 | readonly FZPAC_FINDER="${FZPAC_FINDER:-fzf:sk:peco:gof:fzy}"
12 | readonly STYLE_BOLD=$'\033[1m'
13 | readonly STYLE_UNDERBAR=$'\033[4m'
14 | readonly STYLE_RESET=$'\033[m'
15 |
16 | _version() {
17 | readonly VERSION='2.0.5'
18 | readonly AUTHOR="sheepla"
19 | readonly LICENSE="MIT"
20 | readonly GITHUB_URL="https://github.com"
21 |
22 | cat <${STYLE_RESET}, ${STYLE_UNDERBAR}${STYLE_RESET} move focus down
58 | ${STYLE_UNDERBAR}${STYLE_RESET}, ${STYLE_UNDERBAR}${STYLE_RESET} move focus up
59 | ${STYLE_UNDERBAR}${STYLE_RESET} show information of the package
60 | ${STYLE_UNDERBAR}${STYLE_RESET} select a package
61 | ${STYLE_UNDERBAR}${STYLE_RESET} confirm selection
62 | EOF
63 | }
64 |
65 | _main() {
66 | if [[ "${#}" -lt 1 ]]; then
67 | _err "Must require arguments..."
68 | _help
69 | exit 1
70 | fi
71 |
72 | local finder
73 | finder="$(_finder)"
74 |
75 | local pac
76 | pac="$(_pacman)"
77 |
78 | for arg in "${@}"; do
79 | case "${arg}" in
80 | s | search)
81 | shift
82 | _search "${pac}" "${finder}" "${@}"
83 | break
84 | ;;
85 | l | local)
86 | shift
87 | _search_local "${pac}" "${finder}" "${@}"
88 | break
89 | ;;
90 | S | install)
91 | shift
92 | local pkgs
93 | pkgs=(
94 | "$(_search "${pac}" "${finder}" "${@}")"
95 | )
96 | _install "${pac}" "${pkgs[@]}"
97 | break
98 | ;;
99 | R | remove)
100 | shift
101 | local pkgs
102 | pkgs=(
103 | "$(_search_local "${pac}" "${finder}" "${@}")"
104 | )
105 | _remove "${pac}" "${pkgs[@]}"
106 | break
107 | ;;
108 | A | autoremove)
109 | shift
110 | local pkgs
111 | pkgs=(
112 | "$(_search_no_deps "${pac}" "${finder}" "${@}")"
113 | )
114 | _remove "${pac}" "${pkgs[@]}"
115 | break
116 | ;;
117 | h | -h | help | --help)
118 | _help
119 | break
120 | ;;
121 | v | -v | version | --version)
122 | _version
123 | break
124 | ;;
125 | *)
126 | _err "Invalid sub command: ${1}."
127 | _help
128 | return 1
129 | ;;
130 | esac
131 | done
132 | }
133 |
134 | _has() {
135 | command -v "${1}" &>/dev/null
136 | }
137 |
138 | _pacman() {
139 | for pac in ${FZPAC_PACMAN//:/ }; do
140 | if _has "${pac}"; then
141 | echo -n "${pac}"
142 | return 0
143 | fi
144 | done
145 |
146 | if [[ "${FZPAC_PACMAN}" == *:* ]]; then
147 | _err "${FZPAC_PACMAN//:/, } aren't found."
148 | else
149 | _err "${FZPAC_PACMAN} isn't found."
150 | fi
151 | exit 1
152 | }
153 |
154 | # 'Fuzzy finder' finder. Exit process if no fuzzy finder is found.
155 | _finder() {
156 | for f in ${FZPAC_FINDER//:/ }; do
157 | if _has "${f}"; then
158 | echo "${f}"
159 | return 0
160 | fi
161 | done
162 |
163 | if [[ "${FZPAC_FINDER}" == *:* ]]; then
164 | _err "${FZPAC_FINDER//:/, } aren't found."
165 | else
166 | _err "${FZPAC_FINDER} isn't found."
167 | fi
168 |
169 | exit 1
170 | }
171 |
172 | # A simple abstraction between multiple fuzzy finders. This takes fuzzy finder
173 | # and the options as arguments, then select only supported them by the finder
174 | # and run the finder with selected options.
175 | #
176 | # Arguments
177 | # 1: Fuzzy finder name or path
178 | # 2-: Options for fuzzy finder
179 | #
180 | # Any options which aren't below are not supported and ignored.
181 | #
182 | # Supported options for fzf and sk:
183 | # - --multi
184 | # - --header STR
185 | # - --preview COMMAND
186 | # - --bind KEYBINDS
187 | _fuzzyfinder() {
188 | local -r finder="${1}"
189 | shift
190 |
191 | local -a args=()
192 |
193 | if [[ "${finder}" =~ (fzf|sk) ]]; then
194 | while (($#)); do
195 | case "${1}" in
196 | -m | --multi)
197 | args+=(--multi)
198 | shift
199 | ;;
200 | --header)
201 | args+=(--header "${2}")
202 | shift 2
203 | ;;
204 | --preview)
205 | args+=(--preview "${2}")
206 | shift 2
207 | ;;
208 | --bind)
209 | args+=(--bind "${2}")
210 | shift 2
211 | ;;
212 | *)
213 | shift
214 | ;;
215 | esac
216 | done
217 | fi
218 |
219 | env LANG=C "${finder}" "${args[@]}"
220 | }
221 |
222 | _err() {
223 | echo -e "[ \e[31mERR\e[m ] ${*}" >&2
224 | }
225 |
226 | _search() {
227 | readonly HEADER=": show package info"
228 |
229 | local pac="${1}"
230 | local finder="${2}"
231 | shift 2
232 |
233 | export -f _show_info
234 |
235 | "${pac}" --sync --search --quiet "${@}" |
236 | _fuzzyfinder \
237 | "${finder}" \
238 | --multi \
239 | --header "${HEADER}" \
240 | --preview "_show_info ${pac} {}" \
241 | --bind "ctrl-s:execute(_show_info ${pac} {} | less)"
242 | }
243 |
244 | _search_local() {
245 | readonly HEADER=": show package info"
246 |
247 | local pac="${1}"
248 | local finder="${2}"
249 | shift 2
250 |
251 | export -f _show_info_local
252 |
253 | "${pac}" --query --search --quiet "${@}" |
254 | _fuzzyfinder \
255 | "${finder}" \
256 | --multi \
257 | --header "${HEADER}" \
258 | --preview "_show_info_local ${pac} {}" \
259 | --bind "ctrl-s:execute(_show_info_local ${pac} {} | less)"
260 | }
261 |
262 | _search_no_deps() {
263 | readonly HEADER=": show package info"
264 |
265 | local pac="${1}"
266 | local finder="${2}"
267 | shift 2
268 |
269 | export -f _show_info_local
270 |
271 | "${pac}" --query --deps --unrequired --quiet "${@}" |
272 | _fuzzyfinder \
273 | "${finder}" \
274 | --multi \
275 | --header "${HEADER}" \
276 | --preview "_show_info_local ${pac} {}" \
277 | --bind "ctrl-s:execute(_show_info_local ${pac} {} | less)"
278 | }
279 |
280 | _show_info() {
281 | local pac="${1}"
282 | local pkg="${2}"
283 | shift 1
284 |
285 | env LANG=C "${pac}" --sync --search --color=always "^${pkg}$"
286 | echo ""
287 | env LANG=C "${pac}" --sync --info --color=always "${pkg}"
288 | }
289 |
290 | _show_info_local() {
291 | local pac="${1}"
292 | local pkg="${2}"
293 | shift 1
294 |
295 | env LANG=C "${pac}" --query --search --color=always "^${pkg}$"
296 | echo ""
297 | env LANG=C "${pac}" --query --info --list --color=always "${pkg}"
298 | }
299 |
300 | _install() {
301 | local pac="${1}"
302 | shift 1
303 |
304 | if [ "${pac}" = 'pacman' ]; then
305 | sudo pacman --sync - <<<"${@}"
306 | else
307 | "${pac}" --sync - <<<"${@}"
308 | fi
309 | }
310 |
311 | _remove() {
312 | local pac="${1}"
313 | shift 1
314 |
315 | if [ "${pac}" = 'pacman' ]; then
316 | sudo pacman --remove --nosave - <<<"${@}"
317 | else
318 | "${pac}" --remove --nosave - <<<"${@}"
319 | fi
320 | }
321 |
322 | _main "${@}"
323 | exit "${?}"
324 |
--------------------------------------------------------------------------------
/subcmds.tsv:
--------------------------------------------------------------------------------
1 | s search search for all available packages
2 | l local search for already installed packages
3 | s install select packages and INSTALL it
4 | R remove select packages and UNINSTALL it
5 | A autoremove select packages that are no longer needed and UNINSTALL it
6 | h help show help message
7 | v version show version
8 |
--------------------------------------------------------------------------------
/tools/linter/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM alpine:3.14
2 |
3 | ARG SHFMT_VERSION="v3.3.1"
4 | ARG SHELLCHECK_VERSION="v0.7.2"
5 |
6 | WORKDIR /tmp
7 | RUN apk add --no-cache wget && \
8 | wget -O /usr/local/bin/shfmt https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_linux_amd64 && \
9 | chmod +x /usr/local/bin/shfmt && \
10 | wget https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz && \
11 | tar xf shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz && \
12 | install -m 0755 shellcheck-${SHELLCHECK_VERSION}/shellcheck /usr/local/bin/shellcheck
13 |
--------------------------------------------------------------------------------