Skip to content

Instantly share code, notes, and snippets.

@vifon
Last active December 27, 2015 07:49
Show Gist options
  • Save vifon/7291424 to your computer and use it in GitHub Desktop.
Save vifon/7291424 to your computer and use it in GitHub Desktop.
#!/bin/zsh
#########################################################################
# Copyright (C) 2013 Wojciech Siewierski, Aleksander Nitecki #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
DMENU_ARGS=${DMENU_ARGS- -f -l 16 -p man}
DMENU_ARGS+=" $@"
MAN=${MAN:-man}
DMENU=${DMENU:-dmenu ${DMENU_ARGS}}
print -l /usr/share/man/man[0-9]/* |
awk -F'/' '{section = substr($6,
match($6,
/\.[0-9][^.]*(\.gz)?$/) + 1)
sub(/(\.gz)$/,
"",
section)
sub(/\.[0-9][^.]*(\.gz)?$/,
"",
$6)
print($6"("section")")}' |
sort |
${=DMENU} |
if read; then
awk -F'[\\(\\)]' '{print $2" "$1}' <<< $REPLY |
xargs ${=MAN}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment