loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
For more details see:
https://scriptingosx.com/2019/09/get-current-user-in-shell-scripts-on-macos/
loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
For more details see:
https://scriptingosx.com/2019/09/get-current-user-in-shell-scripts-on-macos/