From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: To: sarlug@lug.ru Date: Fri, 31 Jan 2003 17:23:11 +0300 User-Agent: KMail/1.5 References: <20030130234051.5a636483.horohorinev@mail.ru> <036f01c2c920$e3a80110$480f930a@theundead> In-Reply-To: <036f01c2c920$e3a80110$480f930a@theundead> MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 8BIT Content-Disposition: inline Message-Id: <200301311723.11264.> Subject: [Sarlug] Bash completion Sender: sarlug-admin@lug.ru Errors-To: sarlug-admin@lug.ru X-BeenThere: sarlug@lug.ru X-Mailman-Version: 2.0.9 Precedence: bulk Reply-To: sarlug@lug.ru List-Unsubscribe: , List-Id: Saratov Linux User Group Maillist List-Post: List-Help: List-Subscribe: , List-Archive: Archived-At: List-Archive: List-Post: Народ. Может кому пригодится : скрипт, который в 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 Если будут какие-нибудь проблемы - пишите...