_display_bug_machine_info() {
  local output=""
  local separator=" | " # Define the separator

  # Check if BUG is set and non-empty
  if [ -n "$BUG" ]; then
    # Format BUG value (Cyan) - REMOVED "BUG: " label
    printf -v output "\e[0;36mB:%s\e[0m" "$BUG"
  fi

  # Check if MACHINE is set and non-empty
  if [ -n "$MACHINE" ]; then
    local machine_part=""
    # Format MACHINE value (Magenta) - REMOVED "MACHINE: " label
    printf -v machine_part "\e[0;35mM:%s\e[0m" "$MACHINE"

    # If BUG was also set (output is not empty), add separator first
    if [ -n "$output" ]; then
      output+="$separator$machine_part"
    else
      # Otherwise, MACHINE is the first/only part
      output="$machine_part"
    fi
  fi

  # If the combined output string is not empty, print it
  if [ -n "$output" ]; then
    if [ -n "$STARSHIP_SESSION_KEY" ]; then
      printf "%s" "$output" # echo adds the needed newline after the combined string
    else
      echo "$output"
    fi
  fi
  return 0
}


if [[ ! "$PROMPT_COMMAND" =~ _display_bug_machine_info ]]; then
  # Prepend the function call
  PROMPT_COMMAND="_display_bug_machine_info${PROMPT_COMMAND:+;}${PROMPT_COMMAND}"
fi


## Aliases ##

alias batool'=/google/data/ro/projects/bandaid/batool'
alias pancetta='/google/bin/releases/bandaid-team/pancetta_par/pancetta.par'
alias safergcp='/google/bin/releases/safer-gcp/tools/safergcp'
alias clients='g4 clients -u $USER|awk -F: '\''{print $2}'\'''
alias g3='cd experimental/users/${USER}/'
alias health_check='admin_session --reason=$BUG --tonic_policy=common-loas-transact-dat --transact --delegates=mdbuser/bandaid-batool-server,mdbuser/cloud-control2-gdchardware-frontend -- /google/data/ro/projects/bandaid/batool gdc health_check --justification=$BUG gmec-$MACHINE'

alias admin_batool='admin_session --reason=$BUG --tonic_policy=common-loas-transact-dat --transact --delegates=mdbuser/bandaid-batool-server,mdbuser/cloud-control2-gdchardware-frontend -- /google/data/ro/projects/bandaid/batool'

alias connectivity='admin_session --reason=$BUG --tonic_policy=common-loas-transact-dat --transact --delegates=mdbuser/bandaid-batool-server,mdbuser/cloud-control2-gdchardware-frontend -- /google/data/ro/projects/bandaid/batool gdc check connectivity gmec-$MACHINE'

alias machine_enable='admin_session --reason=$BUG --tonic_policy=common-loas-transact-dat --transact --delegates=mdbuser/bandaid-batool-server,mdbuser/cloud-control2-gdchardware-frontend -- /google/data/ro/projects/bandaid/batool gdc machine enable --env=prod --justification=$BUG --disable_claim=$BUG gmec-$MACHINE'

alias con='admin_session --reason=$BUG --tonic_policy=common-loas-transact-dat --transact --delegates=mdbuser/bandaid-batool-server,mdbuser/cloud-control2-gdchardware-frontend -- ssh gmec-$MACHINE'

alias admin='admin_session --reason=$BUG --tonic_policy=common-loas-transact-dat --transact --delegates=mdbuser/bandaid-batool-server,mdbuser/cloud-control2-gdchardware-frontend -- '

alias gdcgrants='grants add --reason=$BUG cloud-gmec-batool-prod-rw-acl:20h cloud-kubernetes-edge-producer-api-admin-prod:20h gdchardwaremanagement-internal-admin-prod:20h cloud-gmec-bandaid-prod-riker-acl:20h'

alias gcsec='gcert -m=cloud-gmec-offnet --s --reason=$BUG --use_secondary_key --ua_ca_instance=prod --noloas2 --nocorpssh'


alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

#batool() { /google/data/ro/projects/bandaid/batool "$@"; }
#pancetta() { bash /google/bin/releases/bandaid-team/pancetta_par/pancetta.par "$0"; }
riker() { /google/data/ro/projects/bandaid/riker "$0"; }
# Function to display BUG and MACHINE info above the Bash prompt


gdc() {
  for arg in "$@"; do
  if [[ "$arg" =~ ^(b\/[0-9]+|shax\/[0-9]+|irm\/i_[0-9a-Z]+) ]]; then
    BUG="$arg"
  elif [[ "$arg" =~ ^gmec- ]]; then
    MACHINE="$arg"
  fi
done
}
