[Bash-completion-commits] ./current r1135: added _remove_cword()
David Paleino
d.paleino at gmail.com
Mon Jun 23 09:33:52 UTC 2008
------------------------------------------------------------
revno: 1135
committer: David Paleino <d.paleino at gmail.com>
branch nick: current
timestamp: Mon 2008-06-23 11:33:52 +0200
message:
added _remove_cword()
modified:
bash_completion
debian/changelog
-------------- next part --------------
=== modified file 'bash_completion'
--- a/bash_completion 2008-06-23 09:28:11 +0000
+++ b/bash_completion 2008-06-23 09:33:52 +0000
@@ -3158,6 +3158,37 @@
complete -F _cd $nospace $filenames cd
fi
+_remove_comp_word()
+{
+ if [[ COMP_CWORD -eq 0 ]]; then
+ return
+ elif [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
+ local old_cw0="${COMP_WORDS[0]}"
+ local new_cw0="${COMP_WORDS[1]}"
+ local old_length="${#COMP_LINE}"
+ COMP_LINE=${COMP_LINE#${old_cw0}}
+ local head=${COMP_LINE:0:${#new_cw0}}
+ local i=1
+ while [[ $head != $new_cw0 ]]; do
+ COMP_LINE=${COMP_LINE:1}
+ head=${COMP_LINE:0:${#new_cw0}}
+ if (( ++i > 10 )); then
+ break
+ fi
+ done
+ local new_length="${#COMP_LINE}"
+ COMP_POINT=$(( COMP_POINT + new_length - old_length ))
+
+ COMP_CWORD=$(( COMP_CWORD - 1 ))
+ for (( i=0; i < ${#COMP_WORDS[@]} - 1; ++i )); do
+ COMP_WORDS[i]="${COMP_WORDS[i+1]}"
+ done
+ unset COMP_WORDS[${#COMP_WORDS[#]}-1]
+ else
+ return
+ fi
+}
+
# A meta-command completion function for commands like sudo(8), which need to
# first complete on a command, then complete according to that command's own
# completion definition - currently not quite foolproof (e.g. mount and umount
=== modified file 'debian/changelog'
--- a/debian/changelog 2008-06-23 09:28:11 +0000
+++ b/debian/changelog 2008-06-23 09:33:52 +0000
@@ -2,6 +2,7 @@
* Merged Ubuntu changes:
- added quote(), quote_readline(), dequote() helper functions.
+ - added _remove_cword()
- fixed _get_cword()
- refactored _filedir using quote_readline()
- fixed COMPREPLY's in _iwconfig
@@ -9,7 +10,7 @@
- _known_hosts(): use files from UserKnownHostsFile options in
addition to standard ones.
- -- David Paleino <d.paleino at gmail.com> Mon, 23 Jun 2008 11:26:28 +0200
+ -- David Paleino <d.paleino at gmail.com> Mon, 23 Jun 2008 11:33:28 +0200
bash-completion (20080617.3) unstable; urgency=low
More information about the Bash-completion-commits
mailing list