vn-ansible/roles/debian/files/profile.sh

67 lines
1.2 KiB
Bash
Raw Normal View History

2025-02-04 20:03:36 +00:00
#!/bin/bash
# Prompt
FQDN=$(hostname --fqdn)
2025-02-05 13:33:44 +00:00
if [ -f "/etc/vn/env" ]; then
SHORT_HOST=${FQDN%.*.*}
if [ -z "$SHORT_HOST" ]; then
read -r SHORT_HOST < /etc/hostname
fi
2025-02-04 20:03:36 +00:00
2025-02-05 13:33:44 +00:00
read -r VN_ENV < /etc/vn/env
ENV_TEXT="$VN_ENV"
2025-02-05 13:33:44 +00:00
case "$VN_ENV" in
lab)
ENV_COLOR="\033[01;32m"
;;
pre)
ENV_COLOR="\033[01;35m"
;;
test)
ENV_COLOR="\033[01;33m"
2025-02-04 20:03:36 +00:00
;;
2025-02-05 13:33:44 +00:00
pro)
ENV_COLOR="\033[01;31m"
2025-02-04 20:03:36 +00:00
;;
*)
2025-02-05 13:33:44 +00:00
ENV_COLOR="\033[01;36m"
ENV_TEXT="${VN_ENV:0:3}"
2025-02-04 20:03:36 +00:00
;;
esac
2025-02-05 13:33:44 +00:00
if [ -z "$ENV_TEXT" ]; then
ENV_TEXT="???"
ENV_COLOR="\033[01;37m"
fi
ENV_TEXT="\[${ENV_COLOR}\]${ENV_TEXT^^}\[\033[00m\]"
2025-02-05 13:33:44 +00:00
PS1="\u@$SHORT_HOST[$ENV_TEXT]:\w"
2025-02-04 20:03:36 +00:00
if [ "$(id -u)" -eq 0 ]; then
PS1="$PS1# "
else
PS1="$PS1\$ "
fi
fi
# History
HISTSIZE=10000
HISTFILESIZE=50000
HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
# Security
TMOUT=3600
# Aliases
2025-02-05 13:33:44 +00:00
export LS_OPTIONS='--color=auto'
eval "$(dircolors)"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias la='ls $LS_OPTIONS -la'