Skip to content

Add Bash shell autocompletions - #108

Merged
pavelzw merged 1 commit into
prefix-dev:mainfrom
matthewfeickert:feat/add-completions
Sep 8, 2025
Merged

pavelzw merged 1 commit into
prefix-dev:mainfrom
matthewfeickert:feat/add-completions

Conversation

@matthewfeickert

@matthewfeickert matthewfeickert commented Aug 1, 2025 •

Copy link
Copy Markdown
Contributor
  • Add the Bash shell autocompletions to the ~/.bashrc to allow for use of tab completions while using interactively.

This results in the built container image having

# tail -n 2 ~/.bashrc 

eval "$(pixi completion --shell bash)"

If updating documentation:

@matthewfeickert

matthewfeickert commented Aug 1, 2025 •

Copy link
Copy Markdown
Contributor Author

@pavelzw @ruben-arts This is ready for review. If you'd prefer to have this have been discussed in an Issue first (there can be very good reasons for not wanting to touch or customize anything outside of what is the minimum requirements for use) I can put this into draft status and open one.

@ruben-arts

Copy link
Copy Markdown
Contributor

As it only adds the script to the image, it shouldn't take up too much space. I would be fine with it. But I would like @pavelzw to be the deciding factor here, as they use these docker images more in the field.

@matthewfeickert

Copy link
Copy Markdown
Contributor Author

👋 Ping to @pavelzw for thoughts.

@matthewfeickert

matthewfeickert commented Aug 11, 2025 •

Copy link
Copy Markdown
Contributor Author

@ruben-arts Can you approve the CI to run in the meantime?

(edit: Thanks!)

@pavelzw

pavelzw commented Aug 11, 2025 •

Copy link
Copy Markdown
Collaborator

Sorry for the late reply

The bashrc sounds like a fair change to me. Setting SHELL results in the docker image not behaving exactly like the base image which might lead to some weirdness/inconsistency down the line 🤔 WDYT of only doing the bashrc part?

@matthewfeickert

matthewfeickert commented Aug 11, 2025 •

Copy link
Copy Markdown
Contributor Author

Setting SHELL results in the docker image not behaving exactly like the base image which might lead to some weirdness/inconsistency down the line 🤔 WDYT of only doing the bashrc part?

@pavelzw It isn't an issue with the base image being different.

e.g.

ARG BASE_IMAGE=debian:bookworm-slim

already uses Bash as the default shell

$ docker run --rm -ti debian:bookworm-slim
root@181caf7035f6:/# echo $SHELL
/bin/bash
root@181caf7035f6:/#

It is that the Docker RUN command itself executes by default under ["/bin/sh", "-c"].

The SHELL instruction allows the default shell used for the shell form of commands to be overridden. The default shell on Linux is ["/bin/sh", "-c"], and on Windows is ["cmd", "/S", "/C"]. The SHELL instruction must be written in JSON form in a Dockerfile.

— from Dockerfile SHELL docs

So setting the SHELL to [ "/bin/bash", "-c" ] is just ensuring behavior during the container image build.

e.g. The difference between

$ docker run --rm -ti debian:bookworm-slim /bin/sh -c 'echo $SHELL'  # no output, as not set

and

$ docker run --rm -ti debian:bookworm-slim /bin/bash -c 'echo $SHELL'
/bin/bash

I think I'm telling you things you already know though, so apologies if I've totally missed your point.

@pavelzw

pavelzw commented Aug 13, 2025

Copy link
Copy Markdown
Collaborator

yes but with your change, now the following would not be exactly as on the original debian/ubuntu containers:

FROM ghcr.io/prefix-dev/pixi:latest
RUN echo $0

this would now return /bin/bash instead of /bin/sh.

Why not just do something like this instead?

RUN printf '\neval "$(pixi completion --shell bash)"\n' >> /root/.bashrc

this doesn't require the SHELL to be set to /bin/bash.

* Add the Bash shell autocompletions to the ~/.bashrc to allow for use
  of tab completions while using interactively.
@matthewfeickert

matthewfeickert commented Sep 8, 2025 •

Copy link
Copy Markdown
Contributor Author

Why not just do something like this instead?

RUN printf '\neval "$(pixi completion --shell bash)"\n' >> /root/.bashrc

this doesn't require the SHELL to be set to /bin/bash.

To just get this in let's do this for now. Though see below for further questions.

yes but with your change, now the following would not be exactly as on the original debian/ubuntu containers:

FROM ghcr.io/prefix-dev/pixi:latest
RUN echo $0

this would now return /bin/bash instead of /bin/sh.

This seems like the "correct" behavior to me. What's the practical real world reason for wanting sh in some interactions and bash in others? Setting the SHELL is very common and ensures that you have a consistent shell across all interactions. I would think that people should not be concerned with the choices of the Debian project for their default shell.

@matthewfeickert

Copy link
Copy Markdown
Contributor Author

(Also the CI needs approval to run again, sorry.)

@pavelzw pavelzw added the enhancement New feature or request label Sep 8, 2025
@pavelzw
pavelzw merged commit d6bb7bf into prefix-dev:main Sep 8, 2025
16 checks passed
@matthewfeickert
matthewfeickert deleted the feat/add-completions branch September 9, 2025 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants