[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #60618] Fixed directory string being removed on pressing TAB

From: Pedram Ashofteh Ardakani
Subject: [bug #60618] Fixed directory string being removed on pressing TAB
Date: Thu, 5 Aug 2021 15:06:53 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0

Follow-up Comment #5, bug #60618 (project gnuastro):

Look what I found straight from 'info'! Just type in: 'info bash program' and
then use ']' and navigate to 'A programmable completion example'. Then you can
find the actual bash completion program written for 'cd' itself!

Does it give you any ideas?

     # A completion function for the cd builtin
     # based on the cd completion function from the bash_completion package
         local IFS=$' \t\n'    # normalize IFS
         local cur _skipdot _cdpath
         local i j k

         # Tilde expansion, which also expands tilde to full pathname
         case "$2" in
         \~*)    eval cur="$2" ;;
         *)      cur=$2 ;;

         # no cdpath or absolute pathname -- straight directory completion
         if [[ -z "${CDPATH:-}" ]] || [[ "$cur" == @(./*|../*|/*) ]]; then
             # compgen prints paths one per line; could also use while loop
             COMPREPLY=( $(compgen -d -- "$cur") )
             IFS=$' \t\n'
         # CDPATH+directories in the current directory if not in CDPATH
             # preprocess CDPATH to convert null directory names to .
             for i in ${_cdpath//:/$'\n'}; do
                 if [[ $i -ef . ]]; then _skipdot=true; fi
                 for j in $( compgen -d -- "$i/$cur" ); do
                     COMPREPLY[k++]=${j#$i/}        # cut off directory
             $_skipdot || COMPREPLY+=( $(compgen -d -- "$cur") )
             IFS=$' \t\n'

         # variable names if appropriate shell option set and no completions
         if shopt -q cdable_vars && [[ ${#COMPREPLY[@]} -eq 0 ]]; then
             COMPREPLY=( $(compgen -v -- "$cur") )

         return 0


Reply to this item at:


  Message sent via Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]