Forked from reinvanoyen/terminal-prompt-git-branch-zsh.md
Created
July 30, 2023 19:15
-
-
Save intrueder/2ec30f75c8ef89914f24decc955ef67d to your computer and use it in GitHub Desktop.
Revisions
-
reinvanoyen revised this gist
Dec 21, 2022 . 1 changed file with 13 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,20 +1,28 @@ # Add Git Branch Name to Terminal Prompt (MacOS Catalina zsh) ## Updated for MacOS Big Sur | Monterey | Ventura <img width="822" alt="screenshot" src="https://user-images.githubusercontent.com/513140/71285442-13d6db00-235d-11ea-8ba6-5bfe45739888.png"> ### Install Open `~/.zshrc` in your favorite editor and add the following content to the bottom. ```sh function parse_git_branch() { git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p' } COLOR_DEF=$'%f' COLOR_USR=$'%F{243}' COLOR_DIR=$'%F{197}' COLOR_GIT=$'%F{39}' setopt PROMPT_SUBST export PROMPT='${COLOR_USR}%n ${COLOR_DIR}%~ ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF} $ ' ``` ### Reload and apply adjustments To reload and apply adjustments to the formatting use `source ~/.zshrc` in the zsh shell. ### Credits * Thank you benP2ER for the useful additions in [his comment](https://gist.github.com/reinvanoyen/05bcfe95ca9cb5041a4eafd29309ff29?permalink_comment_id=4117181#gistcomment-4117181) * Original gist by Jose Quintana: [Add Git Branch Name to Terminal Prompt (Linux/Mac) ](https://gist.github.com/joseluisq/1e96c54fa4e1e5647940) -
reinvanoyen revised this gist
Dec 20, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,8 @@ # Add Git Branch Name to Terminal Prompt (MacOS Catalina zsh) <img width="822" alt="screenshot" src="https://user-images.githubusercontent.com/513140/71285442-13d6db00-235d-11ea-8ba6-5bfe45739888.png"> Open `~/.zshrc` in your favorite editor and add the following content to the bottom. ```sh function parse_git_branch() { -
reinvanoyen revised this gist
Dec 20, 2019 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,6 @@ # Add Git Branch Name to Terminal Prompt (MacOS Catalina zsh) <img width="822" alt="screenshot" src="https://user-images.githubusercontent.com/513140/71285442-13d6db00-235d-11ea-8ba6-5bfe45739888.png"> Open ~/.zshrc in your favorite editor and add the following content to the bottom. ```sh -
reinvanoyen revised this gist
Dec 20, 2019 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,7 @@ # Add Git Branch Name to Terminal Prompt (MacOS Catalina zsh)  Open ~/.zshrc in your favorite editor and add the following content to the bottom. ```sh @@ -11,4 +15,6 @@ COLOR_DIR=$'\e[38;5;197m' COLOR_GIT=$'\e[38;5;39m' setopt PROMPT_SUBST export PROMPT='${COLOR_USR}%n ${COLOR_DIR}%~ ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF} $ ' ``` Original gist for Bash by Jose Quintana: https://gist.github.com/joseluisq/1e96c54fa4e1e5647940 -
reinvanoyen revised this gist
Dec 20, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ Open ~/.zshrc in your favorite editor and add the following content to the bottom. ```sh function parse_git_branch() { git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p' } -
reinvanoyen created this gist
Dec 20, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ Open ~/.zshrc in your favorite editor and add the following content to the bottom. ```ssh function parse_git_branch() { git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p' } COLOR_DEF=$'\e[0m' COLOR_USR=$'\e[38;5;243m' COLOR_DIR=$'\e[38;5;197m' COLOR_GIT=$'\e[38;5;39m' setopt PROMPT_SUBST export PROMPT='${COLOR_USR}%n ${COLOR_DIR}%~ ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF} $ ' ```