Merge branch 'wip/oholy/gio-completion' into 'master'

Several gio-tool bash completion fixes and improvements

See merge request GNOME/glib!1153
This commit is contained in:
Philip Withnall 2019-10-07 09:23:41 +00:00
commit c88f106471

View File

@ -43,20 +43,19 @@ __gio_location() {
if [[ $cur =~ "/"$ ]]; then
dir="$cur"
elif [[ $cur =~ "/" ]]; then
dir="$(dirname "$cur")/"
# Subtract basename because dirname cmd doesn't work well with schemes
dir=${cur%$(basename "$cur")}
fi
# List daemon mounts, just if dir is not specified, or looks like scheme
local mounts=()
if [[ $dir == "" ]] || [[ $dir =~ ":"$ && ! $dir =~ "/" ]]; then
while IFS=$'\n' read mount; do
# Do not care about local mounts
[[ "$mount" =~ ^"file:" ]] && continue
# List volumes and mounts
local mounts=( )
while IFS=$'\n' read mount; do
# Do not care about local mounts
[[ "$mount" =~ ^"file:" ]] && continue
# Use only matching mounts
[[ "$mount" =~ ^"$cur" && "$mount" != "$cur" ]] && mounts+=("$mount")
done < <(gio mount -l | sed -n -r 's/^ *Mount\([0-9]+\): .* -> (.*)$/\1/p')
fi
# Use only matching mounts
[[ "$mount" =~ ^"$cur" && "$mount" != "$cur" ]] && mounts+=("$mount")
done < <(gio mount -li | sed -n -r 's/^ *(default_location|activation_root)=(.*)$/\2/p' | sort -u)
# Workaround to unescape dir name (e.g. "\ " -> " ")
declare -a tmp="( ${dir} )"