mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
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:
commit
c88f106471
@ -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} )"
|
||||
|
Loading…
Reference in New Issue
Block a user