zsh/zlogin

95 lines
2.7 KiB
Plaintext
Raw Normal View History

2014-08-17 22:54:05 +02:00
# /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)
2019-07-04 17:47:41 +02:00
#if [$( is_network )] && [ $(command -v cowsay) ]; then
# Affiche un dessin (cf fonction définie dans zshrc)
2019-07-04 17:47:41 +02:00
bonjour
#fi
2014-08-17 22:54:05 +02:00
# Accepte les messages d'autres utilisateurs
mesg y
# Affichage le résultat de la commande 'mount' en colonne
#mount | column -t
2014-08-17 22:54:05 +02:00
# 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
# List tmux sessions if tmux is available
if [ $(command -v tmux) ]; then
2021-09-21 22:01:31 +02:00
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
2021-09-21 22:01:31 +02:00
# ssh-agent with fix socket path
## See load-ssh-agent function in ~/.zsh/zshrc
load-ssh-agent
2014-08-17 22:54:05 +02:00
# Recupere un caractere unique
getc ()
{
2021-09-21 22:01:31 +02:00
stty raw -echo
tmp=`dd bs=1 count=1 2>/dev/null`
eval $1='$tmp'
stty cooked
2014-08-17 22:54:05 +02:00
}
2023-11-28 17:11:31 +01:00
## Autorun an X session with some restrictions for Debian {{{
## Set a ~/.noxorg file to work in tty only
# If non-root session
2023-11-28 17:11:31 +01:00
if [ -f /etc/debian_version ] && [ ${USER} != "root" ] && [ $(command -v startx) ]; then
2021-09-21 22:01:31 +02:00
# If it's a VC console and
# no X session already launch and
# no ~/.noxorg file exist
if [ -z "${SSH_TTY}" ] &&
[ ! -f "${HOME}/.noxorg" ] &&
2023-08-30 17:23:42 +02:00
! pgrep --full -- "/usr/lib/xorg/Xorg|/usr/lib/Xorg" ; then
2019-06-19 22:35:37 +02:00
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
2014-08-17 22:54:05 +02:00
fi
2023-11-28 17:11:31 +01:00
## }}}
## Autorun an X session with some restrictions for Archlinux {{{
## Set a ~/.noxorg file to work in tty only
# If non-root session
if [ -f /etc/arch-release ] && [ ${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}" ] &&
[ ! -f "${HOME}/.noxorg" ] &&
! pgrep --full -- "/usr/lib/xorg/Xorg|/usr/lib/Xorg" ; then
echo "No X11 session detected, starting a new one…"
`startx -- :1 vt1`
else
2023-11-28 17:16:54 +01:00
#echo "Not in a VC console, ~/.noxorg file exists or Xorg already running…"
2023-11-28 17:11:31 +01:00
fi
fi
## }}}