Blame view

repos/robbyrussell/oh-my-zsh/plugins/branch/branch.plugin.zsh 787 Bytes
61aaa7b58   mj   Squashed 'repos/r...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  # Branch: displays the current Git or Mercurial branch fast.
  # Victor Torres <vpaivatorres@gmail.com>
  # Oct 2, 2015
  
  function branch_prompt_info() {
    # Defines path as current directory
    local current_dir=$PWD
    # While current path is not root path
    while [[ $current_dir != '/' ]]
    do
      # Git repository
      if [[ -d "${current_dir}/.git" ]]
      then
        echo '±' ${"$(<"$current_dir/.git/HEAD")"##*/}
        return;
      fi
      # Mercurial repository
      if [[ -d "${current_dir}/.hg" ]]
      then
d9bebbb3c   mj   Squashed 'repos/r...
20
21
22
23
24
25
        if [[ -f "$current_dir/.hg/branch" ]]
        then
          echo '☿' $(<"$current_dir/.hg/branch")
        else
          echo '☿ default'
        fi
61aaa7b58   mj   Squashed 'repos/r...
26
27
28
29
30
31
        return;
      fi
      # Defines path as parent directory and keeps looking for :)
      current_dir="${current_dir:h}"
    done
  }