At my company there are system-wide bashrc files like /etc/bashrc and so on.
Inside, they source more and more files. It's very confusing (I noticed my "ls" is aliased with a bunch of flags to ls that I don't want).
I want to for my ~/.bashrc clear the effects of all bashrcs.
Is there something like that in bash? Just to clear all aliases, functions, etc, defined in system-wide files.
1 Answer
The easiest way would be to add this line to your ~/.bashrc :
unalias -aAs far as I know, there is no equivalent for clearing all functions. You can, however, clear them one by one using
unset -f function_nameThe following two bash options are also relevant:
--rcfile file Execute commands from file instead of the system wide initialization file /etc/bash.bashrc and the standard personal initialization file ~/.bashrc if the shell is interactive (see INVOCATION below). --norc Do not read and execute the system wide initialization file /etc/bash.bashrc and the personal initialization file ~/.bashrc if the shell is interactive. This option is on by default if the shell is invoked as sh.So, you could set bash to be an alias for bash --norc:
alias bash='/bin/bash --norc'That way, every time you manually launch bash a new shell will be started with no initialization files. You would then need to manually source your .bashrc.
I thought you could combine the --norc and --rcfile options to read your ~/.bashrc only but could not get it to work.