Skip to content

Commit 9f9a238

Browse files
authored
(DOCSP-17778): Add new steps to enable autocomplete for different shell methods (#598)
* (DOCSP-17778): Add new autocomplete procedures for shell methods * Copy review
1 parent c66ff95 commit 9f9a238

File tree

3 files changed

+79
-19
lines changed

3 files changed

+79
-19
lines changed

source/configure.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,5 @@ Next Steps
8080
modify profiles.
8181
- :ref:`Set environment variables <mcli-env-var>` to enable easier
8282
scripting.
83+
- :ref:`Enable autocomplete <mcli-autocomplete>` to see available
84+
commands and their syntax directly in your shell.

source/configure/autocomplete.txt

Lines changed: 74 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,39 +40,95 @@ Enable Autocomplete
4040
Z Shell
4141
~~~~~~~
4242

43-
If you use ``zsh`` to run the {+mcli+}, add the following to your
44-
``~/.zshrc``:
45-
43+
If you use ``zsh`` to run the {+mcli+}, run the following command
44+
to enable autocomplete in your current shell:
45+
4646
.. code-block:: sh
47+
48+
% echo "autoload -U compinit; compinit" >> ~/.zshrc
4749

48-
autoload -Uz compinit
49-
compinit
50-
51-
source <(mongocli completion zsh)
52-
compdef _mongocli mongocli
53-
54-
Run the following command to reload your ``zsh`` profile:
50+
To enable autocomplete for all future shell sessions:
51+
52+
1.
53+
54+
- If you use MacOS, run the following command:
55+
56+
.. code-block:: sh
57+
58+
% mongocli completion zsh > /usr/local/share/zsh/site-functions/_mongocli
59+
60+
- If you use Linux, run the following command:
61+
62+
.. code-block:: sh
63+
64+
% mongocli completion zsh > "${fpath[1]}/_mongocli"
65+
66+
#. Start a new shell for the setup to take effect.
67+
68+
Bash
69+
~~~~
5570

71+
If you use Bash to run the {+mcli+}, install the ``bash-completion``
72+
package via your OS's package manager. Then,
73+
run the following command to enable autocomplete in your current shell:
74+
5675
.. code-block:: sh
76+
77+
$ source <(mongocli completion bash)
5778

58-
source ~/.zshrc
79+
To enable autocomplete for all future shell sessions:
5980

60-
Bash
81+
1.
82+
83+
- If you use MacOS, run the following command:
84+
85+
.. code-block:: sh
86+
87+
$ mongocli completion bash > /usr/local/etc/bash_completion.d/mongocli
88+
89+
- If you use Linux, run the following command:
90+
91+
.. code-block:: sh
92+
93+
$ mongocli completion bash > /etc/bash_completion.d/mongocli
94+
95+
#. Start a new shell for the setup to take effect.
96+
97+
Fish
6198
~~~~
62-
63-
If you use Bash to run the {+mcli+}, add the following to your
64-
``~/.bash_profile``:
99+
100+
If you use ``fish`` to run the {+mcli+}, run the following command
101+
to enable autocomplete in your current shell:
65102

66103
.. code-block:: sh
104+
105+
> mongocli completion fish | source
106+
107+
To enable autocomplete for all future shell sessions:
108+
109+
1. Run the following command:
110+
111+
.. code-block:: sh
112+
113+
> mongocli completion fish > ~/.config/fish/completions/mongocli.fish
67114

68-
eval "$(mongocli completion bash)"
115+
#. Start a new shell for the setup to take effect.
116+
117+
PowerShell
118+
~~~~~~~~~~
69119

70-
Run the following command to reload your Bash profile:
120+
If you use PowerShell to run the {+mcli+}, run the following command
121+
to enable autocomplete in your current shell:
71122

72123
.. code-block:: sh
73124

74-
source ~/.bash_profile
125+
PS C:\> mongocli completion powershell | Out-String | Invoke-Expression
75126

127+
To enable autocomplete for all future shells, add the output
128+
of the above command to your PowerShell profile. To learn how
129+
to edit a PowerShell profile, see `Windows Documentation
130+
<https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/ise/how-to-use-profiles-in-windows-powershell-ise?view=powershell-7.1>`__.
131+
76132
Use ``Tab`` to Autocomplete Commands
77133
------------------------------------
78134

source/install.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,6 @@ Procedure
105105
Next Steps
106106
----------
107107

108-
:ref:`Configure the {+mcli+} <mcli-configure>` for your environment.
108+
- :ref:`Configure the {+mcli+} <mcli-configure>` for your environment.
109+
- :ref:`Enable autocomplete <mcli-autocomplete>` to see available
110+
commands and their syntax directly in your shell.

0 commit comments

Comments
 (0)