<commit_before># My bash prompt
# 
# Copyright (c) 2011 "Cowboy" <NAME>
# Licensed under the MIT license.
# http://benalman.com/about/license/
# 
# Example:
# [master:AMU][cowboy@Bens-MacBook-Pro:~/.dotfiles]
# [11:14:45] $
# 
# Screenshot:
# http://www.flickr.com/photos/rj3/3959554047/sizes/o/

function prompt_git() {
  local GITDIR=$(git rev-parse --git-dir 2>/dev/null)
  local HEADSHA=$(git rev-parse --verify HEAD 2>/dev/null)
  if [[ "$GITDIR" && "$HEADSHA" ]]; then
    local BRANCH=$(git branch --no-color 2>/dev/null | awk '/^\*/ { print($2) }')
  else
    local BRANCH='(new)'
  fi
  local STATUS=$(git status 2>/dev/null | awk 'BEGIN {r=""} /^# Changes to be committed:$/ {r=r "A"}\
    /^# Changes not staged for commit:$/ {r=r "M"} /^# Untracked files:$/ {r=r "U"} END {print(r)}')

  local OUT=$BRANCH
  if [ "$STATUS" ]; then
    OUT=$OUT$3:$2$STATUS
  fi
  if [ "$OUT" ]; then
    OUT=$4[$2$OUT$4]$1
  fi

  echo $OUT<commit_msg>Prompt now displays correctly in folders that aren't git repos.<commit_after># My bash prompt
#
# Copyright (c) 2011 "Cowboy" <NAME>
# Licensed under the MIT license.
# http://benalman.com/about/license/
#
# Example:
# [master:AMU][cowboy@Bens-MacBook-Pro:~/.dotfiles]
# [11:14:45] $
#
# Screenshot:
# http://www.flickr.com/photos/rj3/3959554047/sizes/o/

function prompt_git() {
  local BRANCH=$(
    GITDIR=$(git rev-parse --git-dir 2>/dev/null)
    HEADSHA=$(git rev-parse --verify HEAD 2>/dev/null)
    if [[ ! "$GITDIR" ]]; then
      echo ''
    elif [[ "$HEADSHA" ]]; then
      git branch --no-color 2>/dev/null | awk '/^\*/ { print($2) }'
    else
      echo '(init)'
    fi
  )
  local STATUS=$(
    git status 2>/dev/null | awk 'BEGIN {r=""} \
      /^# Changes to be committed:$/        {r=r "A"}\
      /^# Changes not staged for commit:$/  {r=r "M"}\
      /^# Untracked files:$/                {r=r "U"}\
      END {print(r)}'
  )

  local OUT=$BRANCH
  if [ "$STATUS" ]; then
    OUT=$OUT$3:$2$STATUS
  fi
  if [ "$OUT" ]; then
    OUT=$4[$2$OUT$4]$1
  fi

  echo $OUT
{'fraction_non_alphanumeric': 0.20777941900541605, 'fraction_numerical': 0.03151157065484983, 'mean_word_length': 2.8704761904761904, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1628698', 'n_tokens_mistral': 863, 'n_tokens_neox': 800, 'n_words': 187}