Code Monkey home page Code Monkey logo

Comments (2)

hchbaw avatar hchbaw commented on June 1, 2024

Hi, Joe!

Oh it's fascinating to add the "history word" group to _command_names.
Thank you very much opening it up here. I will try it out!

from auto-fu.zsh.

joe9 avatar joe9 commented on June 1, 2024

Hello Takehi,

The above is the wrong way to go about adding history words to _command_names. As an fyi, below is an email from Bart on the subject:

Unless I'm misunderstanding your intent, you don't actually want to
change the tags from _command_names -- you just want to add another tag
that appears in completion output along with the _command_names tags?

To do this you want to replace the completer function for "-command-"
context. By default this is the _autocd completer (which is only the
default because _autocd is the only file in the completion library that
begins with "#compdef -command-").

So first make yourself a little function patterned on _autocd:

_history_or_autocd () {
  _history
  local ret=$?
  _autocd || return ret
}

And then install it for the context:

compdef _history_or_autocd -command-

To explain a bit further, the completers in the completer style are in
general attempted until one returns a zero (true, success) status, at
which point the set of possible matches is assumed to be finished. To
merge the results of several completers you have to save the staus, try
the next one, and then return success if any of those completers was
successful.

If you instead wanted to complete history and only try the defaults if no
history words matched, you could have shortcut this as

compdef '_history || _autocd' -command-

Of course whichever of these you choose has to happen after compinit is
run, otherwise _autocd will step on it when loaded.

Joe

from auto-fu.zsh.

Related Issues (20)

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.