From: <max@gamer.yandex.ru>
To: sarlug@lug.ru
Subject: [Sarlug] Bash completion
Date: Fri, 31 Jan 2003 17:23:11 +0300
Message-ID: <200301311723.11264.> (raw)
In-Reply-To: <036f01c2c920$e3a80110$480f930a@theundead>
Народ. Может кому пригодится : скрипт, который в bash'е по TAB дописывает
имена man топиков. Мне лично его очень недостовало.
------------------------Cut here--------------------
#!/bin/bash
#
# Function:
# complete_man() - assigns COMPREPLY variable list of man topics,
# which are expanded from given argument
# Arguments:
# $1 - not used (reserved for use with bash's "Programmable completion")
# $2 - first part of topic name
# $3 - colon-separated section list (or 'man' for default)
function complete_man() {
#local section=, result=, script=
section=
# Check for section parameter
if [[ "$3" != "man" ]]; then
section="-S $3"
fi
# Get topic list and filter pathnames
result=`man ${section} -aW ${2}* 2>/dev/null | sed -ne "s|.*/||p"`
# Get archive extensions recognized by man
archive_extensions=(`cat /etc/man.conf | gawk -F " " '{ if($1 ~ /\./)
print $1; }'`)
# Strip archive extension
for arch_ext in $archive_extensions; do
script="s/\\${arch_ext}//gp"
result=`echo $result | sed -ne $script`
done;
# Strip section number
result=`echo $result | sed -ne "s/\.[0-9]//gp"`
COMPREPLY=($result)
}
------------------------Cut here--------------------
Прикручивается это так: в ~/.bashrc пишем строчки
source <путь до файла>/complete_man.sh
complete -F "complete_man" man
Если будут какие-нибудь проблемы - пишите...
next prev parent reply other threads:[~2003-01-31 14:23 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-30 20:40 [Sarlug] Master 2.2B [CD] Евгений В. Хорохорин
2003-01-30 21:23 ` Eugene A. Suchkov
2003-01-31 12:04 ` [Sarlug] 2 Genix: мой RH Sysadmin Survival CD не у тебя? Masterhard
2003-01-31 12:27 ` Евгений В. Хорохорин
2003-01-31 14:23 ` max [this message]
2003-02-01 9:29 ` [Sarlug] Bash completion HaPK
2003-02-01 12:07 ` Sin
2003-02-01 12:41 ` MD
2003-02-02 17:03 ` HaPK
2003-02-01 17:41 ` Евгений В. Хорохорин
2003-02-01 18:50 ` Re[2]: " Алексей Шишкин <a.shishkin@sgu.ru>
2003-02-01 19:24 ` Евгений В. Хорохорин
2003-02-01 21:49 ` Re[4]: " Алексей Шишкин <a.shishkin@sgu.ru>
2003-02-02 16:52 ` HaPK
2003-02-02 17:56 ` Re[2]: " Алексей Шишкин <a.shishkin@sgu.ru>
2003-02-02 18:11 ` [Sarlug] Programming (Bash completion) òÏÍÁÎ âÏÇÏÒÏÄÓËÉÊ
2003-02-03 3:33 ` HaPK
2003-02-03 11:31 ` òÏÍÁÎ âÏÇÏÒÏÄÓËÉÊ
2003-02-02 19:38 ` [Sarlug] Bash completion Paul P Komkoff Jr
2003-02-01 17:13 ` Paul P Komkoff Jr
2003-02-02 17:41 ` HaPK
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200301311723.11264. \
--to=max@gamer.yandex.ru \
--cc=sarlug@lug.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Saratov Linux User Group
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/sarlug/0 sarlug/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 sarlug sarlug/ http://lore.altlinux.org/sarlug \
sarlug@lists.lug.ru sarlug@lug.ru
public-inbox-index sarlug
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.sarlug
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git