Bash – How to source the bashrc file every time I ‘clear’

bashbashrc

This might be a bad idea. The more I think about it the more I come to the realization that I probably shouldn't do it… but I've been trying and failing so I REALLY want to know how to do it, even if it's a bad idea.

What I want is for the bashrc file to be sourced every time I run the clear command. The reason for this is completely materialistic. I have system information echoed out when I source bashrc and it's cool to me and I'd like that to be at the top every time I clear.
I've tried to set up some aliases for clear but I keep running into infinite loops. The obvious fix is to change the aliases to something else besides clear so that I can run the clear command in the alias without interfering but I type clear so often that it's kind of ingrained in my brain at this point. I'd like to be able to type clear and make it clear AND source the bashrc file.

Best Answer

alias clear='source ~/.bashrc; \clear'

The \ tells bash that you want to invoke the external command, not the alias.