From 0927f43304cc0ad0869c79aad3159faf0e42f89d Mon Sep 17 00:00:00 2001 From: pgrondek Date: Wed, 10 Jul 2019 22:00:17 +0200 Subject: [PATCH] [bash] Switch to single file for computer type --- bashrc | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/bashrc b/bashrc index de0b2d5..ff0fcfa 100644 --- a/bashrc +++ b/bashrc @@ -2,8 +2,6 @@ # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples -SERVER_FLAG_FILE=/etc/.server -WORK_FLAG_FILE=/etc/.work # If not running interactively, don't do anything case $- in @@ -11,6 +9,12 @@ case $- in *) return;; esac +# defining computer type for shell coloring +TYPE_FILE=/etc/.computer-type +if [[ -f ${TYPE_FILE} ]]; then + computer_type=$(cat $TYPE_FILE) +fi + # don't put duplicate lines or lines starting with space in the history. # See bash(1) for more options HISTCONTROL=ignoreboth @@ -62,14 +66,19 @@ fi if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}' PS1="${PS1}\[\033[01;32m\]\u@" - if [ -f $SERVER_FLAG_FILE ]; then - PS1="${PS1}\[\033[34m\]\h" - fi - if [ -f $WORK_FLAG_FILE ]; then - PS1="${PS1}\[\033[33m\]\h" - else - PS1="${PS1}\[\033[32m\]\h" - fi + case $computer_type in + desktop) + PS1="${PS1}\[\033[32m\]\h" + ;; + server) + PS1="${PS1}\[\033[34m\]\h" + ;; + work) + PS1="${PS1}\[\033[33m\]\h" + ;; + *) + PS1="${PS1}\[\033[00m\]\h" + esac PS1="${PS1}\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ " else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '