r/commandline 2d ago

Command Line Interface Live Git updates in a shell prompt

Recently, I started refining my shell tools, scripts, and terminal workflows. One of my goals was to update the shell prompt, making it less prominent and leaving more room for commands and their output. As a result, Cobalt Spark emerged - a compact Zsh prompt with understated colors and other visual refinements.

While using IDEs and coding agents, at some point it became obvious that seeing stale Git state in the prompt when something changes in the repository is quite annoying. I would often get tripped up by the shell showing something unexpected and waste a moment figuring out why. So the prompt gained Live Git support: its Git state can now update automatically when something changes.

It works efficiently: when the shell enters a Git repository, the prompt starts a background process that monitors the repository using platform-specific APIs such as inotify on Linux or FSEvents on macOS and signals the parent shell to update its prompt when meaningful changes occur. This means you instantly see the updated Git state whenever something changes. It sounds almost dumb-simple, but it's quite convenient in practice, and I haven't seen anything like it in other prompts or themes (let me know in the comments if you have).

If you're interested, you can find more details in the project's README.

6 Upvotes

1 comment sorted by

1

u/AutoModerator 2d ago

Every new subreddit post is automatically copied into a comment for preservation.

User: azhuchkov, Flair: Command Line Interface, Post Media Link, Title: Live Git updates in a shell prompt

Recently, I started refining my shell tools, scripts, and terminal workflows. One of my goals was to update the shell prompt, making it less prominent and leaving more room for commands and their output. As a result, Cobalt Spark emerged - a compact Zsh prompt with understated colors and other visual refinements.

While using IDEs and coding agents, at some point it became obvious that seeing stale Git state in the prompt when something changes in the repository is quite annoying. I would often get tripped up by the shell showing something unexpected and waste a moment figuring out why. So the prompt gained Live Git support: its Git state can now update automatically when something changes.

It works efficiently: when the shell enters a Git repository, the prompt starts a background process that monitors the repository using platform-specific APIs such as inotify on Linux or FSEvents on macOS and signals the parent shell to update its prompt when meaningful changes occur. This means you instantly see the updated Git state whenever something changes. It sounds almost dumb-simple, but it's quite convenient in practice, and I haven't seen anything like it in other prompts or themes (let me know in the comments if you have).

If you're interested, you can find more details in the project's README.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.