Coder Social home page Coder Social logo

custompeitl-zsh-plugin's Introduction

Custom autocomplete for zsh functions

requires oh-my-zsh to be installed and plugin to be registered.

holds autocomplete scripts for custom commands in path.

  • conf: can be used to find and edit the configuration of a program _conf autocompletes the command with all directories in ~/.config
  • rep: can be used to open a repository in editor/IDE _rep autocompletes the command with all directories in ~/repos

Good resources on how to write zsh autocomplete functions are very diffult to find and even these very simple commands required a lot of research and trial & error,
particularly to figure out the exact conditions when a command is properly loaded by zsh and when not.


Installation

clone this repo to ~/.oh-my-zsh/custom/plugins by:

git clone https://github.com/markuspeitl/custompeilt-zsh-plugin ~/.oh-my-zsh/custom/plugins/custompeitl

Add the plugin to zsh startup by adding the custompeitl plugin
to the ~/.zshrc plugins array:
plugins=(custompeitl)

For debugging add

autoload -Uz compinit
compinit -u

to .zshrc as otherwise the completions files and/or functions are not registered

Apparently a _functionname file has to be created for the completion function to even register and that
file needs to be linked on top of file with

#compdef functionname
#autoload

if then in script.plugin.zsh the _functionname is specified it masks the function of the completions file,
otherwise it simply does not work as zsh only seems to get for _ files that they contain completion instructions.

Correction

Apparently it is possible to provide the completion in the same file as the function by adding the line

compdef _functionname functionname

(where _functionname is the completion function
and functionname is the command to be executed)
to the script (which was registered as a oh-my-zsh plugin or that was added/findable to/by fpath)

custompeitl-zsh-plugin's People

Contributors

markuspeitl avatar

Watchers

 avatar

custompeitl-zsh-plugin's Issues

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.