Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get vim's :sh command to source my bashrc?

Tags:

shell

vim

unix

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?

like image 506
Pierre-Antoine LaFayette Avatar asked Nov 07 '09 22:11

Pierre-Antoine LaFayette


People also ask

What is source bashrc command?

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.

How do I run a command in bashrc?

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.

How do I access bashrc?

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.


1 Answers

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.

like image 69
jheddings Avatar answered Sep 29 '22 00:09

jheddings