When using the official VS Code Flatpak, configuring the integrated terminal to use your host system's shell often fails with errors like:
bash: cannot set terminal process group (-1): Not a tty
bash: no job control in this shell
This error is critical because it prevents bash from running with job control, which is a requirement for VS Code's powerful shell integration features (like command decorations, command history navigation, and run recent command). This guide provides a robust, definitive solution.
We will create a simple wrapper script on the host system that uses the standard Linux script utility. This utility's purpose is to create a new pseudo-terminal (PTY), which is exactly what bash needs to initialize correctly. This solves the "Not a tty" problem at its root.
First, we'll create a script on your host system (not inside the Flatpak).
-
Open your host terminal and create the file:
# Create the directory if it doesn't exist mkdir -p ~/.local/bin # Create the script file touch ~/.local/bin/vscode-host-shell.sh
-
Paste the following content into
~/.local/bin/vscode-host-shell.sh:#!/bin/bash # # This script uses the 'script' command to force the allocation of a new # pseudo-terminal (PTY). This solves the "Not a tty" and "no job control" # errors when spawning a host shell from within the VS Code Flatpak. # # -q : Runs in quiet mode (no start/end messages). # -c "..." : Specifies the command to run inside the PTY. # exec bash -l : Replaces the script process with a login bash shell. # /dev/null : The session "typescript" log file is discarded. exec script -q -c "exec bash -l" /dev/null
The script needs permission to be executed. In your host terminal, run:
chmod +x ~/.local/bin/vscode-host-shell.shFinally, tell VS Code to use this new script for its terminal profile.
-
In VS Code, open your user settings file by pressing
Ctrl + Shift + Pand searching forPreferences: Open User Settings (JSON). -
Add or update your
terminal.integrated.profiles.linuxconfiguration to look like this. Remember to replaceYOUR_USERNAMEwith your actual username on the host system.{ // Set the default profile to our new one "terminal.integrated.defaultProfile.linux": "Host Shell", // Define the new terminal profile "terminal.integrated.profiles.linux": { "Host Shell": { "path": "flatpak-spawn", "args": [ "--host", // IMPORTANT: Replace YOUR_USERNAME with your actual username "/home/YOUR_USERNAME/.local/bin/vscode-host-shell.sh" ] } }, // Ensure shell integration is enabled (usually default) "terminal.integrated.shellIntegration.enabled": true } -
Save the
settings.jsonfile. Now, when you open a new terminal in VS Code (`Ctrl + ``), it will launch a fully functional host shell with shell integration working perfectly! β