Skip to content

Instantly share code, notes, and snippets.

@joseluisq
Last active July 23, 2025 13:28
Show Gist options
  • Save joseluisq/1e96c54fa4e1e5647940 to your computer and use it in GitHub Desktop.
Save joseluisq/1e96c54fa4e1e5647940 to your computer and use it in GitHub Desktop.

Revisions

  1. joseluisq revised this gist Jul 2, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion terminal-git-branch-name.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Add Git Branch Name to Terminal Prompt (Mac)
    # Add Git Branch Name to Terminal Prompt (Linux/Mac)

    ![image](https://cloud.githubusercontent.com/assets/1700322/8341607/93e820d6-1a8b-11e5-81c8-3dd429270068.png)

  2. joseluisq revised this gist Jul 2, 2020. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion terminal-git-branch-name.md
    Original file line number Diff line number Diff line change
    @@ -14,4 +14,8 @@ parse_git_branch() {
    export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
    ```

    By MARTIN FITZPATRICK at http://martinfitzpatrick.name/article/add-git-branch-name-to-terminal-prompt-mac/
    By MARTIN FITZPATRICK at http://martinfitzpatrick.name/article/add-git-branch-name-to-terminal-prompt-mac/

    ## Bonus for Fish shell users

    If you are [Fish shell](https://fishshell.com/) user and you want speed up your Git workflow, try it out https://github.com/joseluisq/gitnow.
  3. joseluisq renamed this gist Jun 24, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. joseluisq created this gist Jun 24, 2015.
    17 changes: 17 additions & 0 deletions vim-git.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # Add Git Branch Name to Terminal Prompt (Mac)

    ![image](https://cloud.githubusercontent.com/assets/1700322/8341607/93e820d6-1a8b-11e5-81c8-3dd429270068.png)

    Open `~/.bash_profile` in your favorite editor and add the following content to the bottom.

    ```sh
    # Git branch in prompt.

    parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
    }

    export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
    ```

    By MARTIN FITZPATRICK at http://martinfitzpatrick.name/article/add-git-branch-name-to-terminal-prompt-mac/