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

Use builtins instead of external commands #25

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
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
20 changes: 10 additions & 10 deletions fzpac
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -o errexit
set -o nounset

SHELL="$(which bash)"
SHELL="$(type -P bash)"
readonly SHELL

readonly THIS_CMD="${0##*/}"
Expand All @@ -19,7 +19,7 @@ _version() {
readonly LICENSE="MIT"
readonly GITHUB_URL="https://github.com"

cat <<EOF
echo -n -e "\

${STYLE_BOLD}${THIS_CMD}${STYLE_RESET} -- ${STYLE_UNDERBAR}v${VERSION}${STYLE_RESET}

Expand All @@ -28,11 +28,11 @@ Released under the ${LICENSE} License.
Author: ${AUTHOR} (${GITHUB_URL}/${AUTHOR})

* ${THIS_CMD} uses this command as a pacman-like command: $(_pacman)
EOF
"
}

_help() {
cat <<EOF
echo -n -e "\
${THIS_CMD} -- Arch Linux package finder with fuzzy finder

${STYLE_BOLD}USAGE${STYLE_RESET}
Expand All @@ -59,7 +59,7 @@ ${STYLE_BOLD}KEY BINDINGS${STYLE_RESET}
${STYLE_UNDERBAR}<C-s>${STYLE_RESET} show information of the package
${STYLE_UNDERBAR}<Tab>${STYLE_RESET} select a package
${STYLE_UNDERBAR}<CR>${STYLE_RESET} confirm selection
EOF
"
}

_main() {
Expand Down Expand Up @@ -216,7 +216,7 @@ _fuzzyfinder() {
done
fi

env LANG=C "${finder}" "${args[@]}"
LANG=C "${finder}" "${args[@]}"
}

_err() {
Expand Down Expand Up @@ -282,19 +282,19 @@ _show_info() {
local pkg="${2}"
shift 1

env LANG=C "${pac}" --sync --search --color=always "^${pkg}$"
LANG=C "${pac}" --sync --search --color=always "^${pkg}$"
echo ""
env LANG=C "${pac}" --sync --info --color=always "${pkg}"
LANG=C "${pac}" --sync --info --color=always "${pkg}"
}

_show_info_local() {
local pac="${1}"
local pkg="${2}"
shift 1

env LANG=C "${pac}" --query --search --color=always "^${pkg}$"
LANG=C "${pac}" --query --search --color=always "^${pkg}$"
echo ""
env LANG=C "${pac}" --query --info --list --color=always "${pkg}"
LANG=C "${pac}" --query --info --list --color=always "${pkg}"
}

_install() {
Expand Down