39 lines
914 B
Bash
39 lines
914 B
Bash
|
_realpath() {
|
||
|
local i cur prev opts cmd
|
||
|
COMPREPLY=()
|
||
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||
|
cmd=""
|
||
|
opts=""
|
||
|
|
||
|
for i in ${COMP_WORDS[@]}
|
||
|
do
|
||
|
case "${cmd},${i}" in
|
||
|
",$1")
|
||
|
cmd="realpath"
|
||
|
;;
|
||
|
*)
|
||
|
;;
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
case "${cmd}" in
|
||
|
realpath)
|
||
|
opts="-q -h -V --quiet --help --version [path]..."
|
||
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
|
||
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||
|
return 0
|
||
|
fi
|
||
|
case "${prev}" in
|
||
|
*)
|
||
|
COMPREPLY=()
|
||
|
;;
|
||
|
esac
|
||
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||
|
return 0
|
||
|
;;
|
||
|
esac
|
||
|
}
|
||
|
|
||
|
complete -F _realpath -o bashdefault -o default realpath
|