Merge remote-tracking branch 'lenormf/rc/man.kak'
This commit is contained in:
commit
2a6f36732d
16
rc/man.kak
16
rc/man.kak
|
@ -38,13 +38,23 @@ def -params .. \
|
||||||
prefix=${1:0:${kak_pos_in_token}}
|
prefix=${1:0:${kak_pos_in_token}}
|
||||||
for page in /usr/share/man/*/${prefix}*.[1-8]*; do
|
for page in /usr/share/man/*/${prefix}*.[1-8]*; do
|
||||||
candidate=$(basename ${page%%.[1-8]*})
|
candidate=$(basename ${page%%.[1-8]*})
|
||||||
|
pagenum=$(sed -r 's,^.+/.+\.([1-8][^.]*)\..+$,\1,' <<< $page)
|
||||||
case $candidate in
|
case $candidate in
|
||||||
*\*) ;;
|
*\*) ;;
|
||||||
*) echo $candidate ;;
|
*) echo $candidate\($pagenum\);;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
} \
|
} \
|
||||||
man -docstring "Manpages viewer wrapper" %{ %sh{
|
man -docstring "Manpages viewer wrapper" %{ %sh{
|
||||||
[ -z "$@" ] && set -- "$kak_selection"
|
subject=${@-$kak_selection}
|
||||||
echo "eval -try-client %opt{docsclient} _man $@"
|
pagenum=""
|
||||||
|
|
||||||
|
## The completion suggestions display the page number, strip them if present
|
||||||
|
if [[ $subject =~ [a-zA-Z_-]+\([^\)]+\) ]]; then
|
||||||
|
pagenum=${subject##*\(}
|
||||||
|
pagenum=${pagenum:0:$((${#pagenum} - 1))}
|
||||||
|
subject=${subject%%\(*}
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "eval -try-client %opt{docsclient} _man $pagenum $subject"
|
||||||
} }
|
} }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user