I would like the variable NUSERS='who | wc -l'
to be updated every 2 seconds in order to display the number of connected users in the prompt with PS1='\u@\h-${NUSERS}:\w $'
defined in the .bashrc
file.
I tryed: watch NUSERS='who | wc -l' &>/dev/null &
in the .bashrc
... it didn't work
I tryed: while true; do NUSERS='who | wc -l' && sleep 2; done &
in the .bashrc
... it didn't work neither
I don't understand why this doesn't work. I would like to avoid screen and nohup because I don't want the command to run when I exit the ssh session.
actually, it is possible to insert a command directly in the PS1
variable declaration in the .bashrc
file
PS1='\u@\h-`who | wc -l`:\w $'