First of all, we should find a way to relax ourselves, such as doing yoga or running every day and doing some physical exercise, which can make us forget all the unpleasant things, immerse ourselves in our own lives, stop thinking about trivial things, and let our troubles completely calm down, which will help us relax our pressure, ease our emotions and stop letting our temper come out casually.
Another is that you can give some psychological hints. When you want to lose your temper, you can count from one to ten and give yourself a buffer time. Give yourself a psychological hint, I can control my temper, I can't lose my temper, so my temper can be effectively buffered, and then you may not want to lose your temper.
Finally, I think there is another way, that is, you can find something to replace when you want to lose your temper. For example, if you lose your temper in your bag, you can immediately go out for a run or find someone to tell you a series of things, which can effectively divert your attention. I think this is also a very good thing. In short, there are many ways to control your temper, but it depends on your perseverance.