ChatGPT Conversation
Tags: #zsh
User: Thava Alagu (thavamuni@gmail.com)
Created: 03/03/2025, 15:11:32
Updated: 03/03/2025, 15:12:06
Exported: 03/03/2025, 15:16:58
I am using zsh with oh-my-zsh on my mac machine. I am not using git plugin; Still by default, it is showing the current git branch on the prompt inside any git repo; How can I disable that for all repos or disable selectively for some repos ? or choose another prompt style which does not include git branch on the prompt.
The Git branch appears in your prompt because of the default oh-my-zsh theme you're using, not the git
plugin. Here are ways to disable or modify it:
Modify your ~/.zshrc
file:
Open ~/.zshrc
in a text editor:
nano ~/.zshrc
Look for the ZSH_THEME
line. Your current theme is likely one that includes Git info (e.g., robbyrussell
, agnoster
, etc.).
Change the theme to one that does not show Git branches, such as:
ZSH_THEME="simple"
Save and exit (Ctrl + X
, then Y
, then Enter
).
Apply changes:
source ~/.zshrc
If you want to hide the Git branch only in specific repositories, add this to your ~/.zshrc
:
function git_prompt_info() {
local git_dir
git_dir=$(git rev-parse --git-dir 2>/dev/null)
if [[ "$PWD" =~ "/path/to/repo1|/path/to/repo2" ]]; then
echo "" # Hide Git branch for specific repos
else
git_prompt_short_sha
fi
}
Replace /path/to/repo1|/path/to/repo2
with actual repo paths.
Instead of changing themes, you can set a minimal custom prompt:
PROMPT='%n@%m %~ %# '
This will display:
%n
)%m
)%~
)#
for root, $
for normal users.Add this line to your ~/.zshrc
and reload:
source ~/.zshrc
Let me know if you need a specific prompt style!
Powered by ChatGPT Exporter