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