Switch Codespaces login shell to zsh - #4
Merged
Conversation
Add a configure_login_shell step to install-codespaces.sh that runs sudo chsh against $USER so new terminals in a Codespace start in zsh. Skip when zsh is missing or already the login shell. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Codespaces dotfiles installer so that Codespaces sessions start in zsh by changing the user’s login shell, aligning the actual shell experience with the repo’s zsh configuration.
Changes:
- Add a
configure_login_shellstep that discoverszsh, checks the current login shell, and runssudo chshwhen needed. - Wire the new step into the Codespaces install sequence via
run_stepso failures are logged but don’t stop the rest of setup. - Document the new behavior in the Codespaces section of
README.md.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents that Codespaces setup updates the login shell to zsh. |
| install-codespaces.sh | Adds an install step to switch the login shell to zsh and runs it during Codespaces setup. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
Comment on lines
+40
to
+47
| local current_shell | ||
| current_shell="$(getent passwd "$USER" | cut -d: -f7)" | ||
| if [[ "$current_shell" == "$zsh_path" ]]; then | ||
| echo "Login shell is already $zsh_path, skipping" | ||
| return 0 | ||
| fi | ||
|
|
||
| sudo chsh -s "$zsh_path" "$USER" |
- Refactor install-codespaces.sh with a main() guard so functions can be sourced safely from tests. - Add bats unit tests for configure_login_shell that stub out command, getent, and sudo. - Add a GitHub Actions workflow that runs shellcheck, bats, and a Docker-based integration test against the Codespaces universal image. - Drop unused SCRIPT_DIR vars flagged by shellcheck in lib.sh and install-local.sh. - Document tests in README. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
`su - codespace -c` starts a login shell which clears the inherited CODESPACES environment variable, so install.sh fell through to install-local.sh and never ran configure_login_shell. Pass CODESPACES inline so install.sh dispatches to install-codespaces.sh. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Codespaces ships with
bashas the default login shell, so even afterinstall-codespaces.shsymlinks.zshrc, new terminals still start in bash. This change makes the dotfiles installer flip the login shell to zsh so a fresh Codespace drops you straight into zsh.Changes
configure_login_shellstep toinstall-codespaces.sh:zshviacommand -v zsh; skip with a message if it isn't installed.getent passwd "$USER"; skip if it's already zsh (idempotent).sudo chsh -s "$zsh_path" "$USER"to update/etc/passwd.run_steplist so a failure is logged but doesn't abort the rest of the install.README.md.Notes
zshis preinstalled in the default Codespaces image, so no extra apt install is needed.chshonly takes effect for new login sessions, which is fine for Codespaces (next terminal / next start).bash -n install-codespaces.sh.shellcheckonly reports the pre-existing SC1091 info aboutlib.sh.