I did so, right now.You would have to write something yourself.
#!/bin/csh
if ( "$1" == "-y" ) then
set forceYes = True
endif
# Get date to look out for the .serverauth dotfile not to be deleted
set date = `date +'%b %d'`
if ( "$status" != 0 ) then
echo "Couldn't get date."
exit 1
endif
# Get current directory to check
set cwd = `pwd`
if ( "$status" != 0 ) then
echo "Couldn't get current working directory."
exit 1
endif
# Check if one is in $HOME as Xorg .serverauth dotfiles are located in $HOME.
if ! ( "$cwd" == "$HOME" || "$cwd" == "/usr$HOME" ) then
echo "Oh no, you aren't in your home."
exit 1
endif
# Find .serverauth dotfiles.
set dotfiles = ( `find . -type f -name ".serverauth*"` )
if ( "$status" != 0 ) then
echo "Couldn't check for dotfiles."
exit 1
else
foreach file ( $dotfiles:q )
set dateOfFile = `ls -l "$file:q" | awk '{print $6,$7}'`
if ( "$status" != 0 ) then
echo "Couldn't get date of $file:q"
exit 1
endif
if ( "$dateOfFile" == "" ) then
echo "Couldn't get date of .serverauth file."
exit 1
endif
if ( "$dateOfFile" != "$date" ) then
echo "$file:q is not from today but $dateOfFile."
else
if ( -f "$file:q" ) then
set ignorefile = `echo $file:q | cut -c 3-`
endif
endif
end
endif
# Find .serverauth files and delete except ignored one which is current today's serverauth file.
if ( "$?ignorefile" ) then
if ( "$?forceYes" ) then
set rmfile = `find . -type f -name ".serverauth*" -not -name "$ignorefile" -exec rm -fv {} \;`
else
set rmfile = `find . -type f -name ".serverauth*" -not -name "$ignorefile" -exec rm -iv {} \;`
endif
else
if ( "$?forceYes" ) then
set rmfile = `find . -type f -name ".serverauth*" -exec rm -fv {} \;`
else
set rmfile = `find . -type f -name ".serverauth*" -exec rm -iv {} \;`
endif
endif
if ( "$status" != 0 ) then
echo "Couldn't delete .serverauth files."
exit 1
endif
freebsd:~
% touch -d "2024-05-21T16:31:52" .serverauth.1238
freebsd:~
% touch -d "2024-05-22T16:31:52" .serverauth.1239
freebsd:~
% touch -d "2024-05-20T16:31:52" .serverauth.1237
freebsd:~
% clear-serverauth
./.serverauth.1238 is not from today but May 21, can delete it.
./.serverauth.1239 is not from today but May 22, can delete it.
./.serverauth.1237 is not from today but May 20, can delete it.
remove ./.serverauth.1238? n
remove ./.serverauth.1239? n
remove ./.serverauth.1237? n
freebsd:~
% clear-serverauth -y
./.serverauth.1238 is not from today but May 21, deleted.
./.serverauth.1239 is not from today but May 22, deleted.
./.serverauth.1237 is not from today but May 20, deleted.
freebsd:~
% ls -lah .serverauth*
-rw------- 1 yusuf yusuf 156B Jun 22 00:17 .serverauth.43065
if ( -x "$HOME/doc/scripts/clear-serverauth" ) $HOME/doc/scripts/clear-serverauth -y
to ~/.login and it works!