Skip to content
Go to file
Cannot retrieve contributors at this time
111 lines (88 sloc) 4.15 KB

Elvish completions for various built-in commands

Completions for some of Elvish’s built-in commands, including use, the epm module and elvish itself.

This file is written in literate programming style, to make it easy to explain. See $name.elv for the generated file.

Table of Contents


Install the elvish-modules package using epm:

use epm

In your rc.elv, load this module:


Included completions:

  • elvish (completes command-line options and .elv files).
  • use (completes all modules in ~/.elvish/lib). Example (the “lack module name” message is normal and part of Elvish’s as-you-type compilation, it goes away when you add a module name):
    [~]─> use <Tab>
     COMPLETING argument _
    compilation error: 3-3 in [tty]: lack module name
     elvish-dev/epm/epm                                        private
  • epm commands: completes installed packages for the appropriate commands.


Load the completion framework and other libraries.

use ./comp
use re


Completer for the use command, which includes all modules in ~/.elvish/lib/.

edit:completion:arg-completer[use] = (comp:sequence [{
    put ~/.elvish/lib/**[nomatch-ok].elv | each [m]{
      if (not (-is-dir $m)) {
        re:replace ~/.elvish/lib/'(.*).elv' '$1' $m


Completers for the epm commands.

use epm

epm-completer-one  = (comp:sequence [ $epm:list~ ])
epm-completer-many = (comp:sequence [ $epm:list~ ...])
edit:completion:arg-completer[epm:query]     = $epm-completer-one
edit:completion:arg-completer[epm:metadata]  = $epm-completer-one
edit:completion:arg-completer[epm:dest]      = $epm-completer-one
edit:completion:arg-completer[epm:uninstall] = $epm-completer-many
edit:completion:arg-completer[epm:upgrade]   = $epm-completer-many


Completer for the elvish command.

edit:completion:arg-completer[elvish] = (comp:sequence ^
  &opts= { elvish -help | comp:extract-opts &fold } ^
  [ [arg]{ comp:files $arg &regex='\.elv$' } ] ^
You can’t perform that action at this time.