How to check if a shell script/Vim is running in the VS Code integrated terminal?


yongjieyongjie

question

The problem is as stated in the title.

Essentially, I'm trying to get my bash script and Vim to behave differently when run in VS Code's integrated terminal.

what i found

I managed to find several other Stack Overflow questions, but they are related to OS detection:
- How to check if running in Cygwin, Mac or Linux?
- How to detect OS from Bash script?

etc

You can see it's set by checking the shell variable in the vscode terminal TERM_PROGRAM=vscode. In my .bash_profile I have the following and it works fine:

if [ "$TERM_PROGRAM" == "vscode" ]; then
    # some stuff
else
    # other stuff
fi

Related


Node is not running in the integrated terminal in VS Code

cookies I have node js installed. It works in powershell, cmd but not in vs code. node : The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify t

Bash terminal colors in integrated terminal in VS Code

Ian Shirley I'm on a Windows 10 machine and recently installed VS Code instead of Sublime Text3. I changed the integrated terminal in VS Code to default to git Bash. This works great now, but I seem to be losing the color coding of files and directories. I tri

Bash terminal colors in integrated terminal in VS Code

Ian Shirley I'm on a Windows 10 machine and recently installed VS Code instead of Sublime Text3. I changed the integrated terminal in VS Code to default to git Bash. This works great now, but I seem to be losing the color coding of files and directories. I tri

Bash terminal colors in integrated terminal in VS Code

Ian Shirley I'm on a Windows 10 machine and recently installed VS Code instead of Sublime Text3. I changed the integrated terminal in VS Code to default to git Bash. This works great now, but I seem to be losing the color coding of files and directories. I tri

Bash terminal colors in integrated terminal in VS Code

Ian Shirley I'm on a Windows 10 machine and recently installed VS Code instead of Sublime Text3. I changed the integrated terminal in VS Code to default to git Bash. This works great now, but I seem to be losing the color coding of files and directories. I tri

Bash terminal colors in integrated terminal in VS Code

Ian Shirley I'm on a Windows 10 machine and recently installed VS Code instead of Sublime Text3. I changed the integrated terminal in VS Code to default to git Bash. This works great now, but I seem to be losing the color coding of files and directories. I tri

How do I type in the integrated terminal on VS Code in Windows?

Kevin C. Cucumber In Linux, I can type in the integrated terminal, no problem. I can enter user input and it will output. On Windows, I can't do this. The output shows up in the debug console, and I can't type in that console or the integrated terminal. In the

How to copy all text from the integrated vs code terminal?

Beko Is there a way to copy all text from the integrated Visual Studio Code terminal? I have some output that I want to copy to a text file and save. mark I can right-click on the terminal Select All, then select , then right-click and Copy. doesn't that work

How to copy all text from the integrated vs code terminal?

Beko Is there a way to copy all text from the integrated Visual Studio Code terminal? I have some output that I want to copy to a text file and save. mark I can right-click on the terminal Select All, then select , then right-click and Copy. doesn't that work

How do I type in the integrated terminal on VS Code in Windows?

Kevin C. Cucumber In Linux, I can type in the integrated terminal, no problem. I can enter user input and it will output. On Windows, I can't do this. The output shows up in the debug console, and I can't type in that console or the integrated terminal. In the

How to copy all text from the integrated vs code terminal?

Beko Is there a way to copy all text from the integrated Visual Studio Code terminal? I have some output that I want to copy to a text file and save. mark I can right-click on the terminal Select All, then select , then right-click and Copy. doesn't that work

How do I type in the integrated terminal on VS Code in Windows?

Kevin C. Cucumber In Linux, I can type in the integrated terminal, no problem. I can enter user input and it will output. On Windows, I can't do this. The output shows up in the debug console, and I can't type in that console or the integrated terminal. In the

How to copy all text from the integrated vs code terminal?

Beko Is there a way to copy all text from the integrated Visual Studio Code terminal? I have some output that I want to copy to a text file and save. mark I can right-click on the terminal Select All, then select , then right-click and Copy. doesn't that work

How to copy all text from the integrated vs code terminal?

Beko Is there a way to copy all text from the integrated Visual Studio Code terminal? I have some output that I want to copy to a text file and save. mark I can right-click on the terminal Select All, then select , then right-click and Copy. doesn't that work

How to use CMDR as default integrated terminal for vs code

vajad57 I want to use CMDR as VS Code default integrated terminal. I am in mysettings.json "terminal.integrated.shell.windows": "C:\\Windows\\system32\\cmd.exe", "terminal.integrated.shellArgs.windows": [ "/k %CMDER_ROOT%\\vendor\\init.bat" ], It was work

How do I type in the integrated terminal on VS Code in Windows?

Kevin C. Cucumber In Linux, I can type in the integrated terminal, no problem. I can enter user input and it will output. On Windows, I can't do this. The output shows up in the debug console, and I can't type in that console or the integrated terminal. In the

How do I type in the integrated terminal on VS Code in Windows?

Kevin C. Cucumber In Linux, I can type in the integrated terminal, no problem. I can enter user input and it will output. On Windows, I can't do this. The output shows up in the debug console, and I can't type in that console or the integrated terminal. In the

How to copy all text from the integrated vs code terminal?

Beko Is there a way to copy all text from the integrated Visual Studio Code terminal? I have some output that I want to copy to a text file and save. mark I can right-click on the terminal Select All, then select , then right-click and Copy. doesn't that work

How to copy all text from the integrated vs code terminal?

Beko Is there a way to copy all text from the integrated Visual Studio Code terminal? I have some output that I want to copy to a text file and save. mark I can right-click on the terminal Select All, then select , then right-click and Copy. doesn't that work

How do I type in the integrated terminal on VS Code in Windows?

Kevin C. Cucumber In Linux, I can type in the integrated terminal, no problem. I can enter user input and it will output. On Windows, I can't do this. The output shows up in the debug console, and I can't type in that console or the integrated terminal. In the