How do i preserve .bashrc my Qubes?

I customized my .bashrc file in the template Qubes for Fedora & Debian, But i’ve noticed that each Qube regardless of template has its own separate /home contents. how do i make it so my .bashrc file specifically is preserved across all Qubes made from the template in question?

Read the docs

qubes do not inherit from /home/user in the template.
At the time of creation, /home/user in the qube is populated from /etc/skel in the
template.
After that, each qube has its own /home/user

If you have already created the qubes, you must copy the file between
them.

That being said could one not just modify the .bashrc in /etc/skel to my preference or is that generally not a good idea?

Just make your ~/.bashrc source /etc/bashrc and then centrally manage /etc/bashrc in your template.

In your template, place your global custom changes to bash in /etc/profile.d/custom.sh.
Don’t use ~/.bashrc.

References:

From man bash, section Invocation;
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists.
The last few lines of /etc/profile are a conditional clause to open /etc/bashrc and check for double sourcing:

        if [ -f /etc/bashrc ] ; then
                # Bash login shells run only /etc/profile
                # Bash non-login shells run only /etc/bashrc
                # Check for double sourcing is done in /etc/bashrc.
                . /etc/bashrc
       fi
...

From /etc/bashrc:

“It’s NOT a good idea to change this file unless you know what you
are doing. It’s much better to create a custom.sh shell script in
/etc/profile.d/ to make custom changes to your environment, as this
will prevent the need for merging in future updates.”

Testing:

As a test, create /etc/profile.d/custom.sh in the template.
Start by opening a terminal in the template:
[user@dom0~] qvm-run -a <Template_VM> gnome-terminal
might need to use xfce4-terminal if gnome-terminal returns a 127 error.
Open an editor within sudo:
[user@Template_VM] sudo vi /etc/profile.c/custom.sh
Enter:
i
to start input mode, then enter:
alias svim='sudo -E vim'
Save and exit the editor:
:wq
Reboot all VMs based on the template.
Open a terminal window in a VM based on the template:
[user@dom0] qvm-run -a <AppVM> gnome-terminal
[user@AppVM] cd /etc/profile.d/
[user@AppVM] svim custom.sh
The file should open within vim with super user rights.
Exit the vim editor
:q
Exit the terminal window:
[user@AppVM] exit

1 Like