zsh/zlogin

100 lines
2.6 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# /etc/zsh/zlogin ou ~/.zlogin
# Fichier de configuration de zsh, lu au lancement des shells de login
# Formation Debian GNU/Linux par Alexis de Lattre
# http://formation-debian.via.ecp.fr/
# Ce fichier contient les commandes qui s'exécutent quand l'utilisateur
# ouvre une console
# Afficher des informations sur le systèmes:
#echo "\n#### Info uname ####"
#uname -a
# Affiche l'uptime de la machine
#echo "\n#### uptime ####"
#uptime
# If a network connection is available (check function def in zshrc)
#if [$( is_network )] && [ $(command -v cowsay) ]; then
# Affiche un dessin (cf fonction définie dans zshrc)
bonjour
#fi
# Accepte les messages d'autres utilisateurs
mesg y
# Affichage le résultat de la commande 'mount' en colonne
#mount | column -t
# Pour les ordinateurs avec un pavé numérique...
# Active le pavé numérique quand on se loggue en console
#case "`tty`" in /dev/tty[1-6]*)
# setleds +num
#esac
## Génération du fichier ~/.ssh/config
if [ -f ~/.ssh/config_00base ]; then
rm -f ~/.ssh/config
cat ~/.ssh/config_* > ~/.ssh/config
chmod 0600 ~/.ssh/config*
fi
# List tmux sessions if tmux is available
if hash tmux; then
TMUX_SESSION=$(tmux ls 2> /dev/null|grep -- window)
# If tmux session available and if not already inside a tmux
if [ ${TMUX_SESSION} ] && [ -z "${TMUX}" ]; then
printf '%b' "${MAGENTA}++++++++++++++++++++++++ ${WHITEB}Tmux session${RESET} ${MAGENTA}:++++++++++++++++++++++++${RESET}\n"
tmux ls
fi
fi
# Recupere un caractere unique
getc ()
{
stty raw -echo
tmp=`dd bs=1 count=1 2>/dev/null`
eval $1='$tmp'
stty cooked
}
## Autorun an X session with some restrictions
## Set a ~/.noxorg file to work in tty only
# If non-root session
if [ ${USER} != "root" ] && [ $(command -v startx) ]; then
# If it's a VC console and
# no X session already launch and
# no ~/.noxorg file exist
if [ -z "${SSH_TTY}" ] && [ -z "$(pidof /usr/lib/xorg/Xorg)" ] && [ ! -f ~/.noxorg ];then
echo "Aucune session X11 détectée, voulez vous en lancer une ? [O|n]"
getc start_x
if [ `echo "$start_x" | grep "n"` ];then
echo "X11 ne sera pas lancé."
else
`startx -- :1 vt1`
fi
fi
fi
# Keychain {{{
## TODO: user must be able to see ssh-agent process
## Be careful with hidepid!
if [ -f $HOME/.ssh/id_rsa ]; then
eval $(keychain --eval --quiet --agents ssh id_rsa)
fi
if [ -f $HOME/.ssh/id_ed25519 ]; then
eval $(keychain --eval --quiet --agents ssh id_ed25519)
fi
# }}}
# GPG Agent
if [ -f $HOME/.gnupg/secring.gpg ]; then
# Keychain
## Don't ask for gpg password, it will be asked at the first usage
keychain --noask --agents gpg
. $HOME/.keychain/$HOST-sh-gpg
fi