zypper pa --unneeded | grep '^i' | cut -d\| -f3 | xargs sudo zypper -n remove
zypper pa --unneededlists unneeded packages.grep '^i'selects lines that starts withi(installed package)cut d\| -f3selects third field after cutting line at delimited|- And the last one runs
sudo zypper -n removeon the output.
On older version of zypper, following script may be useful.
https://github.com/dilawar/Scripts/blob/master/zypper_autoremove.sh