[bash] Switch to single file for computer type

This commit is contained in:
pgrondek 2019-07-10 22:00:17 +02:00
parent 26dcae257d
commit 0927f43304

29
bashrc
View File

@ -2,8 +2,6 @@
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples # for examples
SERVER_FLAG_FILE=/etc/.server
WORK_FLAG_FILE=/etc/.work
# If not running interactively, don't do anything # If not running interactively, don't do anything
case $- in case $- in
@ -11,6 +9,12 @@ case $- in
*) return;; *) return;;
esac 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. # don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options # See bash(1) for more options
HISTCONTROL=ignoreboth HISTCONTROL=ignoreboth
@ -62,14 +66,19 @@ fi
if [ "$color_prompt" = yes ]; then if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}' PS1='${debian_chroot:+($debian_chroot)}'
PS1="${PS1}\[\033[01;32m\]\u@" PS1="${PS1}\[\033[01;32m\]\u@"
if [ -f $SERVER_FLAG_FILE ]; then case $computer_type in
PS1="${PS1}\[\033[34m\]\h" desktop)
fi PS1="${PS1}\[\033[32m\]\h"
if [ -f $WORK_FLAG_FILE ]; then ;;
PS1="${PS1}\[\033[33m\]\h" server)
else PS1="${PS1}\[\033[34m\]\h"
PS1="${PS1}\[\033[32m\]\h" ;;
fi work)
PS1="${PS1}\[\033[33m\]\h"
;;
*)
PS1="${PS1}\[\033[00m\]\h"
esac
PS1="${PS1}\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ " PS1="${PS1}\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
else else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '