summaryrefslogtreecommitdiffstats
path: root/bash-completion
diff options
context:
space:
mode:
authorSami Kerola2019-01-12 12:14:15 +0100
committerSami Kerola2019-01-12 20:29:37 +0100
commit3ebfc8d370d21c875cde325532f580acb6250e3d (patch)
treee12f97cc72bb76277f62033055efb6b1f714acdc /bash-completion
parentlogin: add support for login.defs(5) LASTLOG_UID_MAX (diff)
downloadkernel-qcow2-util-linux-3ebfc8d370d21c875cde325532f580acb6250e3d.tar.gz
kernel-qcow2-util-linux-3ebfc8d370d21c875cde325532f580acb6250e3d.tar.xz
kernel-qcow2-util-linux-3ebfc8d370d21c875cde325532f580acb6250e3d.zip
bash-completion: umount support relative path and ~ as home shorthands
Addresses: https://github.com/karelzak/util-linux/issues/703 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'bash-completion')
-rw-r--r--bash-completion/umount20
1 files changed, 19 insertions, 1 deletions
diff --git a/bash-completion/umount b/bash-completion/umount
index 496474a9b..7fc2bd376 100644
--- a/bash-completion/umount
+++ b/bash-completion/umount
@@ -51,7 +51,25 @@ _umount_module()
local oldifs=$IFS
IFS=$'\n'
- COMPREPLY=( $( compgen -W '$(findmnt -lno TARGET | sed "s/\([[:blank:]]\)/\\\\\1/g")' -- "$cur" ) )
+ COMPREPLY=( $( compgen -W "$(findmnt -lno TARGET | awk \
+ '{
+ if ($0 ~ ENVIRON["HOME"]) {
+ homeless = $0
+ homeless = gensub(ENVIRON["HOME"], "\\\\~", "g", homeless)
+ homeless = gensub(/(\s)/, "\\\\\\1", "g", homeless)
+ print homeless
+ }
+ if ($0 ~ ENVIRON["PWD"]) {
+ reldir = $0
+ reldir = gensub(ENVIRON["PWD"]"/", "", "g", reldir)
+ reldir = gensub(/(\s)/, "\\\\\\1", "g", reldir)
+ print "./" reldir
+ print reldir
+ }
+ gsub(/\s/, "\\\\&")
+ print $0
+ }'
+ )" -- "$cur" ) )
IFS=$oldifs
}
complete -F _umount_module umount