Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

add fish and zsh prompt support#532

Merged
mangelajo merged 3 commits intojumpstarter-dev:mainfrom
bennyz:fish-prompt
Jul 2, 2025
Merged

add fish and zsh prompt support#532
mangelajo merged 3 commits intojumpstarter-dev:mainfrom
bennyz:fish-prompt

Conversation

@bennyz
Copy link
Copy Markdown
Member

@bennyz bennyz commented Jun 24, 2025

Summary by CodeRabbit

  • Refactor
    • Improved handling of shell environment and prompt customization for different shell types (bash, fish, zsh, and others).
    • Enhanced detection and setup of shell-specific environment variables and command-line arguments for a more consistent user experience.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 24, 2025

Deploy Preview for jumpstarter-docs ready!

Name Link
🔨 Latest commit 5d637db
🔍 Latest deploy log https://app.netlify.com/projects/jumpstarter-docs/deploys/6864e0649714dd0008db4a76
😎 Deploy Preview https://deploy-preview-532--jumpstarter-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 24, 2025

Walkthrough

The launch_shell function in jumpstarter/common/utils.py was refactored to improve how different shells are launched and how their environments and prompts are set. The function now detects the shell type, applies shell-specific environment variables and arguments, and handles prompt customization more robustly.

Changes

File(s) Change Summary
jumpstarter/common/utils.py Refactored launch_shell to handle shell-specific environment and prompt setup, improved type annotation

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant Utils as launch_shell
    participant Shell

    Caller->>Utils: Call launch_shell(host, context, allow, unsafe, command)
    Utils->>Utils: Determine shell type from SHELL env
    alt command is provided
        Utils->>Shell: Execute command with common_env
    else bash shell
        Utils->>Shell: Launch bash with --norc, --noprofile, PS1 prompt
    else fish shell
        Utils->>Shell: Launch fish with custom fish_prompt via --init-command
    else zsh shell
        Utils->>Shell: Launch zsh with --no-rcs, PS1 prompt
    else other shell
        Utils->>Shell: Launch shell with common_env
    end
    Shell-->>Utils: Return exit code
    Utils-->>Caller: Return exit code
Loading

Possibly related PRs

Suggested reviewers

  • NickCao
  • mangelajo

Poem

In the warren where the shells reside,
A rabbit tweaks the prompt with pride.
Bash, fish, or zsh—each gets its due,
With colors and cues both shiny and new.
Hop, hop, the code refines,
Launching shells with clever signs!
🐇💻


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 629e3e1 and 7d6bcbe.

📒 Files selected for processing (1)
  • packages/jumpstarter/jumpstarter/common/utils.py (2 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
packages/jumpstarter/jumpstarter/common/utils.py

[refactor] 78-114: Unnecessary "elif" after "return", remove the leading "el" from "elif"

(R1705)


[refactor] 75-75: Consider using 'with' for resource-allocating operations

(R1732)


[refactor] 113-113: Consider using 'with' for resource-allocating operations

(R1732)

🔇 Additional comments (7)
packages/jumpstarter/jumpstarter/common/utils.py (7)

52-52: Good improvement to type annotation.

The change from [str] to list[str] follows modern Python typing conventions and is more explicit than the deprecated syntax.


66-72: Well-structured environment setup.

The refactoring to extract shell information and separate common environment variables from shell-specific prompt settings is clean and maintainable.


78-85: Bash handling looks correct.

The implementation properly formats ANSI escape codes for bash and uses appropriate flags. Consider whether endswith("bash") should match variants like "rbash" - this might be intentional for compatibility but worth confirming.


86-103: Excellent fish shell implementation.

The inline fish_prompt function definition using fish-specific color commands is well-implemented. Using --init-command is an elegant approach to customize the prompt without modifying user configuration files.


104-111: Zsh implementation addresses the core issue.

The zsh-specific prompt formatting using %F{color} syntax correctly addresses the escape character handling issues mentioned in the PR objectives. This should resolve the problem where zsh didn't respect PS1 properly.


75-77: Resource management is acceptable for this use case.

While static analysis suggests using context managers for resource allocation, the current approach with process.wait() is appropriate here since the process is started and immediately waited for. The subprocess cleanup is handled properly by the wait() call.

Also applies to: 83-84, 101-102, 109-110, 113-114


112-114: Good fallback implementation.

The fallback for unsupported shells is clean and safe, launching with common environment variables without attempting potentially incompatible prompt customization.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Member

@mangelajo mangelajo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I probably need to do the same for zsh

bennyz added 2 commits June 25, 2025 16:00
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
@bennyz
Copy link
Copy Markdown
Member Author

bennyz commented Jun 25, 2025

Nice, I probably need to do the same for zsh

I thought zsh would respect PS1 but seems like it doesn't work well because of the escape characters, so added it separately

@bennyz bennyz changed the title add fish prompt support add fish and zsh prompt support Jun 25, 2025
@bennyz bennyz marked this pull request as ready for review June 26, 2025 07:20
@bennyz bennyz requested a review from mangelajo July 2, 2025 07:20
Copy link
Copy Markdown
Member

@mangelajo mangelajo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 🤟

@mangelajo mangelajo enabled auto-merge July 2, 2025 07:31
@mangelajo mangelajo merged commit c6401f0 into jumpstarter-dev:main Jul 2, 2025
25 of 32 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants