Skip to main content
100%

Add Git Branch Name to Terminal Prompt (Mac)

✓ Published0🌍 Public
Aackuser
Last edited Jun 24, 2015
Created on Dec 11, 2018

This example shows a terminal prompt configured to display the current Git branch name inline, alongside the standard user, host, and working directory information. The `~/.bash_profile` file contains a `parse_git_branch()` function that runs `git branch` and filters the output with `sed` to extract only the active branch marker. The prompt is then customized using the `PS1` environment variable, which embeds the function’s result in green ANSI color codes. This approach relies on shell scripting and standard Unix text-processing tools rather than a visualization library.

AI-generated description

Similar vizzes