[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
_comp_cd()
{
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 ;;
esac
# no cdpath or absolute pathname -- straight directory completion
if [[ -z "${CDPATH:-}" ]] || [[ "$cur" == @(./*|../*|/*) ]]; then
# compgen prints paths one per line; could also use while loop
IFS=$'\n'
COMPREPLY=( $(compgen -d -- "$cur") )
IFS=$' \t\n'
# CDPATH+directories in the current directory if not in CDPATH
else
IFS=$'\n'
_skipdot=false
# preprocess CDPATH to convert null directory names to .
_cdpath=${CDPATH/#:/.:}
_cdpath=${_cdpath//::/:.:}
_cdpath=${_cdpath/%:/:.}
for i in ${_cdpath//:/$'\n'}; do
if [[ $i -ef . ]]; then _skipdot=true; fi
k="${#COMPREPLY[@]}"
for j in $( compgen -d -- "$i/$cur" ); do
COMPREPLY[k++]=${j#$i/} # cut off directory
done
done
$_skipdot || COMPREPLY+=( $(compgen -d -- "$cur") )
IFS=$' \t\n'
fi
# variable names if appropriate shell option set and no completions
if shopt -q cdable_vars && [[ ${#COMPREPLY[@]} -eq 0 ]]; then
COMPREPLY=( $(compgen -v -- "$cur") )
fi
return 0
}
----
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?60618>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [bug #60618] Fixed directory string being removed on pressing TAB,
Pedram Ashofteh Ardakani <=