Skip to content

Instantly share code, notes, and snippets.

@Benjamin-Wegener
Created October 15, 2025 08:21
Show Gist options
  • Select an option

  • Save Benjamin-Wegener/7c496d8c4e2cf58fe9e400bfccf38552 to your computer and use it in GitHub Desktop.

Select an option

Save Benjamin-Wegener/7c496d8c4e2cf58fe9e400bfccf38552 to your computer and use it in GitHub Desktop.
Fix VS Code Flatpak Terminal: Get a Working Host Shell with TTY & Shell Integration

Fix VS Code Flatpak Terminal: Get a Working Host Shell with TTY & Shell Integration

The Problem

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.


The 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.

Step 1: Create the Host Shell Wrapper Script

First, we'll create a script on your host system (not inside the Flatpak).

  1. 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
  2. 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

Step 2: Make the Script Executable

The script needs permission to be executed. In your host terminal, run:

chmod +x ~/.local/bin/vscode-host-shell.sh

Step 3: Configure VS Code's settings.json

Finally, tell VS Code to use this new script for its terminal profile.

  1. In VS Code, open your user settings file by pressing Ctrl + Shift + P and searching for Preferences: Open User Settings (JSON).

  2. Add or update your terminal.integrated.profiles.linux configuration to look like this. Remember to replace YOUR_USERNAME with 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
    }
  3. Save the settings.json file. Now, when you open a new terminal in VS Code (`Ctrl + ``), it will launch a fully functional host shell with shell integration working perfectly! βœ…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment