From c9cdba1c55c7cbaad958058464a26c66e7026a65 Mon Sep 17 00:00:00 2001 From: Rawley Fowler <75388349+rawleyfowler@users.noreply.github.com> Date: Mon, 9 May 2022 11:58:41 -0600 Subject: [PATCH] Create .profile --- macos/.profile | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 macos/.profile diff --git a/macos/.profile b/macos/.profile new file mode 100644 index 0000000..28da9d2 --- /dev/null +++ b/macos/.profile @@ -0,0 +1,45 @@ +export CLICOLOR=1 +COLOR_RED="\033[0;31m" +COLOR_YELLOW="\033[0;33m" +COLOR_GREEN="\033[0;32m" +COLOR_OCHRE="\033[38;5;95m" +COLOR_BLUE="\033[0;34m" +COLOR_WHITE="\033[0;37m" +COLOR_RESET="\033[0m" + +function git_color { + local git_status="$(git status 2> /dev/null)" + if [[ ! $git_status =~ "Working directory clean" ]]; then + echo -e $COLOR_RED + elif [[ $git_status =~ "Your branch is ahead of" ]]; then + echo -e $COLOR_YELLOW + elif [[ $git_status =~ "Nothing to commit" ]]; then + echo -e $COLOR_GREEN + else + echo -e $COLOR_OCHRE + fi +} + +function git_branch { + local git_status="$(git status 2> /dev/null)" + local on_branch="On branch ([^${IFS}]*)" + local on_commit="HEAD detached at ([^${IFS}]*)" + + if [[ $git_status =~ on_branch ]]; then + local branch=${BASH_REMATCH[1]} + echo "[$branch]" + elif [[ $git_status =~ $on_branch ]]; then + local commit=${BASH_REMATCH[1]} + echo "[$commit]" + fi +} + +PS1='\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]' +PS1+="\[\$(git_color)\]" # colors git status +PS1+="\$(git_branch)" # prints current branch +PS1+="\[$COLOR_BLUE\]\[$COLOR_RESET\]\$ " +export PS1 + +export LC_ALL=en_US.UTF-8 +export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx +alias ls="ls -Gp"