Giter VIP home page Giter VIP logo

auto-fu.zsh's Introduction

zsh automatic complete-word and list-choices

Originally incr-0.2.zsh
Incremental completion for zsh
by y.fujii <y-fujii at mimosa-pudica.net>

Thank you very much y.fujii!

Adapted by Takeshi Banse <[email protected]>, public domain
I want to use it with menu selection.

To use this,
1) source this file.
% source auto-fu.zsh
2) establish `zle-line-init' containing `auto-fu-init' something like below.
% zle-line-init () {auto-fu-init;}; zle -N zle-line-init
3) use the _oldlist completer something like below.
% zstyle ':completion:*' completer _oldlist _complete
(If you have a lot of completer, please insert _oldlist before _complete.)
4) establish `zle-keymap-select' containing `auto-fu-zle-keymap-select'.
% zle -N zle-keymap-select auto-fu-zle-keymap-select
(This enables the afu-vicmd keymap switching coordinates a bit.)
*Optionally* you can use the zcompiled file for a little faster loading on
every shell startup, if you zcompile the necessary functions.
*1) zcompile the defined functions. (generates ~/.zsh/auto-fu.zwc)
% A=/path/to/auto-fu.zsh; (zsh -c "source $A ; auto-fu-zcompile $A ~/.zsh")
*2) source the zcompiled file instead of this file and some tweaks.
% source ~/.zsh/auto-fu; auto-fu-install
*3) establish `zle-line-init' and such (same as a few lines above).
Note:
It is approximately *(6~10) faster if zcompiled, according to this result :)
TIMEFMT="%*E %J"
0.041 ( source ./auto-fu.zsh; )
0.004 ( source ~/.zsh/auto-fu; auto-fu-install; )
Here is the auto-fu-zcompile manual.
--- >8 ---
NAME
       auto-fu-zcompile - zcompile auto-fu
SYNOPSIS
       auto-fu-zcompile <auto-fu.zsh file> <directory to output>
              [<restoffiles>...]
DESCRIPTION
       This command dumps out the auto-fu's functions, zle and stuff to
       <directory to output>/auto-fu. This is inspired from `compinit' which
       dumps out the completion system's internal stuff to ~/.zcompdump.
       Then `zrecompile' the <directory to output>/auto-fu.
       As you can see, auto-fu.zsh has some `eval' calls, so it may result
       poor loading performance. I want to avoid that as far as possible, so
       the resulting file (~/.zsh/auto-fu) has fewer `eval's and stripped
       unnecessary things at runtime.
       afu+* and auto-fu* widgets and afu+* functions will *NOT* be
       stripped by auto-fu-zcompile.
OPTIONS
       <auto-fu.zsh file>
           This file.
       <directory to output>
           Directory to dumped and zcompiled files reside.
       [<restoffile>...]
           Files to be `source'ed right before the dumped file creation.
           auto-fu-zcompile will strip unnecessary stuff, so some utility
           shell functions will not be available at runtime. If you want
           to customize auto-fu stuff using auto-fu.zsh's internal
           functions, you can code it at this point (example below).
EXAMPLES
       .   zcompile auto-fu in ~/.zsh.d:
               % A=/path/to/auto-fu.zsh
               % (zsh -c "source $A ; auto-fu-zcompile $A ~/.zsh.d")
       .   Customize some not-easily-customizable things:
               % A=/path/to/auto-fu.zsh
               % (zsh -c "source $A ; \
                 auto-fu-zcompile $A ~/.zsh.d ~/.zsh/auto-fu-customize.zsh")
           '~/.zsh/auto-fu-customize.zsh' is something like this:
