2014-11-17 13:50:19 +01:00
|
|
|
---
|
2016-12-14 12:49:24 +01:00
|
|
|
bash_completion | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
|
1 file changed, 46 insertions(+), 1 deletion(-)
|
2014-11-17 13:50:19 +01:00
|
|
|
|
|
|
|
--- bash_completion
|
2017-07-04 09:57:49 +02:00
|
|
|
+++ bash_completion 2017-07-04 07:44:47.556933294 +0000
|
2020-01-07 11:08:21 +01:00
|
|
|
@@ -555,6 +555,7 @@ _filedir()
|
2016-12-14 12:49:24 +01:00
|
|
|
local IFS=$'\n'
|
2015-03-18 14:07:18 +01:00
|
|
|
|
2016-12-14 12:49:24 +01:00
|
|
|
_tilde "$cur" || return
|
|
|
|
+ _dollar "$cur" || return
|
2015-03-18 14:07:18 +01:00
|
|
|
|
2014-11-17 13:50:19 +01:00
|
|
|
local -a toks
|
2020-01-07 11:08:21 +01:00
|
|
|
local reset
|
|
|
|
@@ -1006,6 +1007,41 @@ _tilde()
|
2015-03-18 14:07:18 +01:00
|
|
|
return $result
|
|
|
|
}
|
|
|
|
|
|
|
|
+# Perform dollar ($) completion
|
|
|
|
+# @return True (0) if completion needs further processing,
|
2015-03-18 14:49:08 +01:00
|
|
|
+# False (> 0) if dollar is followed by a valid username, completions
|
2015-03-18 14:07:18 +01:00
|
|
|
+# are put in COMPREPLY and no further processing is necessary.
|
|
|
|
+_dollar()
|
|
|
|
+{
|
|
|
|
+ local s=""
|
|
|
|
+ local -i glob=0
|
|
|
|
+
|
|
|
|
+ shopt -q extglob && let glob++
|
|
|
|
+ ((glob == 0)) && shopt -s extglob
|
|
|
|
+
|
|
|
|
+ [[ "$COMP_LINE" == cd* ]] && s="/"
|
|
|
|
+
|
|
|
|
+ case "$1" in
|
|
|
|
+ \$\(*|\`*)
|
|
|
|
+ COMPREPLY=($(compgen -c -P '$(' -S ")$s" -- ${1#??})) ;;
|
|
|
|
+ \$\{*)
|
|
|
|
+ COMPREPLY=($(compgen -v -P '${' -S "}$s" -- ${1#??})) ;;
|
|
|
|
+ \$*)
|
|
|
|
+ COMPREPLY=($(compgen -v -P '$' ${s:+-S $s} -- ${1#?})) ;;
|
|
|
|
+ *)
|
|
|
|
+ ((glob == 0)) && shopt -u extglob
|
|
|
|
+ return 0
|
|
|
|
+ esac
|
|
|
|
+
|
|
|
|
+ if ((${#COMPREPLY[@]} > 0)) ; then
|
|
|
|
+ ((${#COMPREPLY[@]} == 1)) && eval COMPREPLY=\(${COMPREPLY[@]}\)
|
|
|
|
+ else
|
|
|
|
+ eval COMPREPLY=\(${1}\)
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
+ ((glob == 0)) && shopt -u extglob
|
|
|
|
+ return ${#COMPREPLY[@]}
|
|
|
|
+}
|
|
|
|
|
|
|
|
# Expand variable starting with tilde (~)
|
|
|
|
# We want to expand ~foo/... to /home/foo/... to avoid problems when
|
2020-01-07 11:08:21 +01:00
|
|
|
@@ -1720,7 +1756,16 @@ complete -F _known_hosts traceroute traceroute6 \
|
2015-03-18 14:07:18 +01:00
|
|
|
_cd()
|
|
|
|
{
|
|
|
|
local cur prev words cword
|
|
|
|
- _init_completion || return
|
|
|
|
+ _init_completion || {
|
|
|
|
+ if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
|
|
|
|
+ local i=${COMPREPLY[0]}
|
|
|
|
+ if [[ "$i" == "$cur" && $i != "*/" ]]; then
|
|
|
|
+ _dollar "$i" || return
|
|
|
|
+ COMPREPLY[0]="${i%%/}/"
|
|
|
|
+ fi
|
|
|
|
+ fi
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
|
|
|
|
local IFS=$'\n' i j k
|
|
|
|
|