59 lines
1.9 KiB
Bash
59 lines
1.9 KiB
Bash
# source IA
|
|
# check if is a scp connexion
|
|
is_scp() {
|
|
# If SSH_ORIGINAL_COMMAND is defined and contains "scp"
|
|
if [[ -n "$SSH_ORIGINAL_COMMAND" && "$SSH_ORIGINAL_COMMAND" == scp* ]]; then
|
|
return 0
|
|
fi
|
|
# if script name ($0) contains "scp"
|
|
if [[ "$0" == *scp* ]]; then
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
# source prompt color: https://robotmoon.com/bash-prompt-generator/^
|
|
if [ $(whoami) == "gilles" ]; then
|
|
#export PS1="\[\033[0;32m\][\[\033[1;94m\]\u\[\033[0;33m\]@\h \[\033[0;32m\]\W]# \[\033[0;37m\]"
|
|
export PS1="\[\e[38;5;216m\]\u\[\e[38;5;160m\]@\[\e[38;5;202m\]\h \[\e[38;5;131m\]\w \[\033[0m\]$ "
|
|
elif [ $(whoami) == "blutch" ]; then
|
|
export PS1="\[\033[0;32m\][\[\033[1;94m\]\u\[\033[0;33m\]@\h \[\033[0;32m\]\W]# \[\033[0;37m\]"
|
|
elif [ $(whoami) == "root" ]; then
|
|
export PS1="\[\033[0;32m\][\[\033[0;31m\]\u\[\033[0;31m\]@\h \[\033[0;32m\]\W]# \[\033[0;37m\]"
|
|
else
|
|
export PS1="[\u@\h \W]\$ "
|
|
fi
|
|
|
|
# Aliases
|
|
alias rm='rm -i'
|
|
alias cp='cp -i'
|
|
alias mv='mv -i'
|
|
alias ls='ls --color=auto'
|
|
alias sudo='sudo --preserve-env=PATH env' # https://www.petefreitag.com/blog/environment-variables-sudo/
|
|
|
|
if ! is_scp; then
|
|
if [[ "$USER" == "gilles" || "$USER" == "root" ]]; then
|
|
host_domain=$(cat /etc/hostname| rev | cut -d. -f1-2 | rev)
|
|
host_fqdn=$(hostname)
|
|
host_short=$(hostname -s)
|
|
ip=$(hostname -I)
|
|
dist=$(cat /etc/redhat-release)
|
|
kern=$(uname -r)
|
|
cat << EOF
|
|
---------------------------------------------------------
|
|
Host domain: $host_domain
|
|
Host name (fqdn): $host_fqdn
|
|
Host name (short): $host_short
|
|
Distribution: $dist
|
|
Kernel: $kern
|
|
----------------------------------------------------------
|
|
EOF
|
|
fi
|
|
fi
|
|
# execute only if user is gilles or root
|
|
#if [[ "$USER" == "gilles" || "$USER" == "root" ]]; then
|
|
# # display proxy status
|
|
# if [ -f "/usr/local/bin/proxyOnOff.sh" ]; then
|
|
# sudo /usr/local/bin/proxyOnOff.sh status
|
|
# fi
|
|
#fi |