From 6c68f369cef378731ce8cb8065a99b02039ad85f Mon Sep 17 00:00:00 2001
From: Salt <rehashedsalt@cock.li>
Date: Mon, 15 Feb 2021 10:24:57 -0600
Subject: [PATCH] Make some tweaks to profile and functions

---
 base/.functions | 26 ++++++++++----------------
 base/.profile   |  4 ++++
 2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/base/.functions b/base/.functions
index 731d491f..6104159e 100644
--- a/base/.functions
+++ b/base/.functions
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/bash
 #
 # .functions
 # Functions for interactive shells
@@ -19,6 +19,15 @@ proj() {
 	if [ -d "$projdir" ]; then
 		# It exists
 		cd "$projdir" || return 50
+		# Run code if we have it
+		# The fun part is this environment file can access some vars about the proj
+		local envfile="$projdir/.env"
+		if [ -r "$envfile" ]; then
+			. "$envfile"
+			echo "Sourced environment file for project"
+			# Also mark an envvar to ensure we can detect this condition
+			export PROJECT="$projname"
+		fi
 	else
 		# It does not exist
 		echo "Creating new project \"$projname\""
@@ -53,18 +62,3 @@ _proj() {
 	COMPREPLY=($(compgen -W "$COMPREPLY" "${COMP_WORDS[COMP_CWORD]}"))
 	return 0
 }
-# Autocompletion for zsh
-compdef _proj proj > /dev/null 2>&1 && \
-_proj() {
-	#! /usr/bin/env zsh
-	# It's okay, shellcheck
-	# We zsh now
-	# shellcheck disable=2039
-	for dir in "$HOME"/Projects/*; do
-		temp="$(basename "$dir")"
-		temp="${reply//[^ a-zA-Z0-9.]/}"
-		reply+=" $temp"
-	done
-	return 0
-}
-
diff --git a/base/.profile b/base/.profile
index 4a65cba1..7d529073 100755
--- a/base/.profile
+++ b/base/.profile
@@ -309,6 +309,10 @@ _ps1bash() {
 	elif [ "$USER" != "salt" ]; then
 		_prefix="${fg_bold}${fg_yellow}$USER${r}${fg_yellow}:${r}${_prefix}"
 	fi
+	# If we're in a PROJECT, post that envvar
+	if [ -n "$PROJECT" ]; then
+		_prefix="${_prefix}${fg_bold}${fg_blue}$PROJECT${r}${fg_blue}:${r}"
+	fi
 	# Color PWD
 	_prefix="${_prefix}${fg_blue}"
 	# Show the tilde instead of $HOME