Commit c88f1064 authored by Philip Withnall's avatar Philip Withnall

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

Several gio-tool bash completion fixes and improvements

See merge request !1153
parents a350fa50 b3bf1e26
Pipeline #121439 failed with stages
in 22 minutes and 14 seconds
......@@ -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} )"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment