Skip to content

Commit

Permalink
docs: adapt completion instructions (prefix-dev#2561)
Browse files Browse the repository at this point in the history
We currently give people a one-liner to setup completions.

That is convenient, but also fragile.
If people's startup script doesn't end in a newline, it
[breaks](panel-extensions/copier-template-panel-extension#4 (comment)).
If people run it multiple times it will be duplicated.

Let's follow https://starship.rs and give users instructions to add it
themselves
  • Loading branch information
Hofer-Julian authored and jjjermiah committed Nov 30, 2024
1 parent e8bf6cf commit 25a255e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 27 deletions.
39 changes: 27 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,32 +109,43 @@ Afterwards, restart the shell or source the shell config file.

#### Bash (default on most Linux systems)

Add the following to the end of `~/.bashrc`:

```bash
echo 'eval "$(pixi completion --shell bash)"' >> ~/.bashrc
# ~/.bashrc

eval "$(pixi completion --shell bash)"
```
#### Zsh (default on macOS)

Add the following to the end of `~/.zshrc`:


```zsh
echo 'eval "$(pixi completion --shell zsh)"' >> ~/.zshrc
# ~/.zshrc

eval "$(pixi completion --shell zsh)"
```

#### PowerShell (pre-installed on all Windows systems)

```pwsh
Add-Content -Path $PROFILE -Value '(& pixi completion --shell powershell) | Out-String | Invoke-Expression'
```
Add the following to the end of `Microsoft.PowerShell_profile.ps1`.
You can check the location of this file by querying the `$PROFILE` variable in PowerShell.
Typically the path is `~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1` or
`~/.config/powershell/Microsoft.PowerShell_profile.ps1` on -Nix.

If this fails with "Failure because no profile file exists", make sure your profile file exists.
If not, create it with:

```PowerShell
New-Item -Path $PROFILE -ItemType File -Force
```pwsh
(& pixi completion --shell powershell) | Out-String | Invoke-Expression
```

#### Fish

Add the following to the end of `~/.config/fish/config.fish`:

```fish
echo 'pixi completion --shell fish | source' >> ~/.config/fish/config.fish
# ~/.config/fish/config.fish
pixi completion --shell fish | source
```

#### Nushell
Expand All @@ -154,8 +165,12 @@ use ~/.cache/pixi/completions.nu *

#### Elvish

Add the following to the end of `~/.elvish/rc.elv`:

```elv
echo 'eval (pixi completion --shell elvish | slurp)' >> ~/.elvish/rc.elv
# ~/.elvish/rc.elv
eval (pixi completion --shell elvish | slurp)
```

### Distro Packages
Expand Down
42 changes: 27 additions & 15 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,40 @@ Afterwards, restart the shell or source the shell config file.

### Bash (default on most Linux systems)

```bash
echo 'eval "$(pixi completion --shell bash)"' >> ~/.bashrc
Add the following to the end of `~/.bashrc`:

```bash title="~/.bashrc"

eval "$(pixi completion --shell bash)"
```
### Zsh (default on macOS)

```zsh
echo 'eval "$(pixi completion --shell zsh)"' >> ~/.zshrc
Add the following to the end of `~/.zshrc`:


```zsh title="~/.zshrc"

eval "$(pixi completion --shell zsh)"
```

### PowerShell (pre-installed on all Windows systems)

Add the following to the end of `Microsoft.PowerShell_profile.ps1`.
You can check the location of this file by querying the `$PROFILE` variable in PowerShell.
Typically the path is `~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1` or
`~/.config/powershell/Microsoft.PowerShell_profile.ps1` on -Nix.

```pwsh
Add-Content -Path $PROFILE -Value '(& pixi completion --shell powershell) | Out-String | Invoke-Expression'
(& pixi completion --shell powershell) | Out-String | Invoke-Expression
```

!!! tip "Failure because no profile file exists"
Make sure your profile file exists, otherwise create it with:
```PowerShell
New-Item -Path $PROFILE -ItemType File -Force
```
### Fish

Add the following to the end of `~/.config/fish/config.fish`:

### Fish
```fish title="~/.config/fish/config.fish"
```fish
echo 'pixi completion --shell fish | source' > ~/.config/fish/completions/pixi.fish
pixi completion --shell fish | source
```

### Nushell
Expand All @@ -98,10 +106,14 @@ use ~/.cache/pixi/completions.nu *

### Elvish

```elv
echo 'eval (pixi completion --shell elvish | slurp)' >> ~/.elvish/rc.elv
Add the following to the end of `~/.elvish/rc.elv`:

```elv title="~/.elvish/rc.elv"
eval (pixi completion --shell elvish | slurp)
```


## Alternative installation methods

Although we recommend installing pixi through the above method we also provide additional installation methods.
Expand Down

0 comments on commit 25a255e

Please sign in to comment.