Skip to content

Commit

Permalink
improve completion for files with special chars
Browse files Browse the repository at this point in the history
  • Loading branch information
wofr06 committed Mar 18, 2024
1 parent 2647645 commit f62fd64
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lesscomplete
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,14 @@ isdeb () {
# the main program
set +o noclobber
setopt sh_word_split 2>/dev/null

a="${1/#\~/$HOME}"
a="${a//\\}"
sep=: # file name separator
altsep='=' # alternate separator character
if [[ -e "$1" && "$1" == *"$sep"* ]]; then
if [[ -e "$a" && "$a" == *"$sep"* ]]; then
sep=$altsep
elif [[ "$1" == *"$altsep"* ]]; then
[[ -e "${1%%"$altsep"*}" ]] && sep=$altsep
elif [[ "$a" == *"$altsep"* ]]; then
[[ -e "${a%%"$altsep"*}" ]] && sep=$altsep
fi

tmpdir=${TMPDIR:-/tmp}/lesspipe."$RANDOM"
Expand All @@ -344,8 +345,8 @@ t=$(nexttmp)
if [[ $LESSOPEN == *\|-* && $1 == - ]]; then
cat > "$t"
[[ -n "$fext" ]] && t="$t$sep$fext"
set "$1" "$t"
a="$t"
nexttmp >/dev/null
fi

show "$@"
show "$a"

0 comments on commit f62fd64

Please sign in to comment.