Change of background color when entering yay or pamac elevated mode

Hi, @napcok!

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?

Thanks again for such a great distro!

1 Like

Hi @lobaluna

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? :rofl:

Sometimes… if it works well, it’s better not to improve :wink:

1 Like

Wise words!

Well, it works perfectly, indeed. Since I copied the sudo function for pamac and yay, modifying accordingly, it’s perfectly readable.

When the next update for the ~/.bashrc comes in, I’ll see changes easier. That’s the way. I say no more.