From bcf859bb1ee7fa233d61c9e1bc3ace12797f5619 Mon Sep 17 00:00:00 2001 From: Martin Blazik Date: Fri, 15 Mar 2024 10:46:47 +0100 Subject: [PATCH] Set PS1 prompt --- rc/bash-prompt.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 rc/bash-prompt.sh diff --git a/rc/bash-prompt.sh b/rc/bash-prompt.sh new file mode 100644 index 0000000..967ed5f --- /dev/null +++ b/rc/bash-prompt.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +function get_color() +{ + local color="$1" + echo "\[$(tput setaf "$color")\]" +} + +readonly RED=$(get_color 1) +readonly GREEN=$(get_color 2) +readonly CYAN=$(get_color 6) +readonly END_COLOR='\[\033[00m\]' + +function get_ps1_prompt() +{ + local username='\u' + local hostname='\h' + local working_directory='\w' + local user_type='\$' + + echo "${debian_chroot:+($debian_chroot)}${GREEN}${username}@${hostname}${END_COLOR}:${CYAN}${working_directory}${END_COLOR}${user_type} " +} + +function set_ps1_prompt() +{ + PS1="$(get_ps1_prompt)" + export PS1 +} + +set_ps1_prompt