mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 16:26:39 +00:00
bash-completion: add completion for gstreamer tools
Allow to autocomplete with elements/properties in the devenv using gst-launch-1.0 etc. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/232>
This commit is contained in:
parent
ce79200376
commit
e4421c3c90
1 changed files with 22 additions and 0 deletions
22
gst-env.py
22
gst-env.py
|
@ -43,6 +43,18 @@ SHAREDLIB_REG = re.compile(r'\.so|\.dylib|\.dll')
|
||||||
GSTPLUGIN_FILEPATH_REG_TEMPLATE = r'.*/{libdir}/gstreamer-1.0/[^/]+$'
|
GSTPLUGIN_FILEPATH_REG_TEMPLATE = r'.*/{libdir}/gstreamer-1.0/[^/]+$'
|
||||||
GSTPLUGIN_FILEPATH_REG = None
|
GSTPLUGIN_FILEPATH_REG = None
|
||||||
|
|
||||||
|
BC_RC = '''
|
||||||
|
BASH_COMPLETION_SCRIPTS="{bash_completions}"
|
||||||
|
BASH_COMPLETION_PATHS="{bash_completions_paths}"
|
||||||
|
for p in $BASH_COMPLETION_PATHS; do
|
||||||
|
for f in $BASH_COMPLETION_SCRIPTS; do
|
||||||
|
[ -f "$p/$f" ] && . "$p/$f"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
'''
|
||||||
|
BASH_COMPLETION_PATHS = [SCRIPTDIR + '/subprojects/gstreamer/data/bash-completion/completions']
|
||||||
|
BASH_COMPLETION_PATHS += [SCRIPTDIR + '/subprojects/gst-devtools/validate/data/bash-completion/completions']
|
||||||
|
|
||||||
def listify(o):
|
def listify(o):
|
||||||
if isinstance(o, str):
|
if isinstance(o, str):
|
||||||
return [o]
|
return [o]
|
||||||
|
@ -219,6 +231,8 @@ def setup_gdb(options):
|
||||||
|
|
||||||
return python_paths
|
return python_paths
|
||||||
|
|
||||||
|
def is_bash_completion_available (options):
|
||||||
|
return os.path.exists(os.path.join(options.builddir, 'subprojects/gstreamer/data/bash-completion/helpers/gst'))
|
||||||
|
|
||||||
def get_subprocess_env(options, gst_version):
|
def get_subprocess_env(options, gst_version):
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
|
@ -504,6 +518,14 @@ if __name__ == "__main__":
|
||||||
shutil.copyfileobj(src, tmprc)
|
shutil.copyfileobj(src, tmprc)
|
||||||
tmprc.write('\nexport PS1="[gst-%s] $PS1"' % gst_version)
|
tmprc.write('\nexport PS1="[gst-%s] $PS1"' % gst_version)
|
||||||
tmprc.flush()
|
tmprc.flush()
|
||||||
|
if is_bash_completion_available(options):
|
||||||
|
bash_completions_files = []
|
||||||
|
for p in BASH_COMPLETION_PATHS:
|
||||||
|
if os.path.exists(p):
|
||||||
|
bash_completions_files += os.listdir(path=p)
|
||||||
|
bc_rc = BC_RC.format(bash_completions=' '.join(bash_completions_files), bash_completions_paths=' '.join(BASH_COMPLETION_PATHS))
|
||||||
|
tmprc.write(bc_rc)
|
||||||
|
tmprc.flush()
|
||||||
args.append("--rcfile")
|
args.append("--rcfile")
|
||||||
args.append(tmprc.name)
|
args.append(tmprc.name)
|
||||||
elif args[0].endswith('fish'):
|
elif args[0].endswith('fish'):
|
||||||
|
|
Loading…
Reference in a new issue