diff options
author | Sami Kerola <kerolasa@iki.fi> | 2019-01-12 11:14:15 +0000 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2019-04-02 12:12:03 +0200 |
commit | 3e3b276c87b9bbf6017d4f4fd738877ffaeff610 (patch) | |
tree | 451303fc0cd8d0d35976d6ea1bea733827ea544a | |
parent | 539fb3c722d2cc867fa547276d01e977b07a38fa (diff) | |
download | util-linux-3e3b276c87b9bbf6017d4f4fd738877ffaeff610.tar.gz |
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>
-rw-r--r-- | bash-completion/umount | 20 |
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 |