Skip to content

Commit

Permalink
fix: bash autocomplete
Browse files Browse the repository at this point in the history
The bash autocomplete had a bug, most likely as a result of a lazy `:% s/PROG/totp-cli/g`.

I added extra docs about autocomplete.

Fixes #93

References:
* #93

Signed-off-by: Efertone <[email protected]>
  • Loading branch information
yitsushi committed Oct 4, 2023
1 parent f0c508a commit a0ff0b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,16 @@ totp-cli import list.yaml

### Shell Completion

Disclaimer: I don't have much expertise with auto-complete integrations. The
following instructions should be enough, but it is possible they are not. Feel
free to open a Pull Request with any additional suggestions/fixes either in the
docs or the autocomplete scripts.

* Bash: `autocomplete/bash_autocomplete`
* Zsh: `autocomplete/zsh_autocomplete`

#### Zsh

A function to provide tab-completion for zsh is in the file
`autocomplete/zsh_autocomplete`. When installing or packaging totp-cli this
should preferably be installed in `$prefix/share/zsh/site-functions`. Otherwise,
Expand All @@ -270,11 +277,19 @@ functions into the folder `~/.zsh/completions` you must add the following to
your zsh main config file (`.zshrc`):

```shell
cp autocomplete/zsh_autocomplete ~/.zsh/functions/_totp_cli
fpath=( ~/.zsh/completions $fpath )
autoload -U compinit
compinit
```

#### Bash

```
mkdir -p ~/.local/share/bash-completion/completions
cp autocomplete/bash_autocomplete ~/.local/share/bash-completion/completions/totp-cli
```

## About the password

The password should never be passed directly to any applications to unlock it.
Expand Down
3 changes: 0 additions & 3 deletions autocomplete/bash_autocomplete
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#! /bin/bash

: totp-cli

# Macs have bash3 for which the bash-completion package doesn't include
# _init_completion. This is a minimal version of that function.
_cli_init_completion() {
Expand Down Expand Up @@ -32,4 +30,3 @@ _cli_bash_autocomplete() {
}

complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete totp-cli
unset totp-cli

0 comments on commit a0ff0b3

Please sign in to comment.