From d3cbce8c2519b57520d445915180a18b000711b8 Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Thu, 19 Oct 2023 11:27:14 -0400 Subject: [PATCH] Allow bash to show info text --- configs/shells/bash/.bashrc | 3 +++ configs/shells/{zsh => bash}/info.sh | 18 ++++++++++++++---- configs/shells/zsh/.zshrc | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) rename configs/shells/{zsh => bash}/info.sh (57%) diff --git a/configs/shells/bash/.bashrc b/configs/shells/bash/.bashrc index 23bf9d4..2529451 100644 --- a/configs/shells/bash/.bashrc +++ b/configs/shells/bash/.bashrc @@ -4,6 +4,9 @@ export EWCONFIG_ROOT="$HOME/.config/ewconfig" # Load macros . $EWCONFIG_ROOT/configs/shells/bash/macros.sh +# Show some host info +. $EWCONFIG_ROOT/configs/shells/bash/info.sh + # I always want my ~/bin to be in my PATH export PATH="$HOME/bin:$PATH" export PATH="$EWCONFIG_ROOT/configs/scripts:$PATH" diff --git a/configs/shells/zsh/info.sh b/configs/shells/bash/info.sh similarity index 57% rename from configs/shells/zsh/info.sh rename to configs/shells/bash/info.sh index d17c368..dea0843 100644 --- a/configs/shells/zsh/info.sh +++ b/configs/shells/bash/info.sh @@ -1,16 +1,26 @@ +# Define red and green based on the shell +if [ -n "$BASH_VERSION" ]; then + red='\033[0;31m' + green='\033[0;32m' + reset_color='\033[0m' +elif [ -n "$ZSH_VERSION" ]; then + red="$fg[red]" + green="$fg[green]" +fi + # If `uname -s` is a BSD if [ $(uname -s | grep -c BSD) -gt 0 ]; then - echo "$fg[green]Platform:$reset_color $(uname -s) $(uname -r) $(uname -p)" + echo -e "${green}Platform:$reset_color $(uname -s) $(uname -r) $(uname -p)" else # Linux - echo "$fg[green]Platform:$reset_color $(uname -o) $(uname -r)" - echo "$fg[green]Uptime:$reset_color $(uptime -p)" + echo -e "${green}Platform:$reset_color $(uname -o) $(uname -r)" + echo -e "${green}Uptime:$reset_color $(uptime -p)" fi # Determine if $EWCONFIG_ROOT contains uncommitted changes if [ -d $EWCONFIG_ROOT/.git ]; then if [ -n "$(git -C $EWCONFIG_ROOT status --porcelain)" ]; then - echo "$fg[red]ewconfig contains uncommitted changes$reset_color" + echo -e "${red}ewconfig contains uncommitted changes$reset_color" fi fi diff --git a/configs/shells/zsh/.zshrc b/configs/shells/zsh/.zshrc index 6df5967..8e5f39f 100644 --- a/configs/shells/zsh/.zshrc +++ b/configs/shells/zsh/.zshrc @@ -14,7 +14,7 @@ if [ -f $EWCONFIG_ROOT/configs/zsh/by_host/$HOSTNAME.sh ]; then fi # Show some host info -. $EWCONFIG_ROOT/configs/shells/zsh/info.sh +. $EWCONFIG_ROOT/configs/shells/bash/info.sh # I always want my ~/bin to be in my PATH export PATH="$HOME/bin:$PATH"