list.sh: support column output
This commit is contained in:
parent
fafa61852d
commit
e4896f3440
@ -9,7 +9,18 @@ homebrew-list() {
|
|||||||
*) ;;
|
*) ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
local ls_env=()
|
||||||
local ls_args=()
|
local ls_args=()
|
||||||
|
|
||||||
|
local tty
|
||||||
|
if [[ -t 1 ]]
|
||||||
|
then
|
||||||
|
tty=1
|
||||||
|
ls_args+=("-Cq")
|
||||||
|
source "${HOMEBREW_LIBRARY}/Homebrew/utils/helpers.sh"
|
||||||
|
ls_env+=("COLUMNS=$(columns)")
|
||||||
|
fi
|
||||||
|
|
||||||
local formula=""
|
local formula=""
|
||||||
local cask=""
|
local cask=""
|
||||||
|
|
||||||
@ -31,13 +42,6 @@ homebrew-list() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
local tty
|
|
||||||
if [[ -t 1 ]]
|
|
||||||
then
|
|
||||||
tty=1
|
|
||||||
source "${HOMEBREW_LIBRARY}/Homebrew/utils/helpers.sh"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z "${cask}" && -d "${HOMEBREW_CELLAR}" ]]
|
if [[ -z "${cask}" && -d "${HOMEBREW_CELLAR}" ]]
|
||||||
then
|
then
|
||||||
if [[ -n "${tty}" && -z "${formula}" ]]
|
if [[ -n "${tty}" && -z "${formula}" ]]
|
||||||
@ -46,7 +50,7 @@ homebrew-list() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local formula_output
|
local formula_output
|
||||||
formula_output="$(ls "${ls_args[@]}" "${HOMEBREW_CELLAR}")" || exit 1
|
formula_output="$(/usr/bin/env "${ls_env[@]}" ls "${ls_args[@]}" "${HOMEBREW_CELLAR}")" || exit 1
|
||||||
if [[ -n "${formula_output}" ]]
|
if [[ -n "${formula_output}" ]]
|
||||||
then
|
then
|
||||||
echo "${formula_output}"
|
echo "${formula_output}"
|
||||||
@ -66,7 +70,7 @@ homebrew-list() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local cask_output
|
local cask_output
|
||||||
cask_output="$(ls "${ls_args[@]}" "${HOMEBREW_CASKROOM}")" || exit 1
|
cask_output="$(/usr/bin/env "${ls_env[@]}" ls "${ls_args[@]}" "${HOMEBREW_CASKROOM}")" || exit 1
|
||||||
if [[ -n "${cask_output}" ]]
|
if [[ -n "${cask_output}" ]]
|
||||||
then
|
then
|
||||||
echo "${cask_output}"
|
echo "${cask_output}"
|
||||||
|
@ -86,3 +86,21 @@ numeric() {
|
|||||||
IFS=".rc" read -r -a version_array <<<"${1}"
|
IFS=".rc" read -r -a version_array <<<"${1}"
|
||||||
printf "%01d%02d%02d%03d" "${version_array[@]}" 2>/dev/null
|
printf "%01d%02d%02d%03d" "${version_array[@]}" 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
columns() {
|
||||||
|
if [[ -n "${COLUMNS}" ]]
|
||||||
|
then
|
||||||
|
echo "${COLUMNS}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local columns
|
||||||
|
read -r _ columns < <(stty size 2>/dev/null)
|
||||||
|
|
||||||
|
if [[ -z "${columns}" ]] && tput cols >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
columns="$(tput cols)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${columns:-80}"
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user