Skip to content

Instantly share code, notes, and snippets.

@rodrigoreis
Last active July 9, 2022 15:14
Show Gist options
  • Select an option

  • Save rodrigoreis/7dd796d05d6682e995692be514830f3a to your computer and use it in GitHub Desktop.

Select an option

Save rodrigoreis/7dd796d05d6682e995692be514830f3a to your computer and use it in GitHub Desktop.

Revisions

  1. rodrigoreis revised this gist Jul 9, 2022. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions git-branch-in-bash.sh
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    function __git_ps1_dirty() {
    function __git_ps1_custom() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
    }

    function changes_in_branch() {
    echo -ne "\033[0;35m$(__git_ps1_dirty)\033[0m";
    function __git_get_branch_name() {
    echo -ne "\033[0;35m$(__git_ps1_custom)\033[0m";
    }

    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(changes_in_branch)\$ '
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(__git_get_branch_name)\$ '
  2. rodrigoreis created this gist Jul 1, 2022.
    9 changes: 9 additions & 0 deletions git-branch-in-bash.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    function __git_ps1_dirty() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
    }

    function changes_in_branch() {
    echo -ne "\033[0;35m$(__git_ps1_dirty)\033[0m";
    }

    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(changes_in_branch)\$ '