I have seen the code in ~/.bashrc regarding the change of background color for sudo, which is great!
I cloned it and modified it to use when entering yay and pamac. But since I’m not that savvy in bash tricks, I just duplicated the code for each command.
Is there some way to put brackets in the code and refactor it, so when entering sudo, yay or pamac, the ~/.bashrc reads only one chunk of code?
There are actually three similar functions in .bashrc that override su, sudo, and ssh.
I don’t think it’s possible to do what you’re thinking of - one piece of code for multiple commands. And even if it was possible, I wouldn’t do it. The readability of the scripts is also important, which I have painfully learned many times when returning after many months or years to my old overcombined scripts.
Also in Mabox, when I touch old scripts, sometimes my head really hurts before I understand what’s going on. Then I think to myself: What idiot wrote that?
Sometimes… if it works well, it’s better not to improve