<commit_before>#!/bin/bash
# bash_prompt.sh
# <NAME>

# Output ANSI escape sequence for the given color code
__set_color() {
	echo -n "\[\e[${1}m\]"
}

# Reset color escape sequences
__reset_color() {
	__set_color 0
}

# Outputs a succinct and useful interactive prompt
# Escape sequences: http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html
__output_ps1() {

	# Output name of current working directory (with ~ denoting HOME)
	__set_color $PURPLE_BOLD
	echo -n "\W"
	__set_color $WHITE_BOLD
	echo -n " : "

	# If working directory is (or resides in) a git repository
	if git rev-parse --git-dir &> /dev/null; then

		# Output name of current branch
		__set_color $PURPLE_BOLD
		echo -n "$(git rev-parse --abbrev-ref HEAD 2> /dev/null)"
		__set_color $WHITE_BOLD
		echo -n " : "

	fi

	# Output $ for user and # for root
	__set_color $PURPLE_BOLD
	echo -n "\$ "
	__reset_color

}

# Detect and manage Python virtualenvs when changing directories
__detect_python_virtualenv() {

	local dirname="$(basename "$PWD")"
	local virtualenv="$WORKON_HOME"/"$dirname"
	# If current directory has a virtualenv that is not itself
	if [ "$dirname" != "/" -a -d "$virtualenv" -a "$virtualenv" != "$PWD" ]; then
		# Activate virtualenv if it is not already active
		if [ -z "$VIRTUAL_ENV" -o "$VIRTUAL_ENV" != "$virtualenv" ]; then
			source "$virtualenv"/bin/activate
		fi
	else
		# Otherwise, deactivate any active virtualenv
		if [ ! -z "$VIRTUAL_ENV" ]; then
			deactivate
		fi
	fi

}

# Run the following for each new command
__update_prompt_command() {

	__detect_python_virtualenv
	PS1="$(__output_ps1)"
	# Write in-memory command history to file
	history -a
	# Ensure that current working directory is updated as needed
	update_terminal_cwd

}
PROMPT_COMMAND="__update_prompt_command"<commit_msg>Always export interactive prompt (PS1) string<commit_after>#!/bin/bash
# bash_prompt.sh
# <NAME>

# Output ANSI escape sequence for the given color code
__set_color() {
	echo -n "\[\e[${1}m\]"
}

# Reset color escape sequences
__reset_color() {
	__set_color 0
}

# Outputs a succinct and useful interactive prompt
# Escape sequences: http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html
__output_ps1() {

	# Output name of current working directory (with ~ denoting HOME)
	__set_color $PURPLE_BOLD
	echo -n "\W"
	__set_color $WHITE_BOLD
	echo -n " : "

	# If working directory is (or resides in) a git repository
	if git rev-parse --git-dir &> /dev/null; then

		# Output name of current branch
		__set_color $PURPLE_BOLD
		echo -n "$(git rev-parse --abbrev-ref HEAD 2> /dev/null)"
		__set_color $WHITE_BOLD
		echo -n " : "

	fi

	# Output $ for user and # for root
	__set_color $PURPLE_BOLD
	echo -n "\$ "
	__reset_color

}

# Detect and manage Python virtualenvs when changing directories
__detect_python_virtualenv() {

	local dirname="$(basename "$PWD")"
	local virtualenv="$WORKON_HOME"/"$dirname"
	# If current directory has a virtualenv that is not itself
	if [ "$dirname" != "/" -a -d "$virtualenv" -a "$virtualenv" != "$PWD" ]; then
		# Activate virtualenv if it is not already active
		if [ -z "$VIRTUAL_ENV" -o "$VIRTUAL_ENV" != "$virtualenv" ]; then
			source "$virtualenv"/bin/activate
		fi
	else
		# Otherwise, deactivate any active virtualenv
		if [ ! -z "$VIRTUAL_ENV" ]; then
			deactivate
		fi
	fi

}

# Run the following for each new command
__update_prompt_command() {

	__detect_python_virtualenv
	export PS1="$(__output_ps1)"
	# Write in-memory command history to file
	history -a
	# Ensure that current working directory is updated as needed
	update_terminal_cwd

}
PROMPT_COMMAND="__update_prompt_command"
{'fraction_non_alphanumeric': 0.11392750068138457, 'fraction_numerical': 0.0035431997819569366, 'mean_word_length': 4.034293552812072, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '2825308', 'n_tokens_mistral': 1361, 'n_tokens_neox': 1267, 'n_words': 389}