0

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.

3
  • You can't open a file just by typing its name. Try nano ~/.bash_profile. Commented Feb 17, 2016 at 17:27
  • If you don't have a .bash_profile, you need to create it. There might also be .profile, this is the generic name of the startup script. Commented Feb 17, 2016 at 17:27
  • .bash_profile isn't a program you run with arguments. It's a shell startup script that's run automatically when you login. You edit it to change what happens when you login, for instance to initialize environment variables needed by programs. Commented Feb 17, 2016 at 17:28

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the explanation

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.