>
             afu+my-kill-line-maybe () {
               if (($#BUFFER > CURSOR));
               then zle kill-line
               else zle kill-whole-line
               fi
             }
             zle -N afu+my-kill-line-maybe
             afu-register-zle-eof \
               afu+orf-ignoreeof-deletechar-list \
               afu-ignore-eof afu+my-kill-line-maybe
             afu-register-zle-eof \
               afu+orf-exit-deletechar-list exit afu+my-kill-line-maybe
<
           Using `afu-register-zle-eof' to customize the <C-d> behaviors.
--- 8< ---

Configuration
The auto-fu features can be configured via zstyle.

:auto-fu:highlight
  input
    A highlight specification used for user input string.
  completion
    A highlight specification used for completion string.
  completion/one
    A highlight specification used for completion string if it is the
    only one candidate.
:auto-fu:var
  postdisplay
    An initial indication string for POSTDISPLAY in auto-fu-init.
  postdisplay/clearp
    If set, POSTDISPLAY will be cleared after the accept-lines.
    'yes' by default.
  enable
    A list of zle widget names the automatic complete-word and
    list-choices to be triggered after its invocation.
    Only with ALL in 'enable', the 'disable' style has any effect.
    ALL by default.
  disable
    A list of zle widget names you do *NOT* want the complete-word to be
    triggered. Only used if 'enable' contains ALL. For example,
      zstyle ':auto-fu:var' enable all
      zstyle ':auto-fu:var' disable magic-space
    yields; complete-word will not be triggered after pressing the
    space-bar, otherwise automatic thing will be taken into account.
  track-keymap-skip
    A list of keymap names to *NOT* be treated as a keymap change.
    In other words, these keymaps cannot be used with the standalone main
    keymap. For example "opp". If you use my opp.zsh, please add an 'opp'
    to this zstyle.
  autoable-function/skipwords
  autoable-function/skiplbuffers
  autoable-function/skiplines
    A list of patterns to *NOT* be treated as auto-stuff appropriate.
    These patterns will be tested against the part of the command line
    buffer as shown on the below figure:
    (*) is used to denote the cursor position.
      # nocorrect aptitude --assume-*yes -d install zsh && echo ready
                           <-------->skipwords
                  <----------------->skiplbuffers
                  <----------------------------------->skplines
    Examples:
    - To disable auto-stuff inside single and also double quotes.
      And less than 3 chars before the cursor.
      zstyle ':auto-fu:var' autoable-function/skipwords \
        "('|$'|")*" "^((???)##)"
    - To disable the rm's first option, and also after the '(cvs|svn) co'.
      zstyle ':auto-fu:var' autoable-function/skiplbuffers \
        'rm -[![:blank:]]#' '(cvs|svn) co *'
    - To disable after the 'aptitude word '.
      zstyle ':auto-fu:var' autoable-function/skiplines \
        '([[:print:]]##[[:space:]]##|(#s)[[:space:]]#)aptitude [[:print:]]# *'
  autoable-function/preds
    A list of functions to be called whether auto-stuff appropriate or not.
    These functions will be called with the arguments (above figure)
      - $1 '--assume-'
      - $2 'aptitude'
      - $3 'aptitude --assume-'
      - $4 'aptitude --assume-yes -d install zsh'
    For example,
    to disable some 'perl -M' thing, we can do by the following zsh codes.
>
      afu-autoable-pm-p () { [[ ! ("$2" == 'perl' && "$1" == -(#i)m*) ]] }
      # retrieve default value into 'preds' to push the above function into.
      local -a preds; afu-autoable-default-functions preds
      preds+=afu-autoable-pm-p
      zstyle ':auto-fu:var' autoable-function/preds $preds
<
    The afu-autoable-dots-p is actually an example of this ability to skip
    uninteresting dots.
  autoablep-function
    A predicate function to determine whether auto-stuff could be
    appropriate. (Default `auto-fu-default-autoable-pred' implements the
    above autoablep-function/* functionality.)
Configuration example

zstyle ':auto-fu:highlight' input bold
zstyle ':auto-fu:highlight' completion fg=black,bold
zstyle ':auto-fu:highlight' completion/one fg=white,bold,underline
zstyle ':auto-fu:var' postdisplay $'
-azfu-'
zstyle ':auto-fu:var' track-keymap-skip opp
#zstyle ':auto-fu:var' disable magic-space

XXX: use with the error correction or _match completer.
If you got the correction errors during auto completing the word, then
plese do _not_ do `magic-space` or `accept-line`. Insted please do the
following, `undo` and then hit <tab> or throw away the buffer altogether.
This applies _match completer with complex patterns, too.
I'm very sorry for this annonying behaviour.
(For example, 'ls --bbb' and 'ls --*~^*al*' etc.)

XXX: ignoreeof semantics changes for overriding ^D.
You cannot change the ignoreeof option interactively. I'm verry sorry.
To customize the ^D behavior further, it will be done for example above
auto-fu-zcomple manual's EXAMPLE section's code. Please take a look.

TODO: play nice with zsh-syntax-highlighting.
TODO: http://d.hatena.ne.jp/tarao/20100531/1275322620
TODO: pause auto stuff until something happens. ("next magic-space" etc)
TODO: handle RBUFFER.
TODO: signal handling during the recursive edit.
TODO: handle empty or space characters.
TODO: cp x /usr/loc
TODO: region_highlight vs afu-able-p → nil
Do *NOT* clear the region_highlight if it should.
TODO: ^C-n could be used as the menu-select-key outside of the menuselect.
TODO: *-directories|all-files may not be enough.
TODO: recommend zcompiling.
TODO: undo should reset the auto stuff's state.
TODO: when `_match`ing,
sometimes extra <TAB> key is needed to enter the menu select,
sometimes is *not* needed. (already be entered menu select state.)

History

v0.0.1.12
fix some options potentially will be reset during the auto-stuff.
fix afu-keymap+widget to $afu_zles work in custom widgets.
Thank you very much for the reports, Christian271!

v0.0.1.11
play nice with banghist.
Thank you very much for the report, yoshikaw!
add autoablep-function machinery.
Thank you very much for the suggestion, tyru and kei_q!

v0.0.1.10
Fix not work auto-thing without extended_glob.
Thank you very much for the report, myuhe!

v0.0.1.9
add auto-fu-activate, auto-fu-deactivate and auto-fu-toggle.

v0.0.1.8.3
in afu+complete-word PAGER=<TAB> ⇒ PAGER=PAGER= bug fix.
Thank you very much for the report, tyru!

v0.0.1.8.2
afu+complete-word bug fixes.

v0.0.1.8.1
README.md

v0.0.1.8
add completion/one and postdisplay/clearp configurations.
add kill-word and yank to afu_zles.

v0.0.1.7
Fix "no such keymap `isearch'" error.
Thank you very much for the report, mooz and Shougo!

v0.0.1.6
Fix `parameter not set`. Thank you very much for the report, Shougo!
Bug fix.

v0.0.1.5
afu+complete-word bug (directory vs others) fix.

v0.0.1.4
afu+complete-word bug fixes.

v0.0.1.3
Teach ^D and magic-space.

v0.0.1.2
Add configuration option and auto-fu-zcompile for a little faster loading.

v0.0.1.1
Documentation typo fix.

v0.0.1
Initial version.

auto-fu.zsh's People

Contributors

hchbaw avatar uwabami avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

auto-fu.zsh's Issues

bug?

Hello,

I could not figure out if this is due to my settings or if everyone sees these messages once in a while?

--()------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(pts/43@master)--
which sr
which sr
/usr/bin/sr
sr is /usr/bin/sr
sr: /usr/bin/sr /usr/share/man/man1/sr.1.gz
/usr/bin/sr: symbolic link to surfraw' --(~)------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(pts/43@master)-- wafu-rhs-protect:15: bad math expression: operand expected at> 1 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 1' afu-rhs-protect:21: bad math expression: operator expected at1 fg=green...' work/
afu-rhs-protect:15: bad math expression: operand expected at > 1 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 1'wget wgetpaste whatis whereis which who whoami wipefs wordforms wordlist2hunspell write wrjpgcom wtpt
afu-rhs-protect:21: bad math expression: operator expected at none > 1 +...' afu-rhs-protect:15: bad math expression: operand expected at> 2 + 1' where which
afu-rhs-protect:18: bad math expression: operand expected at > 2' afu-rhs-protect:21: bad math expression: operator expected at1 fg=green...'afu-gvars with-afu-magic-insert
with-afu-region-highlight-saving with-afu-trapint with-afu-zle-rebinding
afu-rhs-protect:15: bad math expression: operand expected at > 2 + 1' with-afu-magic-insert with-afu-menuselecting-handling with-afu-resume with-afu-trapint-handling with-afu-zsh-syntax-highlighting afu-rhs-protect:18: bad math expression: operand expected at> 2'
afu-rhs-protect:21: bad math expression: operator expected at none > 2 +...' watchMarketSlow wget what which-command whafu-rhs-protect:15: bad math expression: operand expected at> 2 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 2' afu-rhs-protect:21: bad math expression: operator expected at2 fg=red,b...'
afu-rhs-protect:15: bad math expression: operand expected at > 2 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 2'
afu-rhs-protect:21: bad math expression: operator expected at 3 standout...' afu-rhs-protect:15: bad math expression: operand expected at> 2 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 2' afu-rhs-protect:21: bad math expression: operator expected atnone > 2 +...'
afu-rhs-protect:15: bad math expression: operand expected at > 3 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 3'
afu-rhs-protect:21: bad math expression: operator expected at 2 fg=red,b...' afu-rhs-protect:15: bad math expression: operand expected at> 3 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 3' afu-rhs-protect:21: bad math expression: operator expected at3 standout...'
afu-rhs-protect:15: bad math expression: operand expected at > 3 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 3'
afu-rhs-protect:21: bad math expression: operator expected at none > 3 +...' whiafu-rhs-protect:15: bad math expression: operand expected at> 3 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 3' afu-rhs-protect:21: bad math expression: operator expected at3 fg=red,b...'
afu-rhs-protect:15: bad math expression: operand expected at > 3 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 3'
afu-rhs-protect:21: bad math expression: operator expected at 4 standout...' afu-rhs-protect:15: bad math expression: operand expected at> 3 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 3' afu-rhs-protect:21: bad math expression: operator expected atnone > 3 +...'
afu-rhs-protect:15: bad math expression: operand expected at > 4 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 4'
afu-rhs-protect:21: bad math expression: operator expected at 3 fg=red,b...' afu-rhs-protect:15: bad math expression: operand expected at> 4 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 4' afu-rhs-protect:21: bad math expression: operator expected at4 standout...'
afu-rhs-protect:15: bad math expression: operand expected at > 4 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 4'
afu-rhs-protect:21: bad math expression: operator expected at none > 4 +...' whicafu-rhs-protect:15: bad math expression: operand expected at> 4 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 4' afu-rhs-protect:21: bad math expression: operator expected at3 fg=red,b...'
afu-rhs-protect:15: bad math expression: operand expected at > 4 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 4'
afu-rhs-protect:21: bad math expression: operator expected at 4 standout...' afu-rhs-protect:15: bad math expression: operand expected at> 4 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 4' afu-rhs-protect:21: bad math expression: operator expected atnone > 4 +...'
afu-rhs-protect:15: bad math expression: operand expected at > 5 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 5'
afu-rhs-protect:21: bad math expression: operator expected at 3 fg=red,b...' afu-rhs-protect:15: bad math expression: operand expected at> 5 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 5' afu-rhs-protect:21: bad math expression: operator expected at4 standout...'
afu-rhs-protect:15: bad math expression: operand expected at > 5 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 5'
afu-rhs-protect:21: bad math expression: operator expected at none > 5 +...' whichafu-rhs-protect:15: bad math expression: operand expected at> 5 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 5' afu-rhs-protect:21: bad math expression: operator expected at5 fg=green...'
afu-rhs-protect:15: bad math expression: operand expected at > 5 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 5'
afu-rhs-protect:21: bad math expression: operator expected at 6 standout...' afu-rhs-protect:15: bad math expression: operand expected at> 5 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 5' afu-rhs-protect:21: bad math expression: operator expected atnone > 5 +...'

which

Usage:
whereis [options] file

Options:
-f define search scope
-b search only binaries
-B define binaries lookup path
-m search only manual paths
-M define man lookup path
-s search only sources path
-S define sources lookup path
-u search from unusual enties
-V output version information and exit
-h display this help and exit

--(~)------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(pts/43@master)--
wafu-rhs-protect:15: bad math expression: operand expected at > 1 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 1'
afu-rhs-protect:21: bad math expression: operator expected at 1 fg=green...' afu-rhs-protect:15: bad math expression: operand expected at> 1 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 1' afu-rhs-protect:21: bad math expression: operator expected at2 standout...'
whafu-rhs-protect:15: bad math expression: operand expected at > 2 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 2'
afu-rhs-protect:21: bad math expression: operator expected at 2 fg=red,b...' afu-rhs-protect:15: bad math expression: operand expected at> 2 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 2' afu-rhs-protect:21: bad math expression: operator expected at3 standout...'

No such keymap `main afu'

This is my auto-fu.zsh: http://codepad.org/enxoIlVq

At this point my shell becomes unresponsive and I have to kill it.

I am not sure if my below bindkey is causing the issue.
50-bindkeys.zsh:bindkey "ih" vi-cmd-mode

as it probably thinks I am tying ih when typing 'which' quickly. Not sure if that makes sense.

Please let me know if you need more details.

Thanks
Joe

errors on startup when auto-fu.zsh is sourced

Cannot rebind self-insert: user:url-quote-magic
Cannot rebind backward-delete-char: user:backward-delete-char
Cannot rebind backward-kill-word: user:backward-kill-word
Cannot rebind kill-line: user:kill-line
Cannot rebind kill-whole-line: user:kill-whole-line
Cannot rebind kill-word: user:kill-word
Cannot rebind magic-space: user:magic-space
Cannot rebind yank: user:yank
Vim: Warning: Output is not to a terminal
Vim: Warning: Input is not from a terminal
(eval):1: bad pattern: ^[[?1002h^[[?1049h^[[?1h^[=^[[1
Vim: Warning: Output is not to a terminal
Vim: Warning: Input is not from a terminal
(eval):1: bad pattern: ^[[?1002h^[[?1049h^[[?1h^[=^[[1
Vim: Warning: Output is not to a terminal
Vim: Warning: Input is not from a terminal
(eval):1: bad pattern: ^[[?1002h^[[?1049h^[[?1h^[=^[[1
Vim: Warning: Output is not to a terminal
Vim: Warning: Input is not from a terminal
(eval):1: bad pattern: ^[[?1002h^[[?1049h^[[?1h^[=^[[1
--(~)-----------------------------------------------------------------------------------(pts/7@main)--

Does auto-fu support prefix history filter?

I have been use oh-my-zag before, a best feature I like is filtering history by prefix. I just need input the incomplete commands and press up arrow, and I could switch in the history that has the same prefix that match I input.

Can auto-fu support this? Sorry from a zsh newbie

Need to Ctrl-C twice instead of once

Instead of Ctrl-C once ,you have to hit it twice when using auto-fu. Would it be possible that auto-fu traps the event in some way and repropagates it to avoid that ?

Causes undo widget not to work

When auto.fu is enable the undo widget stops working. If I type 'thing' and hit undo the 'n' disappears (should be the 'g'), if I hit it again nothing happens.

Error message: with-afu-zle-rebinding:16: command not found: afu-zle-aysce-install and with-afu-zle-rebinding:16: command not found: -zle-force-install

こんにちわ~~ @hchbaw

The following error are showing up alternately every time I start a new terminal.

$ with-afu-zle-rebinding:16: command not found: afu-zle-aysce-install
$ (Then I could execute whatever command without any error shown)

and

$ with-afu-zle-rebinding:16: command not found: -zle-force-install
$ (Then I could execute whatever command without any error shown)

A bit similar to issue #22 from @joe9 , but I think it's better to make a new issue to report it.

What's more, the following command just outputs a blank line.

$ echo $functions[afu-initialize-rebinds]
[A blank line]
$

How could I fix the error message?

Hope for your reply !!! お愿いします!

FYI

# Path to your oh-my-zsh installation.
ZSH=/usr/share/oh-my-zsh/

# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="agnoster"

DEFAULT_USER="f"

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(extract fbterm git history-substring-search systemd svn tmux)

source $ZSH/oh-my-zsh.sh

# User configuration

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

## auto-fu.zsh stuff.
# source ~/codes/auto-fu.zsh/auto-fu.zsh
{ . /home/f/.zsh/auto-fu; auto-fu-install; }
zstyle ':auto-fu:highlight' input bold
zstyle ':auto-fu:highlight' completion fg=black,bold
zstyle ':auto-fu:highlight' completion/one fg=white,bold,underline
zstyle ':auto-fu:var' postdisplay $'\n-azfu-'
zstyle ':auto-fu:var' track-keymap-skip opp
zle-line-init () {auto-fu-init;}; zle -N zle-line-init
zle -N zle-keymap-select auto-fu-zle-keymap-select

# Powerline
. /usr/share/zsh/site-contrib/powerline.zsh

# Customize to your needs...

# Enhanced History Search
bindkey "^[[A" history-search-backward
bindkey "^[[B" history-search-forward
# Emulate 256 color mode only when fbterm is active
[ -n "$FBTERM" ] && export TERM=fbterm
setopt hist_ignore_all_dups
setopt hist_ignore_space
# zsh 4.3.6 doesn't have this option
setopt hist_fcntl_lock 2>/dev/null
setopt hist_reduce_blanks
# vim:filetype=zsh:foldmethod=marker:autoindent:expandtab:shiftwidth=4

bindkey to disable auto-fu?

Hello,

I am trying to figure out how to switch between "predict-on"/"predict-off" and auto-fu.

This is my predict-on setting.

autoload predict-on
zle -N predict-off
zle -N predict-on
bindkey '^Z' predict-on

bindkey '^X^Z' predict-off

bindkey '^X' predict-off
zstyle ':predict' verbose true

I noticed that I cannot have both predict-on and auto-fu active at the same time.
What do I do to turn-off auto-fu?

Is it possible to have bindkeys as the predict-on does to turn on/off auto-fu?

I tried zle -N auto-fu-off and zle-N auto-fu-deactivate. But, both did not seem to do anything.

Any thoughts, please?

Thanks
Joe

completion for npm is super slow

Type 'npm' then space and another character. Another of these lines is printed every second

$ npm egrep: empty (sub)expression
egrep: empty (sub)expression
egrep: empty (sub)expression
egrep: empty (sub)expression
egrep: empty (sub)expression
egrep: empty (sub)expression
...

used along with zsh-syntax-highlighting.

Hello,

I noticed this line in your Readme: TODO: play nice with zsh-syntax-highlighting.

I use zsh-syntax-highlighting.

I notice (being a newbie) that it does not matter whether I source auto-fu.zsh before or after sourcing zsh-syntax-highlighting.

Just wanted to check about the recommended approach (source it before zsh-syntax-highlighting or after)?

Thanks
Joe

always complete to the first match

i would like to have what is typed already to complete to the first match, again much like google-chrome's addr bar.
note that vimperato for example doesn't behave like that; or at least it didn't when i was using it (4-5 years ago).

Uninstall instructions?

I am not zhs savvy, I installed auto-fu in the wrong way and now I have undesired results.

How do I remove auto-fu?

Doesn't auto-fu.zsh support `visual` ?

Hi, thank you for before day 😄 :

I hope to this behavior

  1. $KEYMAP enters afu-vicmd
  2. Input v or V
  3. Select somewhere
  4. Input x
    • ==> Delete selected area

But auto-fu.zsh delete only one char

For example.

# prompt
$ aaaaaaabaaaaaa
         ^______

# and input x

$ aaaaaaaaaaaaa

(^ means the cursor point)
(_ means the selected block)


Does auto-fu.zsh support visual ? 😃

what does magic-space do?

Hello,

This is my zstyle:

zstyle -L
zstyle ':completion:' accept-exact-dirs true
zstyle ':completion:
:options' auto-description %d
zstyle :auto-fu:var autoable-function/skiplines '[[:blank:]\"''']'
zstyle :auto-fu:var autoable-function/skipwords '[\]
'
zstyle ':completion::complete:' cache-path /home/j/var/zsh/zcompcache
zstyle ':completion:hist-complete:
' completer history
zstyle :auto-fu:highlight completion 'bold,fg=blue'
zstyle :auto-fu:highlight completion/one 'fg=blue'
zstyle ':completion:
:options' description yes
zstyle :auto-fu:var disable magic-space
zstyle :auto-fu:var enable all
zstyle :auto-fu:var eof-installed-p yes
zstyle ':completion::corrections' format ' %F{green}-- %d (errors: %e) --%f'
zstyle ':completion:
:descriptions' format ' %F{yellow}-- %d --%f'
zstyle ':completion::messages' format ' %F{purple} -- %d --%f'
zstyle ':completion:
:warnings' format ' %F{red}-- no matches found --%f'
zstyle ':completion:' format ' %F{yellow}-- %d --%f'
zstyle :auto-fu:highlight input
zstyle :auto-fu:var isearchmap-installed-p yes
zstyle ':completion:
:default' list-prompt '%S%M matches%s'
zstyle ':completion:' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[.-]=* r:|=' 'l:|= r:|='
zstyle ':completion:predict:
' menu yes
zstyle ':completion:::::' menu select
zstyle ':completion:
' menu 'select=1'
zstyle :auto-fu:var misc-installed-p yes
zstyle :auto-fu:var postdisplay
zstyle :auto-fu:var preexec-installed-p yes
zstyle ':completion:' show-completer true
zstyle ':completion::complete:
' use-cache on
zstyle ':completion:' use-compctl false
zstyle :predict verbose true
zstyle ':completion:
' verbose yes

What does "magic space" do? and, does "enable-all" enable that functionality?

Thanks
Joe

Not compatible with ZSH Vi-mode

I just added the following snippet to my .zshrc (taken from the Internet, I know!):

# Vi-mode
bindkey -v

bindkey '^P' up-history
bindkey '^N' down-history
bindkey '^?' backward-delete-char
bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word
bindkey '^r' history-incremental-search-backward

function zle-line-init zle-keymap-select {
    VIM_PROMPT="%{$fg_bold[yellow]%} [% NORMAL]%  %{$reset_color%}"
    RPS1="${${KEYMAP/vicmd/$VIM_PROMPT}/(main|viins)/} %{$fg[red]%}$(rvm_info)%{$reset_color%}"
    zle reset-prompt
}

zle -N zle-line-init
zle -N zle-keymap-select
export KEYTIMEOUT=1

If I put this before auto-fu then auto-fu works but not the Vi-mode, and if I put it after auto-fu then Vi-mode works but not auto-fu...

Weird.

Errors after sourcing

$ git clone https://github.com/hchbaw/auto-fu.zsh.git
$ cd auto-fu.zsh
$ chmod +x auto-fu.zsh
$ ./auto-fu.zsh
./auto-fu.zsh: line 295: autoload: command not found
./auto-fu.zsh: line 297: syntax error near unexpected token `)'
./auto-fu.zsh: line 297: `() {'
$ zsh --version
zsh --version
zsh 4.3.11 (i386-apple-darwin12.0)

Causes duplicate prompts.

In later versions of zsh auto-fu.zsh causes the prompt to be displayed twice. In older versions of zsh this didn't happen, I don't know the exact version. For example if you simple type echo test <enter> this is the output.

Ubuntu-15% echo test
Ubuntu-15% echo test
test
Ubuntu-15% 

startup errors

afu-register-zle-accept-line:3: command not found: v
afu-register-zle-accept-line:3: command not found: v
afu-register-zle-accept-line:3: command not found: v
afu-register-zle-toggle:5: command not found: v

Hello,

I see the above errors when I start zsh with the auto-fu.zsh sourced. Wondering if you have any thoughts on how to fix them.

Thanks
Joe

Please reset all text attributes at the end of zle-accept-line

I combine auto-fu with zsh-syntax-highlighting and have customized my own colors with zsh-syntax-highlighting, some of them "bold". Occasionally, it happens that after pressing "enter" the program is started with bold color-mode not being reset. Surprisingly this is somewhat unreproducible, i.e. exactly the same input can lead to bold or normal colors during the program run; usually the colors are not reset if I type very quickly. Not sure whether this is a bug of zsh, zsh-syntax-highlighting, auto-fu, or if it occurs only in the interplay with some other setting of mine. Nevertheless,

echo -en '\e[0m'

at the end of the end of the function(s) $afufun() defined in afu-register-zle-accept-line fixes the issue reliably.

Interesting behaviour

Hello,

I am wondering if you can help me with this issue.

Attached is the screenshot of what I am talking about: http://imgur.com/gdoaItb

On the right are 2 terminals and the different auto-fu behaviour in each.

On the right most terminal with the "history word" on top shows auto-fu completing to "etc/zsh" though the shortest match of "etc" in the "local directory" is still available.

On the other terminal, auto-foo correctly completes to "etc" and waits.

This is probably not related to auto-foo. To get the "history word" group in the list of commands, I add this line:

defs=(

  • 'history:history words:_history_complete_word'
    'commands:external command:_path_commands'
    )

to the file: /usr/share/zsh/5.0.2/functions/Completion/Zsh/_command_names

The shell/terminal to the extreme right was started with the above line in the file. The shell/terminal next to that (towards the center, with the correct auto-fu behaviour) was started without that above history line.

Just wanted to bring it to your attention for your insight/opinion.

Thanks
Joe

breakage with upcoming zsh-5.0.3

When using auto-fu.zsh with the current git version of zsh (which perhaps will be released soon as zsh-5.0.3), the prompt and command line are printed twice for every command.

I was not able to track whether this is due to a bug of zsh-5.0.3 or due to some changed behaviour of zsh-5.0.3.

Please tag releases

This is not a bug but just a request: I would appreciate if you would tag the releases regularly.

Reason: I am providing an ebuild of auto-fu.zsh for gentoo in an overlay (see URL below).
Although it is possible to use a "live" ebuild with git, it is more reliable and more convenient for the users if they can download the tarball for the current release. With github, this is only possible for tagged releases. The last tag is already a year old...

http://git.overlays.gentoo.org/gitweb/?p=user/mv.git;a=tree;f=app-shells/auto-fu-zsh

afu-track-keymap:15: permission denied:

When I use auto-fu.zsh on a machine over SSH, I get:

afu-track-keymap:15: permission denied:

Every time I hit enter at the zsh prompt. This is using auto-fu.zsh from git (on the pu branch) with zsh 5.0.0.

add history to results

i've just started using auto-fu but i don't see history being pull into results. is it possible to add history to resutls? i would want it to be the first hit actually. why? because most commands are repeteation (with some minor changes applied in small portion of them) of older commands... definitly needs to be the first hit in results...

Clean exit with Ctrl-d and different behavior for Ctrl-d

When exiting zsh with Ctrl-d (if auto-fu is used) the exit status is nonzero which is irritating for remote or chroot shells. The reson is that the function

afu-eof-maybe () {
local eof="$1"; shift
[[ "$BUFFER" != '' ]] || { $eof; return }
"$@"
}

is called with $1=exit, and the status during $eof is nonzero, because the previous test has nonzero status. A simple inversion of the logic would fix this, i.e. the second line of the above function would just have to be replaced by

[[ -z $BUFFER ]] && { $eof; return }

As a somewhat related issue, I would think that a slightly different behavior of Ctrl-d for nonempty lines would be more intuitive: I would like that Ctrl-d clears not only a character but the whole rest of the line, and if there is no such rest then the whole line is cleared (so that pressing Ctrl-d at most three times indeed exits the shell). In other words, I would like to see instead of "$@" in the above function some code (or function) like:

if (($#BUFFER > CURSOR))
then zle kill-line
else zle kill-whole-line
fi

It would be really great if such a behavior could be enabled at least optionally.

Disable menu completion

Thank you for this excellent script. I have thb running on my ZSH alongside zsh-syntax-highlight

I have menu completion configured to be extra-verbose. It's on the slow side and I would rather it not be triggered on self-insert. Is there a way to disable the menu completion aspect such that the highlighting in the line is the only thing I see?

Thanks,
PythonNut

random error

Hello,

I receive this random error once in a while.

afu-rhs-protect:15: bad math expression: operand expected at > 0 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 0'
afu-rhs-protect:21: bad math expression: operator expected at 1 standout...' afu-rhs-protect:15: bad math expression: operand expected at> 1 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 1' afu-rhs-protect:21: bad math expression: operator expected at1 standout...'
--(/etc/trapd00r_configs)---------------------------------------------------------------------------------------------------(pts/20@master)--
c
afu-rhs-protect:15: bad math expression: operand expected at > 1 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 1'
afu-rhs-protect:21: bad math expression: operator expected at 1 underlin...' afu-rhs-protect:15: bad math expression: operand expected at> 1 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 1' afu-rhs-protect:21: bad math expression: operator expected at2 standout...'
afu-rhs-protect:15: bad math expression: operand expected at > 1 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 1'
afu-rhs-protect:21: bad math expression: operator expected at none > 1 +...' afu-rhs-protect:15: bad math expression: operand expected at> 2 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 2' afu-rhs-protect:21: bad math expression: operator expected at1 underlin...'
afu-rhs-protect:15: bad math expression: operand expected at > 2 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 2'
afu-rhs-protect:21: bad math expression: operator expected at 2 standout...' afu-rhs-protect:15: bad math expression: operand expected at> 2 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 2' afu-rhs-protect:21: bad math expression: operator expected atnone > 2 +...'
--(
/etc/trapd00r_configs)---------------------------------------------------------------------------------------------------(pts/20@master)--
cd
afu-rhs-protect:15: bad math expression: operand expected at > 2 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 2'
afu-rhs-protect:21: bad math expression: operator expected at 2 fg=green...' afu-rhs-protect:15: bad math expression: operand expected at> 2 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 2' afu-rhs-protect:21: bad math expression: operator expected at3 standout...'
afu-rhs-protect:15: bad math expression: operand expected at > 2 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 2'
afu-rhs-protect:21: bad math expression: operator expected at none > 2 +...' --(~/etc/trapd00r_configs)---------------------------------------------------------------------------------------------------(pts/20@master)-- cd afu-rhs-protect:15: bad math expression: operand expected at> 3 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 3' afu-rhs-protect:21: bad math expression: operator expected at2 fg=green...'
afu-rhs-protect:15: bad math expression: operand expected at > 3 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 3'
afu-rhs-protect:21: bad math expression: operator expected at 4 standout...' afu-rhs-protect:15: bad math expression: operand expected at> 4 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 4' afu-rhs-protect:21: bad math expression: operator expected at2 fg=green...'
afu-rhs-protect:15: bad math expression: operand expected at > 4 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 4'
afu-rhs-protect:21: bad math expression: operator expected at `4 standout...'

Any thoughts, please?

Thanks
Joe

[Feature Request] Does not send unaccepted completion after enter pressed

Thanks for hchbaw san's splendid plugin. It works well enough for me.

However, sometimes I don't want to accept the completion and just press enter, but auto-fu does send unaccepted completion to execution. Since the completion is still in gray color, intuitively it should not be sent, at least for an end-user like me.

For example, I want to replace a file with a new one while keeping the old one under another name. Like:

mv new-file .
mv old-file old-file-back
mv new-file old-file*-back # * stands for cursor position, I have typed what I want
# and auto-fu adds what I don't want
# send this line clobbers old-file-back :(

Also, if I want to cd to a directory, auto-fu will automatically add undesirable subdirectory to the path I type(less harmful than the above case indeed).

Auto suggestion of other shells, notable fish's, does behave like what I want(not sending unaccepted completion). Probably because it is more intuitive.

I'm a terminal zsh-user, but I guess this can be implemented in zle-line-finish, can't it?

I found it can be done in afu+accept-line function by assigning LBUFFER to BUFFER, but I cannot ensure it is free of hassle.

Weird error when using functions

I have a function called mcd:

mcd() { mkdir -p "$1" && cd "$1"; }

When I type mcd, completion works. But then, when I type <Space> followed
by any letter, I get a bunch or errors. In this example, I typed mcd h:

Last login: Sat Oct  5 14:21:40 on ttys000
~ ○ mcd _mtools_drives:3: command not found: mtoolstest
_mtools_drives:3: command not found: mtoolstest
_mtools_drives:3: command not found: mtoolstest
        h

I don't know if that is a configuration problem from me or a bug from auto-fu..

Install help, please?

This is how I sourced auto-fu.zsh into my zshrc:

http://codepad.org/gJdSz0cs

$ cat 06-auto-fu.zsh

!/usr/bin/zsh

First, we set sane options for the standard completion system:

autoload -Uz compinit is-at-least
compinit -D -u
zstyle ':completion:' completer complete
zstyle ':completion:
' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:
' menu select=1 # interactive
zstyle ':completion:' accept-exact-dirs true
zstyle ':completion:
' path-completion false
if is-at-least 4.3.10
then zstyle ':completion:_' format "%B%F{yellow}%K{blue}%d%k%f%b"
else zstyle ':completion:*' format "%B%d%b"
fi

Now we source ${PN}

source /usr/share/zsh/site-contrib/auto-fu.zsh/auto-fu.zsh

Finally, we configure ${PN}

zstyle ':auto-fu:highlight' input
zstyle ':auto-fu:highlight' completion bold,fg=blue
zstyle ':auto-fu:highlight' completion/one fg=blue
zstyle ':auto-fu:var' postdisplay # $'\n-azfu-'

zstyle ':auto-fu:var' enable all

zstyle ':auto-fu:var' track-keymap-skip opp

zstyle ':auto-fu:var' disable magic-space

zle-line-init() auto-fu-init
zle -N zle-line-init
zle -N zle-keymap-select auto-fu-zle-keymap-select

Starting a line with a space or tab or quoting the first word

or escaping a word should deactivate auto-fu for that line/word.

This is useful e.g. if auto-fu is too slow for you in some cases.

zstyle ':auto-fu:var' autoable-function/skiplines '[[:blank:]\"''']'
zstyle ':auto-fu:var' autoable-function/skipwords '[\]
'

Let Ctrl-d successively remove tail of line, whole line, and exit

kill-line-maybe() {
if (($#BUFFER > CURSOR))
then zle kill-line
else zle kill-whole-line
fi
}
zle -N kill-line-maybe
bindkey '\C-d' kill-line-maybe

Keep Ctrl-d behavior also when auto-fu is active

afu+orf-ignoreeof-deletechar-list() {
afu-eof-maybe afu-ignore-eof zle kill-line-maybe
}
afu+orf-exit-deletechar-list() {
afu-eof-maybe exit zle kill-line-maybe
}

vim: set et sw=2:

When I do source the above file, I get:

source 06-auto-fu.zsh
source 06-auto-fu.zsh
with-afu~: job table full or recursion limit exceeded
with-afu~: job table full or recursion limit exceeded
with-afu~: job table full or recursion limit exceeded
with-afu~: job table full or recursion limit exceeded
with-afu~: job table full or recursion limit exceeded
with-afu~: job table full or recursion limit exceeded
with-afu~: job table full or recursion limit exceeded
with-afu~: job table full or recursion limit exceeded
with-afu~: job table full or recursion limit exceeded
with-afu~: job table full or recursion limit exceeded

Any thoughts on what I am missing, please?

Thanks
Joe

do NOT change what user has typed

why auto-fu changes what i type. yes in the background what i have typed is still there and so i have to blind type until auto-fu lets go of the prompt. this is not a sane behaviour. here again google-chrome's address-bar should be the model.

候補が表示されない。

初めまして、myuheといいます。
auto-fu.zsh素晴らしいですね。愛用させてもらってます。
ところで当方の環境では、0.0.1.3以降のバージョンで正常に動作しませんでした。
現象としては、postdisplayは表示されるのですが、候補が表示されません。
なお、.zshrcにauto-fu.zshの設定だけしたものでも試してみましたが、改善ありませんでした。
また、コンパイルの有無も関係ないようでした。
0.0.1.2より古いものは問題なく動作しているようです。

当方の環境は
zsh 4.3.10 (i686-pc-linux-gnu)
ubuntu 10.04
です。

以下のように設定しています。
source ~/.zsh/auto-fu.zsh
zstyle ':auto-fu:highlight' input bold
zstyle ':auto-fu:highlight' completion fg=red,bold
zstyle ':auto-fu:highlight' completion/one fg=white,bold,underline
zstyle ':auto-fu:var' postdisplay $'\n-azfu-'
zstyle ':auto-fu:var' disable magic-space

zle-line-init () {auto-fu-init;}; zle -N zle-line-init

License

Hi, can you add a license to this package? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.