Winnemucca
Winnemucca

Reputation: 3458

cannot get ~/.bash_profile

I am attempting to set up vs code on my work computer. When I run

~/.bash_profile

I get no such directory.

the ~/. works fine.

I am seeing an issue with bash_profile. Not sure how to fix it. I tried a couple of other pasts on stack overflow I found, but at this point do not want to do that anymore as I do not know fully know what is happening

/.bash_profile "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

I can set up vs code in my terminal without it, but the changes that I make will not save and vs code will not open code . . When I work from a new terminal.

Upvotes: 0

Views: 3584

Answers (1)

assefamaru
assefamaru

Reputation: 2789

First of all, .bash_profile is not a directory or a program, but rather a hidden file that is executed by the command interpreter for login shells.

Assuming you are using Mac OS X, you can place the following line in your .bash_profile file:

function code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $*; }

If the file does not exist, you can simply create it, open the file and add the line above as follows:

touch ~/.bash_profile
nano ~/.bash_profile
# paste the line above
# press Ctrl-X to exit, press 'Y' for yes, and Enter to save.

If you want to do the above in one line, simply do:

echo "function code () { VSCODE_CWD=\"$PWD\" open -n -b \"com.microsoft.VSCode\" --args $*; }" >> ~/.bash_profile

Using >> ensures that contents in .bash_profile don't get destroyed during redirection if file exists. If file does not exist, a new file will be created.

Then restart your terminal, or type source ~/.bash_profile, and you should be able to run VS Code.

Upvotes: 2

Related Questions