Maaz Ahmad Khan
Maaz Ahmad Khan

Reputation: 172

open integrated terminal of vs code in current working directory in linux mint

I switched from Windows to linux mint recently. This feature of opening terminal in cwd was working fine in windows. I also used sync to export all my settings to linux mint.

But for some reason, linux bash is not opening in cwd. Its been bugging me a lot and I don't know if it's an issue within my settings or an issue with VS code itself.

Upvotes: 0

Views: 386

Answers (2)

user14913400
user14913400

Reputation: 32

As OP has noted, vscode is conflicting with bash's behaviour, but it is not necessary to give up your bash default cwd (current working directory).

Simply check whether the terminal is launched by vscode and based on that set the default cwd:

# ~/.bashrc
if [[ "$TERM_PROGRAM" != "vscode" ]]; then
    cd /default-path
fi

now bash will have the /default-path as its default cwd and vscode will keep its own project directory.

Upvotes: 0

Maaz Ahmad Khan
Maaz Ahmad Khan

Reputation: 172

Ok, I suspected that I had set a default directory for my linux bash so that whenever I opened a new terminal it would open in a default directory.

That was conflicting with VS code's default behaviour.

To fix :

  1. open a new terminal and at root, run $ code ~/.bashrc

  2. search for your default directory it looked like this: $ cd directory-name

  3. simply remove this line, save and close this file.

  4. reload VS code and voila

Upvotes: 1

Related Questions