mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 22:16:16 +01:00
Merge branch 'completion-bins' into 'main'
completion: Invoke the command being completed See merge request GNOME/glib!4013
This commit is contained in:
commit
81eaabb308
@ -1,3 +1,20 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2013 Allison Karlitskaya
|
||||||
|
#
|
||||||
|
# This library is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 2.1 of the
|
||||||
|
# licence, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This 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 Lesser General Public
|
||||||
|
# License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
@ -7,6 +24,9 @@
|
|||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
|
||||||
__app() {
|
__app() {
|
||||||
|
local gapplication_binary
|
||||||
|
gapplication_binary="$1"
|
||||||
|
|
||||||
case "${COMP_CWORD}" in
|
case "${COMP_CWORD}" in
|
||||||
1)
|
1)
|
||||||
# shellcheck disable=SC2207
|
# shellcheck disable=SC2207
|
||||||
@ -18,7 +38,7 @@ __app() {
|
|||||||
case "${COMP_WORDS[1]}" in
|
case "${COMP_WORDS[1]}" in
|
||||||
launch|action|list-actions)
|
launch|action|list-actions)
|
||||||
# shellcheck disable=SC2207
|
# shellcheck disable=SC2207
|
||||||
COMPREPLY=($(compgen -W "$(gapplication list-apps)" -- "${COMP_WORDS[2]}"))
|
COMPREPLY=($(compgen -W "$("$gapplication_binary" list-apps)" -- "${COMP_WORDS[2]}"))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@ -36,7 +56,7 @@ __app() {
|
|||||||
# Word 3 is the action name. This is the only one we can help with.
|
# Word 3 is the action name. This is the only one we can help with.
|
||||||
if [ "${COMP_CWORD}" == 3 ]; then
|
if [ "${COMP_CWORD}" == 3 ]; then
|
||||||
# shellcheck disable=SC2207
|
# shellcheck disable=SC2207
|
||||||
COMPREPLY=($(compgen -W "$(gapplication list-actions "${COMP_WORDS[2]}")" -- "${COMP_WORDS[3]}"))
|
COMPREPLY=($(compgen -W "$("$gapplication_binary" list-actions "${COMP_WORDS[2]}")" -- "${COMP_WORDS[3]}"))
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
|
@ -1,3 +1,20 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2010 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# This library is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 2.1 of the
|
||||||
|
# licence, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This 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 Lesser General Public
|
||||||
|
# License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
@ -8,12 +25,15 @@
|
|||||||
|
|
||||||
|
|
||||||
__gdbus() {
|
__gdbus() {
|
||||||
|
local gdbus_binary
|
||||||
|
gdbus_binary="$1"
|
||||||
|
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local cur
|
local cur
|
||||||
cur="$(_get_cword :)"
|
cur="$(_get_cword :)"
|
||||||
|
|
||||||
local suggestions
|
local suggestions
|
||||||
suggestions="$(gdbus complete "${COMP_LINE}" "${COMP_POINT}")"
|
suggestions="$("$gdbus_binary" complete "${COMP_LINE}" "${COMP_POINT}")"
|
||||||
# shellcheck disable=SC2207
|
# shellcheck disable=SC2207
|
||||||
COMPREPLY=($(compgen -W "$suggestions" -- "$cur"))
|
COMPREPLY=($(compgen -W "$suggestions" -- "$cur"))
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this library; if not, see <http://www.gnu.org/licenses/>.
|
# along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
@ -37,6 +38,8 @@ __gio_has_common_prefix() {
|
|||||||
|
|
||||||
# Complete file location
|
# Complete file location
|
||||||
__gio_location() {
|
__gio_location() {
|
||||||
|
local gio_binary
|
||||||
|
gio_binary="$1"
|
||||||
# Prevent breaking on colons, we have to work with uris
|
# Prevent breaking on colons, we have to work with uris
|
||||||
local cur
|
local cur
|
||||||
_get_comp_words_by_ref -n : cur
|
_get_comp_words_by_ref -n : cur
|
||||||
@ -59,7 +62,7 @@ __gio_location() {
|
|||||||
|
|
||||||
# Use only matching mounts
|
# Use only matching mounts
|
||||||
[[ "$mount" =~ ^"$cur" && "$mount" != "$cur" ]] && mounts+=("$mount")
|
[[ "$mount" =~ ^"$cur" && "$mount" != "$cur" ]] && mounts+=("$mount")
|
||||||
done < <(gio mount -li | sed -n -r 's/^ *(default_location|activation_root)=(.*)$/\2/p' | sort -u)
|
done < <("$gio_binary" mount -li | sed -n -r 's/^ *(default_location|activation_root)=(.*)$/\2/p' | sort -u)
|
||||||
|
|
||||||
# Workaround to unescape dir name (e.g. "\ " -> " ")
|
# Workaround to unescape dir name (e.g. "\ " -> " ")
|
||||||
local -a tmp="( ${dir} )"
|
local -a tmp="( ${dir} )"
|
||||||
@ -88,7 +91,7 @@ __gio_location() {
|
|||||||
files+=("$path")
|
files+=("$path")
|
||||||
names+=("$escaped_name")
|
names+=("$escaped_name")
|
||||||
fi
|
fi
|
||||||
done < <(gio list -hl "$unescaped_dir" 2> /dev/null)
|
done < <("$gio_binary" list -hl "$unescaped_dir" 2> /dev/null)
|
||||||
|
|
||||||
COMPREPLY=("${files[@]}" "${mounts[@]}")
|
COMPREPLY=("${files[@]}" "${mounts[@]}")
|
||||||
|
|
||||||
@ -118,7 +121,7 @@ __gio() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Complete file locations
|
# Complete file locations
|
||||||
__gio_location
|
__gio_location "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
@ -1,3 +1,20 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2012 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# This library is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 2.1 of the
|
||||||
|
# licence, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This 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 Lesser General Public
|
||||||
|
# License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
@ -7,7 +24,8 @@
|
|||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
|
||||||
__gresource() {
|
__gresource() {
|
||||||
local choices coffset
|
local choices coffset gresource_binary
|
||||||
|
gresource_binary="$1"
|
||||||
|
|
||||||
if [ "${COMP_CWORD}" -gt 2 ]; then
|
if [ "${COMP_CWORD}" -gt 2 ]; then
|
||||||
if [ "${COMP_WORDS[1]}" = --section ]; then
|
if [ "${COMP_WORDS[1]}" = --section ]; then
|
||||||
@ -45,7 +63,7 @@ __gresource() {
|
|||||||
3)
|
3)
|
||||||
case "${COMP_WORDS[$((coffset+1))]}" in
|
case "${COMP_WORDS[$((coffset+1))]}" in
|
||||||
list|details|extract)
|
list|details|extract)
|
||||||
choices="$(gresource list "${COMP_WORDS[$((coffset+2))]}" 2> /dev/null | sed -e 's.$. .')"
|
choices="$("$gresource_binary" list "${COMP_WORDS[$((coffset+2))]}" 2> /dev/null | sed -e 's.$. .')"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2010, 2012 Red Hat, Inc.
|
||||||
|
# Copyright 2010 Allison Karlitskaya
|
||||||
|
# Copyright 2011 Giovanni Campagna
|
||||||
|
#
|
||||||
|
# This library is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 2.1 of the
|
||||||
|
# licence, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This 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 Lesser General Public
|
||||||
|
# License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
@ -7,12 +26,16 @@
|
|||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
|
||||||
__gsettings() {
|
__gsettings() {
|
||||||
local choices coffset schemadir=""
|
local choices coffset schemadir=() gsettings_binary
|
||||||
|
gsettings_binary="$1"
|
||||||
|
|
||||||
if [ "${COMP_CWORD}" -gt 2 ]; then
|
if [ "${COMP_CWORD}" -gt 2 ]; then
|
||||||
if [ "${COMP_WORDS[1]}" = --schemadir ]; then
|
if [ "${COMP_WORDS[1]}" = --schemadir ]; then
|
||||||
# this complexity is needed to perform correct tilde expansion
|
# The eval complexity is needed to perform correct tilde expansion
|
||||||
schemadir=$(eval "echo --schemadir ${COMP_WORDS[2]}")
|
# The array is needed to ensure we can keep it expanding to either zero
|
||||||
|
# or one option in the commands below, while keeping quoting correct.
|
||||||
|
# See https://www.shellcheck.net/wiki/SC2086
|
||||||
|
schemadir=("--schemadir" "$(eval "echo ${COMP_WORDS[2]}")")
|
||||||
coffset=2
|
coffset=2
|
||||||
else
|
else
|
||||||
coffset=0
|
coffset=0
|
||||||
@ -38,7 +61,7 @@ __gsettings() {
|
|||||||
choices=$'list-schemas\nlist-relocatable-schemas\nlist-keys\nlist-children\nlist-recursively\nget\nrange\nset\nreset\nreset-recursively\nwritable\nmonitor'
|
choices=$'list-schemas\nlist-relocatable-schemas\nlist-keys\nlist-children\nlist-recursively\nget\nrange\nset\nreset\nreset-recursively\nwritable\nmonitor'
|
||||||
;;
|
;;
|
||||||
list-keys|list-children|list-recursively|reset-recursively)
|
list-keys|list-children|list-recursively|reset-recursively)
|
||||||
choices="$(gsettings "$schemadir" list-schemas 2> /dev/null)"$'\n'"$(gsettings "$schemadir" list-relocatable-schemas 2> /dev/null | sed -e 's.$.:/.')"
|
choices="$("$gsettings_binary" "${schemadir[@]}" list-schemas 2> /dev/null)"$'\n'"$("$gsettings_binary" "${schemadir[@]}" list-relocatable-schemas 2> /dev/null | sed -e 's.$.:/.')"
|
||||||
;;
|
;;
|
||||||
list-schemas)
|
list-schemas)
|
||||||
# shellcheck disable=SC2207
|
# shellcheck disable=SC2207
|
||||||
@ -47,7 +70,7 @@ __gsettings() {
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
get|range|set|reset|writable|monitor|describe)
|
get|range|set|reset|writable|monitor|describe)
|
||||||
choices="$(gsettings "$schemadir" list-schemas 2> /dev/null | sed -e 's.$. .')"$'\n'"$(gsettings "$schemadir" list-relocatable-schemas 2> /dev/null | sed -e 's.$.:/.')"
|
choices="$("$gsettings_binary" "${schemadir[@]}" list-schemas 2> /dev/null | sed -e 's.$. .')"$'\n'"$("$gsettings_binary" "${schemadir[@]}" list-relocatable-schemas 2> /dev/null | sed -e 's.$.:/.')"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
@ -55,11 +78,11 @@ __gsettings() {
|
|||||||
3)
|
3)
|
||||||
case "${COMP_WORDS[$((coffset+1))]}" in
|
case "${COMP_WORDS[$((coffset+1))]}" in
|
||||||
set)
|
set)
|
||||||
choices="$(gsettings "$schemadir" list-keys "${COMP_WORDS[$((coffset+2))]}" 2> /dev/null | sed -e 's.$. .')"
|
choices="$("$gsettings_binary" "${schemadir[@]}" list-keys "${COMP_WORDS[$((coffset+2))]}" 2> /dev/null | sed -e 's.$. .')"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
get|range|reset|writable|monitor|describe)
|
get|range|reset|writable|monitor|describe)
|
||||||
choices="$(gsettings "$schemadir" list-keys "${COMP_WORDS[$((coffset+2))]}" 2> /dev/null)"
|
choices="$("$gsettings_binary" "${schemadir[@]}" list-keys "${COMP_WORDS[$((coffset+2))]}" 2> /dev/null)"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
@ -68,7 +91,7 @@ __gsettings() {
|
|||||||
case "${COMP_WORDS[$((coffset+2))]}" in
|
case "${COMP_WORDS[$((coffset+2))]}" in
|
||||||
set)
|
set)
|
||||||
# shellcheck disable=SC2207
|
# shellcheck disable=SC2207
|
||||||
range=($(gsettings "$schemadir" range "${COMP_WORDS[$((coffset+2))]}" "${COMP_WORDS[$((coffset+3))]}" 2> /dev/null))
|
range=($("$gsettings_binary" "${schemadir[@]}" range "${COMP_WORDS[$((coffset+2))]}" "${COMP_WORDS[$((coffset+3))]}" 2> /dev/null))
|
||||||
case "${range[0]}" in
|
case "${range[0]}" in
|
||||||
enum)
|
enum)
|
||||||
unset 'range[0]'
|
unset 'range[0]'
|
||||||
|
Loading…
Reference in New Issue
Block a user