/bash_completion_lib/include/_expand

http://github.com/brinkman83/bashrc · #! · 16 lines · 14 code · 2 blank · 0 comment · 0 complexity · 4d9b58ae5dd42a5d389a1f47658d7fb0 MD5 · raw file

  1. # This function expands tildes in pathnames
  2. #
  3. _expand()
  4. {
  5. [ "$cur" != "${cur%\\}" ] && cur="$cur\\"
  6. # expand ~username type directory specifications
  7. if [[ "$cur" == \~*/* ]]; then
  8. eval cur=$cur
  9. elif [[ "$cur" == \~* ]]; then
  10. cur=${cur#\~}
  11. COMPREPLY=( $( compgen -P '~' -u $cur ) )
  12. return ${#COMPREPLY[@]}
  13. fi
  14. }