<commit_before>#!/usr/bin/env bash

# Line colors
__mk5_normal="\[\e[0m\]"
__mk5_black="\[\e[0;30m\]"
__mk5_red="\[\e[0;31m\]"
__mk5_green="\[\e[0;32m\]"
__mk5_yellow="\[\e[0;33m\]"
__mk5_blue="\[\e[0;34m\]"
__mk5_purple="\[\e[0;35m\]"
__mk5_cyan="\[\e[0;36m\]"
__mk5_white="\[\e[0;37m\]"
__mk5_b_black="\[\e[1;30m\]"
__mk5_b_red="\[\e[1;31m\]"
__mk5_b_green="\[\e[1;32m\]"
__mk5_b_yellow="\[\e[1;33m\]"
__mk5_b_blue="\[\e[1;34m\]"
__mk5_b_purple="\[\e[1;35m\]"
__mk5_b_cyan="\[\e[1;36m\]"
__mk5_b_white="\[\e[1;37m\]"

# Special characters
__mk5_char_usr='>'
__mk5_char_root='#'
__mk5_char_jobs='&'
__mk5_char_unt='-'
__mk5_char_mod='*'
__mk5_char_add='+'
__mk5_char_stash='\$'
__mk5_char_behind='v'
__mk5_char_ahead='^'
__mk5_char_no_up='!'

__mk5_hostname="${HOSTNAME%%.*}"
__mk5_home="$(readlink -f "$HOME" 2>/dev/null || echo "$HOME")"

__mk5_set_prompt() {
  # Grab status code first
  local last_status="$?"

  # Status color
  local pchar_color
  if [ "$last_status" == 0 ]; then
    pchar_color="$__mk5_b_green"
  else
    pchar_color="$__mk5_b_red"
  fi

  # Use $ or # for prompt
  local pchar
  if [ "$EUID" == 0 ]; then
    pchar="$__mk5_char_root"
  else
    pchar="$__mk5_char_usr"
  fi

  # Display hostname if ssh'd
  local hostname
  [ "$SSH_TTY" ] && hostname="$__mk5_b_cyan@$__mk5_cyan$__mk5_hostname"

  # Display job count
  local jobs_info
  local jobs_count="$(jobs -p | wc -l | awk '{print$1}')"
  if [ "$jobs_count" != 0 ]; then
    jobs_info="$__mk5_yellow$__mk5_char_jobs$jobs_count$__mk5_b_yellow, "
  fi

  # Git stuff (mostly in bash for speed)<commit_msg>better jobs handling<commit_after>#!/usr/bin/env bash

# Line colors
__mk5_normal="\[\e[0m\]"
__mk5_black="\[\e[0;30m\]"
__mk5_red="\[\e[0;31m\]"
__mk5_green="\[\e[0;32m\]"
__mk5_yellow="\[\e[0;33m\]"
__mk5_blue="\[\e[0;34m\]"
__mk5_purple="\[\e[0;35m\]"
__mk5_cyan="\[\e[0;36m\]"
__mk5_white="\[\e[0;37m\]"
__mk5_b_black="\[\e[1;30m\]"
__mk5_b_red="\[\e[1;31m\]"
__mk5_b_green="\[\e[1;32m\]"
__mk5_b_yellow="\[\e[1;33m\]"
__mk5_b_blue="\[\e[1;34m\]"
__mk5_b_purple="\[\e[1;35m\]"
__mk5_b_cyan="\[\e[1;36m\]"
__mk5_b_white="\[\e[1;37m\]"

# Special characters
__mk5_char_usr='>'
__mk5_char_root='#'
__mk5_char_stopped='%'
__mk5_char_running='&'
__mk5_char_unt='-'
__mk5_char_mod='*'
__mk5_char_add='+'
__mk5_char_stash='\$'
__mk5_char_behind='v'
__mk5_char_ahead='^'
__mk5_char_no_up='!'

__mk5_hostname="${HOSTNAME%%.*}"
__mk5_home="$(readlink -f "$HOME" 2>/dev/null || echo "$HOME")"

__mk5_set_prompt() {
  # Grab status code first
  local last_status="$?"

  # Status color
  local pchar_color
  if [ "$last_status" == 0 ]; then
    pchar_color="$__mk5_b_green"
  else
    pchar_color="$__mk5_b_red"
  fi

  # Use $ or # for prompt
  local pchar
  if [ "$EUID" == 0 ]; then
    pchar="$__mk5_char_root"
  else
    pchar="$__mk5_char_usr"
  fi

  # Display hostname if ssh'd
  local hostname
  [ "$SSH_TTY" ] && hostname="$__mk5_b_cyan@$__mk5_cyan$__mk5_hostname"

  # Display job count
  local jobs_info
  local jobs_l="$(jobs)"
  if [ "$jobs_l" ]; then
    # Stopped
    local jobs_s="$(grep '^.\{6\}S' <<< "$jobs_l" | wc -l | awk '{print$1}')"
    if [ "$jobs_s" != 0 ]; then
      jobs_info+=" $__mk5_red$__mk5_char_stopped$jobs_s"
    fi

    # Running
    local jobs_r="$(grep '^.\{6\}R' <<< "$jobs_l" | wc -l | awk '{print$1}')"
    if [ "$jobs_r" != 0 ]; then
      jobs_info+=" $__mk5_yellow$__mk5_char_running$jobs_r"
    fi

    [ "$jobs_info" ] && jobs_info="${jobs_info# }$__mk5_b_yellow, "
  fi

  # Git stuff (mostly in bash for speed)
{'fraction_non_alphanumeric': 0.2189265536723164, 'fraction_numerical': 0.05508474576271186, 'mean_word_length': 4.638535031847134, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5295069', 'n_tokens_mistral': 1817, 'n_tokens_neox': 1713, 'n_words': 242}