Skip to content

Commit f3d9071

Browse files
authored
Merge pull request #7 from Tienbruh/hoonbranch
Modified readme to include both temporary and permanent autocomplete
2 parents 5a65355 + 9742678 commit f3d9071

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

README.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -628,44 +628,51 @@ In addition to the options provided in the base `OpenAI` client, the following o
628628
An example of using the client with Microsoft Entra ID (formerly known as Azure Active Directory) can be found [here](https://github.com/openai/openai-python/blob/main/examples/azure_ad.py).
629629

630630
## Activating CLI Autocomplete
631+
Use the following commands to activate CLI autocompletion for each shell.
631632

632-
### Using CLI Autocomplete
633-
Using the following sequence of commands for each shell will activate the autocompletion feature for the CLI.
634-
#### Bash
635-
1. Register ‘openai’ command for argument completion by running:
633+
### Bash & Zsh
634+
Configure your shell to support global auto completion for python scripts by running:
636635
```shell
637-
register-python-argcomplete openai >> ~/.bashrc
636+
activate-global-python-argcomplete
638637
```
639-
640-
#### Zsh
641-
1. Register ‘openai’ command for argument completion by running:
638+
Use this command to register `openai` for argument completion using argcomplete for the current terminal session:
642639
```shell
640+
eval "$(register-python-argcomplete openai)"
641+
```
642+
Alternatively, run this command to register `openai` for argument completion permanently, eliminating the need to run the `eval` command each time the terminal is restarted or killed.
643+
For Bash:
644+
```shell
645+
register-python-argcomplete openai >> ~/.bashrc
646+
```
647+
For Zsh:
648+
```shell
643649
register-python-argcomplete openai >> ~/.zshrc
644650
```
645651

646-
#### Fish
647-
1. Register ‘openai’ command for argument completion by running:
652+
### Powershell
653+
To activate completions for Powershell use:
648654
```shell
649-
register-python-argcomplete --shell fish openai > ~/.config/fish/config.fish
655+
register-python-argcomplete --shell powershell openai | Out-String | Invoke-Expression
650656
```
651-
652-
#### Powershell
653-
1. Create new completion file:
657+
Alternatively, create a new completion file. This command will persist even if the terminal is killed or restarted.
654658
```shell
655659
register-python-argcomplete --shell powershell openai > ~/openai.psm1
656660
```
657-
658-
2. If you don't already have a ``$PROFILE`` you can add this by running:
661+
To activate the completions file, open the [``$PROFILE``](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.4&viewFallbackFrom=powershell-7.3#how-to-create-a-profile) by running ``notepad $PROFILE`` and add this following line:
659662
```shell
660-
New-Item -ItemType File -Path $PROFILE -Force
663+
Import-Module "~/openai.psm1"
661664
```
662-
663-
3. Open the [``$PROFILE``](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.4&viewFallbackFrom=powershell-7.3#how-to-create-a-profile) by running ``notepad $PROFILE`` and add this following line:
665+
### Fish
666+
To activate completions for fish use:
664667
```shell
665-
Import-Module "~/openai.psm1"
668+
register-python-argcomplete --shell fish openai | source
669+
```
670+
Alternatively, create a new completion file. This command will persist even if the terminal is killed or restarted.
671+
```shell
672+
register-python-argcomplete --shell fish openai > ~/.config/fish/config.fish
666673
```
667674

668-
#### Usage
675+
### Usage
669676
After completing the appropriate steps for your shell, restart the terminal and try:
670677
```shell
671678
openai <TAB>

0 commit comments

Comments
 (0)