~reesmichael1/elvish-completions

0493f5883b008940c74c4670d8c81254ff9205ff — Michael Rees 11 months ago
Add completion module for filenames with pass
2 files changed, 30 insertions(+), 0 deletions(-)

A README.md
A pass.elv
A  => README.md +13 -0
@@ 1,13 @@
# elvish-completions

A collection of completion modules for [the Elvish shell](https://elv.sh).

## pass.elv

This module provides completions for [`pass`](https://passwordstore.org).

Currently, it only provides completions for the filenames stored within the password directory (i.e., it does not know about `pass` specific commands like `insert`, `edit`, etc.). It depends on `tree`, although I'll probably eventually rewrite it in pure Elvish.

```
use sr.ht/reesmichael1/elvish-completions/pass
```

A  => pass.elv +17 -0
@@ 1,17 @@
use github.com/zzamboni/elvish-completions/comp

edit:completion:arg-completer[pass] = (comp:sequence [[arg]{
    prefix = ""
    try {
        prefix = (get-env PASSWORD_STORE_DIR)
    } except e {
        prefix = $E:HOME"/.password-store/"
    }
    tree -if $prefix | each [c]{
        try {
            if (==s $c[-4:] ".gpg") {
               put $c[(count $prefix):][:-4]
            }
        } except e { []{} }
    }
}])