change gmo-cfg.sh

This commit is contained in:
Gilles Mouchet 2024-06-01 09:21:00 +02:00
parent c0c2e4200a
commit b20224c084

View File

@ -1,3 +1,17 @@
# 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\]"
@ -17,13 +31,16 @@ 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 [[ "$USER" == "gilles" || "$USER" == "root" ]]; then
if [ ! is_scp ]; then
if [[ "$USER" == "gilles" || "$USER" == "root" ]]; then
dist=$(cat /etc/redhat-release)
kern=$(uname -r)
cat << EOF
Distribution: $dist
Kernel: $kern
EOF
fi
fi
# execute only if user is gilles or root
#if [[ "$USER" == "gilles" || "$USER" == "root" ]]; then