mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
tools/gstreamer-completion: Updated to work with the binary registry
The original registry was in xml format (~/.gstreamer-*/registry.xml). A binary registry format was added in 2007 (commitebf0c9d3
) and made the default in 2008 (commit3f39fd7e
). In 0.10 you could still choose at "configure" time to use the xml registry instead; in 1.0 the binary registry is your only choice. This change to gstreamer-completion should work with either format because it parses the output of "gst-inspect" instead of reading the registry file directly. Note that _gst_launch no longer needs an explicit "return 0" because, unlike the previous grep command, compgen always returns 0 (unless a genuine error occurs). Just like the previous implementation by David Schleef, this "only completes names of features, but that's 90% of what I want it for."
This commit is contained in:
parent
a2170fc7b8
commit
271c707c45
1 changed files with 7 additions and 21 deletions
|
@ -2,26 +2,12 @@
|
|||
# Put this in /etc/bash_completion.d/
|
||||
#
|
||||
|
||||
_gst_launch()
|
||||
{
|
||||
local cur
|
||||
_gst_launch() {
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
COMPREPLY=( $(compgen -W "$(_gst_elements)" -- "$cur") )
|
||||
} &&
|
||||
complete -F _gst_launch -o default gst-launch-1.0
|
||||
|
||||
: ${GST_REGISTRY:=~/.gstreamer-1.0/registry.xml}
|
||||
: ${GST_COMPLETE:=~/.gstreamer-1.0/complete}
|
||||
|
||||
if [ ! -f "${GST_REGISTRY}" ] ; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ ! -f "${GST_COMPLETE}" \
|
||||
-o "${GST_REGISTRY}" -nt "${GST_COMPLETE}" ] ; then
|
||||
sed -n 's/^..<name>\(.*\)<\/name>/\1/ p' ${GST_REGISTRY} >${GST_COMPLETE}
|
||||
fi
|
||||
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
COMPREPLY=( $(grep ^$cur $GST_COMPLETE) )
|
||||
|
||||
return 0
|
||||
_gst_elements() {
|
||||
gst-inspect-1.0 | grep -v 'Total count' | awk -F': +' '{print $2}'
|
||||
}
|
||||
complete -F _gst_launch -o default gst-launch
|
||||
|
||||
|
|
Loading…
Reference in a new issue