Whenever I start a shell in vim using :sh, it doesn't source my ~/.bashrc file. How can I get it to do this automatically?
bashrc file is a script, and by sourcing it, you execute the commands placed in that file. The commands define aliases in your case, but there can be virtually any commands placed in that file.
bashrc File from the beginning, you can do so by pressing Ctrl+Alt+T or opening a new terminal tab, making it all more accessible. At each launch, Bash runs the contents of the . bashrc file to load your preferences. You can find this shell script in the home directory of users.
The quickest way to access it is nano ~/. bashrc from a terminal (replace nano with whatever you like to use). If this is not present in a user's home folder the system-wide . bashrc is used as a fallback as it is loaded before the user's file.
See :help 'shell'
. You can set this string to include -l
or --login
, which will source your .bashrc
file. So, you might have a line like this in your .vimrc
:
set shell=bash\ --login
Note that this will alter everything that invokes the shell, including :!
. This shouldn't be much of a problem, but you should be aware of it.
The value of this command can also be changed by setting the $SHELL
environment variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With