chezmoi: The best way to add .oh-my-zsh plugins that don't have a repo
What exactly are you trying to do?
Several command line tools provide ways to add command completions to ZSH but don’t provide a static file that can be integrated into .chezmoiexternal.toml using either external repo configuration. For example, in order to add bitwarden command completions to zsh through .oh-my-zsh, you have to run the following command to generate the completion file1:
mkdir $ZSH_CUSTOM/plugins/bw
bw completion --shell zsh | sudo tee $ZSH_CUSTOM/plugins/bw/_bw
Because I don’t see a place where this file exists statically (it looks like it’s being rendered), I need a way to include it through a different means.
What have you tried so far?
My first thought was to just include it like a normal file in chezmoi. So I ran:
chezmoi add $ZSH_CUSTOM/plugins/bw --recursive
after having already run the bw completion command to generate the file. The problem here is that the file gets added to chezmoi’s repo at the base level, i.e. $(chezmoi source-path)/plugins/bw/_bw, which is not the correct position to be installed in for .oh-my-zsh to pick it up. Perhaps this is because .oh-my-zsh is in the .chezmoiexternal.toml? The effect is that chezmoi apply or using chezmoi on another machine causes _bw to be pull into $HOME/plugins/bw/_bw and for the plugin to not be loaded.
Where else have you checked for solutions?
- I have read chezmoi’s how-to guide, and not found the answer.
- I have read chezmoi’s FAQ, and not found the answer.
- I have searched chezmoi’s reference guide, and not found the answer.
Output of any commands you’ve tried with --verbose flag
❯ chezmoi add --verbose $ZSH_CUSTOM/plugins/bw --recursive
diff --git a/exact_plugins/bw b/exact_plugins/bw
new file mode 40755
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
--- /dev/null
+++ b/exact_plugins/bw
diff --git a/exact_plugins/bw/_bw b/exact_plugins/bw/_bw
new file mode 100644
index 0000000000000000000000000000000000000000..69beaf6e3ba428bb6ca66c005f6af743c804d972
--- /dev/null
+++ b/exact_plugins/bw/_bw
@@ -0,0 +1,414 @@
+#compdef _bw bw
+
+function _bw {
... ( a bunch of other output of the contents of the file that I feel is impertinent to this issue)
and the subsequent chezmoi diff
❯ chezmoi diff --verbose
diff --git a/.oh-my-zsh/custom/plugins/bw b/.oh-my-zsh/custom/plugins/bw
deleted file mode 40755
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
--- a/.oh-my-zsh/custom/plugins/bw
+++ /dev/null
diff --git a/.oh-my-zsh/custom/plugins/gh b/.oh-my-zsh/custom/plugins/gh
deleted file mode 40755
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
--- a/.oh-my-zsh/custom/plugins/gh
+++ /dev/null
diff --git a/.oh-my-zsh/custom/plugins/poetry b/.oh-my-zsh/custom/plugins/poetry
deleted file mode 40755
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
--- a/.oh-my-zsh/custom/plugins/poetry
+++ /dev/null
diff --git a/plugins b/plugins
new file mode 40755
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
--- /dev/null
+++ b/plugins
diff --git a/plugins/bw b/plugins/bw
new file mode 40755
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
--- /dev/null
+++ b/plugins/bw
diff --git a/plugins/bw/_bw b/plugins/bw/_bw
new file mode 100644
index 0000000000000000000000000000000000000000..69beaf6e3ba428bb6ca66c005f6af743c804d972
--- /dev/null
+++ b/plugins/bw/_bw
@@ -0,0 +1,414 @@
+#compdef _bw bw
+
... cut for brevity ...
+function _bw_receive {
+ _arguments -C \
+ '--password[Password needed to access the Send.]' \
+ '--passwordenv[Environment variable storing the Send'"'"'s password]' \
+ '--passwordfile[Path to a file containing the Sends password as its first line]' \
+ '--obj[Return the Send'"'"'s json object rather than the Send's content]' \
+ '--output[Specify a file path to save a File-type Send to]' \
+ '(-h --help)'{-h,--help}'[output usage information]' \
+ "*::arg:->args"
+}
\ No newline at end of file
diff --git a/plugins/gh b/plugins/gh
new file mode 40755
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
--- /dev/null
+++ b/plugins/gh
diff --git a/plugins/gh/_gh b/plugins/gh/_gh
new file mode 100644
index 0000000000000000000000000000000000000000..dfce760b6c84c509d4fe1c67e888dd2f38dcacc3
--- /dev/null
+++ b/plugins/gh/_gh
@@ -0,0 +1,177 @@
+#compdef _gh gh
+
.. cut for brevity ...
+# don't run the completion function when being source-ed or eval-ed
+if [ "$funcstack[1]" = "_gh" ]; then
+ _gh
+fi
diff --git a/plugins/poetry b/plugins/poetry
new file mode 40755
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
--- /dev/null
+++ b/plugins/poetry
diff --git a/plugins/poetry/_poetry b/plugins/poetry/_poetry
new file mode 100644
index 0000000000000000000000000000000000000000..b297e88d38907f7b28d09bbdfa8d8c806a48c13b
--- /dev/null
+++ b/plugins/poetry/_poetry
@@ -0,0 +1,135 @@
+#compdef poetry
+
... cut for brevity...
+_poetry_0083e2c55c594e6f_complete "$@"
+compdef _poetry_0083e2c55c594e6f_complete /home/lund/.local/share/pypoetry/venv/bin/poetry
Output of chezmoi doctor
❯ chezmoi doctor --verbose
RESULT CHECK MESSAGE
ok version v2.7.5, commit 53bb61524468afe3262d6d8089fdc6912dbccb34, built at 2021-11-07T21:20:58Z, built by goreleaser
ok os-arch linux/amd64 (Ubuntu 20.04.3 LTS (Focal Fossa))
ok executable /snap/chezmoi/307/chezmoi
ok config-file no config file found
ok source-dir ~/.local/share/chezmoi is a directory
ok suspicious-entries no suspicious entries
ok working-tree ~/.local/share/chezmoi is a directory
ok dest-dir ~ is a directory
ok shell found /bin/bash
ok edit-command found /usr/bin/vim
ok umask 022
ok git-command found /usr/bin/git, version 2.25.1
ok merge-command found /usr/bin/vimdiff
ok age-command age not found in $PATH
ok gpg-command found /usr/bin/gpg, version 2.2.19
info pinentry-command not set
info 1password-command op not found in $PATH
failed bitwarden-command found /snap/bin/bw, could not parse version from Warning: Ignoring extra certs from `/usr/local/share/ca-certificates/dyneticsroot.crt`, load failed: error:02001002:system library:fopen:No such file or directory
1.19.1
info gopass-command gopass not found in $PATH
info keepassxc-command keepassxc-cli not found in $PATH
info keepassxc-db not set
info lastpass-command lpass not found in $PATH
info pass-command pass not found in $PATH
info vault-command vault not found in $PATH
info secret-command not set
Additional context
I’m pretty sure you can ignore the bitwarden error shown in chezmoi doctor as I have the snap installed which has some permission issues accessing a certificate. Seeing as I’m not currently using bitwarden for this setup, I don’t think it affects this issue.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (12 by maintainers)
@twpayne I think this deserves a new guide in the docs, but it can’t be done unless https://github.com/twpayne/chezmoi/issues/1574 is finished because otherwise it would include a workaround (
exact: false.So I suggest we keep this issue open until the aforementioned guide is merged.
@felipecrs Wow, you are amazing. It worked wonderfully! chezmoi is impressive! I didn’t need to do the extra compinit or autoload so I’m not sure what happened there.