Diff
1diff --git a/plugins/fnm/README.md b/plugins/fnm/README.md
2index 00fab5cd4b07461ccce20fb5c02cc58c4c90cea8..3d3914d07296e3192dd58c3f0c7154f23aafefd8 100644
3--- a/plugins/fnm/README.md
4+++ b/plugins/fnm/README.md
5@@ -2,8 +2,34 @@
6
7 This plugin adds autocompletion for [fnm](https://github.com/Schniz/fnm) - a Node.js version manager.
8
9-To use it, add `fnm` to the plugins array in your zshrc file:
10+To use it, add `fnm` to the plugins array in your `.zshrc` file:
11
12 ```zsh
13 plugins=(... fnm)
14 ```
15+
16+## Configuration
17+
18+These settings should go in your `.zshrc` file, before Oh My Zsh is sourced.
19+
20+### Autostart
21+
22+If set, the plugin will automatically start fnm for the session, running the `fnm env`:
23+
24+```zsh
25+zstyle ':omz:plugins:fnm' autostart yes
26+```
27+
28+Default: `no` (disabled)
29+
30+### Use on cd
31+
32+If set, the Node.js version will be switched based on the requirements of the current directory (recommended):
33+
34+```zsh
35+zstyle ':omz:plugins:fnm' use-on-cd yes
36+```
37+
38+Default: `yes` (enabled)
39+
40+Check out the [official documentation](https://github.com/Schniz/fnm/blob/master/docs/commands.md) for the available fnm variables.
41diff --git a/plugins/fnm/fnm.plugin.zsh b/plugins/fnm/fnm.plugin.zsh
42index 6219025cdcc60b976abd68ad4251009d0f588eb4..90a5ae81172e8c29ca1a5b40c8c6ff1581bbf1e3 100644
43--- a/plugins/fnm/fnm.plugin.zsh
44+++ b/plugins/fnm/fnm.plugin.zsh
45@@ -11,3 +11,11 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnm" ]]; then
46 fi
47
48 fnm completions --shell=zsh >| "$ZSH_CACHE_DIR/completions/_fnm" &|
49+
50+if zstyle -t ':omz:plugins:fnm' autostart; then
51+ local -a fnm_env_cmd
52+ if zstyle -T ':omz:plugins:fnm' use-on-cd; then
53+ fnm_env_cmd+=("--use-on-cd")
54+ fi
55+ eval "$(fnm env --shell=zsh $fnm_env_cmd)"
56+fi