about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-09-30 14:53:07 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-09-30 14:53:07 +0000
commitac92473443271dea6f6a68a7bcddb91536a716b2 (patch)
tree91d8a47c2c37178adff68e841257111b1f5b8ee4
parent25497a3818eadf0ff09a444ec268908263b74892 (diff)
downloadzsh-ac92473443271dea6f6a68a7bcddb91536a716b2.tar.gz
zsh-ac92473443271dea6f6a68a7bcddb91536a716b2.tar.xz
zsh-ac92473443271dea6f6a68a7bcddb91536a716b2.zip
zsh-workers/8108
-rw-r--r--Completion/Commands/_bash_completions43
-rw-r--r--Doc/Zsh/compsys.yo20
2 files changed, 63 insertions, 0 deletions
diff --git a/Completion/Commands/_bash_completions b/Completion/Commands/_bash_completions
new file mode 100644
index 000000000..5f3adc1e0
--- /dev/null
+++ b/Completion/Commands/_bash_completions
@@ -0,0 +1,43 @@
+#compdef -K _bash_complete-word complete-word \e~ _bash_list-choices list-choices ^X~
+#
+# This function is for bash compatibility.  As some of the bash bindings
+# are already taken up in zsh, only Esc ~ and \C-x ~ are bound, and
+# you must add the rest by hand.  The bindings expected are:
+#
+# Esc ! -> command name
+# Esc $ -> environment variables
+# Esc @ -> machine names
+# Esc / -> file name
+# Esc ~ -> a user name
+# 
+# C-x instead of Esc with one of the above will list matches and won't
+# attempt any completion.
+#
+# The following will bind the remaining set; simply put it in .zshrc
+# after compinit is run.
+#
+# for key in '!' '$' '@' '/'; do
+#   bindkey "\e$key" _bash_complete-word
+#   bindkey "^X$key" _bash_list-choices
+# done
+#
+# If for some reason \e~ or ^X~ were already bound to something else,
+# that will not have been overridden, so you should add '~' to the
+# list of keys at the top of the for-loop.
+
+local key=$KEYS[-1]
+
+case $key in
+  '!') _main_complete _command_names
+       ;;
+  '$') compgen -E
+       ;;
+  '@') _main_complete _hosts
+       ;;
+  '/') _files
+       ;;
+  '~') _main_complete _users
+       ;;
+  *) _message "Key $key is not understood"
+     ;;
+esac
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 851ef8471..7c38dac27 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -1170,6 +1170,26 @@ implementing special behaviour which can be bound separately to keys.  The
 following is a list of these and their default bindings.
 
 startitem()
+item(tt(_bash_completions))(
+This function is used by two widgets, tt(_bash_complete-word) and
+tt(_bash_list-choices).  It exists to provide compatibility with
+completion bindings in bash.  The last character of the binding determines
+what is completed: `tt(!)', command names; `tt($)', environment variables;
+`tt(@)', host names; `tt(/)', file names; `tt(~)' user names.  In bash, the
+binding preceeded by `tt(\e)' gives completion, and preceeded by `tt(^X)'
+lists options.  As some of these bindings clash with standard zsh
+bindings, only `tt(\e~)' and `tt(^X~)' are bound by default.  To add the
+rest, the following should be added to tt(.zshrc) after tt(compinit) has
+been run:
+
+example(for key in '!' '$' '@' '/' '~'; do
+  bindkey "\e$key" _bash_complete-word
+  bindkey "^X$key" _bash_list-choices
+done)
+
+This includes the bindings for `tt(~)' in case they were already bound to
+something else; the completion code does not override user bindings.
+)
 item(tt(_correct_filename (^XC)))(
 Correct the filename path at the cursor position.  Allows up to six errors
 in the name.  Can also be called with an argument to correct