Skip to content

Commit

Permalink
Use multibyte characters in prompt with less v668 and higher.
Browse files Browse the repository at this point in the history
  • Loading branch information
xwmx committed Oct 6, 2024
1 parent dd9c544 commit 3f34335
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions nb
Original file line number Diff line number Diff line change
Expand Up @@ -2519,17 +2519,27 @@ _join() {
# Description:
# The prompt to display in `less`.
_less_prompt() {
# TODO: remove when less 668 or higher is widely available
local _less_version=
_less_version="$(less --version | head -1)"
_less_version="${_less_version#* }"
_less_version="${_less_version%% *}"

local _prompt="\
> scroll for more, h for help, or q to quit"

if [[ "${_COLUMNS}" -gt 81 ]]
then
# NOTE: Multibyte unicode characters not rendering in recent versions of less.
# TODO: Resolve unicode rendering and revert prompt.
# _prompt="\
# > scroll for more, f / b to jump ↓ / ↑, h for help, or q to quit"
_prompt="\
# TODO: remove when less 668 or higher is widely available
if [[ "${_less_version:-}" -gt "653" ]] &&
[[ "${_less_version:-}" -lt "668" ]]
then # render prompt without multibyte characters
_prompt="\
> scroll for more, f / b to jump forward / back, h for help, or q to quit"
else
_prompt="\
> scroll for more, f / b to jump ↓ / ↑, h for help, or q to quit"
fi
fi

printf "%s\\n" "${_prompt}"
Expand Down

0 comments on commit 3f34335

Please sign in to comment.