2

I have Git Bash running in my Windows Terminal, but I have trouble setting the background image, which is only visible in the right strip of the terminal window (it's cropped, not squished): image is almost not visible

At first, I thought Git Bash is outputting a black background that gets drawn over the image, but the gray background you see is set from Windows Terminal's settings and can be changed there to any color; so it chooses to draw the background color instead of the image?

  • I have tried deleting the color option altogether, but then the background is just black, except for the right strip of the image.
  • The image works correctly in PowerShell, with other images having the same effect - only the right strip is visible in Git Bash. I have tried different strech and position settings, but always only the right strip is visible.

How do I get Windows Terminal to render the image properly?

Windows Terminal settings:

// For documentation on these settings, see: https://aka.ms/terminal-documentation

{
  "$schema": "https://aka.ms/terminal-profiles-schema",

  "defaultProfile": "{e1001cad-b4fa-48a0-8617-0791feb59286}",

  // You can add more global application settings here.
  // To learn more about global settings, visit https://aka.ms/terminal-global-settings

  // If enabled, selections are automatically copied to your clipboard.
  "copyOnSelect": false,

  // If enabled, formatted data is also copied to your clipboard
  "copyFormatting": false,

  // Startup values
  //"startOnUserLogin": true,
  "initialCols": 240,
  "initialRows": 60,
  "confirmCloseAllTabs": false,
  "initialPosition": "20,15",


  // A profile specifies a command to execute paired with information about how it should look and feel.
  // Each one of them will appear in the 'New Tab' dropdown,
  //   and can be invoked from the commandline with `wt.exe -p xxx`
  // To learn more about profiles, visit https://aka.ms/terminal-profile-settings
  "profiles":
  {
    "defaults":
    {
      // Put settings here that you want to apply to all profiles.
    },
    "list":
    [
      {
        // Make changes here to the powershell.exe profile.
        "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
        "name": "Windows PowerShell",
        "commandline": "powershell.exe",
        "backgroundImage": "C:\\Users\\karel_hrkal\\Desktop\\hexmap-dark.png", 
        "hidden": false
      },
      {
        // Make changes here to the cmd.exe profile.
        "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
        "name": "Command Prompt",
        "commandline": "cmd.exe",
        "hidden": false
      },
      {
        "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
        "name": "Azure Cloud Shell",
        "source": "Windows.Terminal.Azure",
        "hidden": false
      },
      {
        "guid" : "{e1001cad-b4fa-48a0-8617-0791feb59286}",
        "name" : "Git Bash",
        "commandline" : "\"C:\\Programs\\Git\\bin\\bash.exe\" --login -i -l",
        "startingDirectory": "C:\\Projekty",
        "closeOnExit" : true,
        "colorScheme" : "Vintage",
        "cursorColor" : "#8080FF",
        "cursorShape" : "bar",
        "fontFace" : "Consolas",
        "fontSize" : 10,
        "antialiasingMode": "cleartype",
        "historySize" : 9001,
        "icon" : "C:\\Programs\\Git\\mingw64\\share\\git\\git-for-windows.ico",
        //"backgroundImage": "C:\\Users\\karel_hrkal\\Desktop\\hexmap.png",
        "backgroundImage": "C:\\Users\\karel_hrkal\\Desktop\\fantasy-landscape-mountains-waterfall-river-fantasy.png",
        "backgroundImageStretchMode": "uniform",
        "backgroundImageAlignment": "right",
        "padding" : "0, 0, 0, 0",
        "snapOnInput" : true,
        "useAcrylic" : false,
        "hidden": false
      }
    ]
  },

  // Add custom color schemes to this array.
  // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
  "schemes": [],

  // Add custom keybindings to this array.
  // To unbind a key combination from your defaults.json, set the command to "unbound".
  // To learn more about keybindings, visit https://aka.ms/terminal-keybindings
  "keybindings":
  [
    // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
    // These two lines additionally bind them to Ctrl+C and Ctrl+V.
    // To learn more about selection, visit https://aka.ms/terminal-selection
    { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
    { "command": "paste", "keys": "ctrl+v" },

    // Press Ctrl+Shift+F to open the search box
    { "command": "find", "keys": "ctrl+shift+f" },

    // Press Alt+Shift+D to open a new pane.
    // - "split": "auto" makes this pane open in the direction that provides the most surface area.
    // - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
    // To learn more about panes, visit https://aka.ms/terminal-panes
    { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
  ]
}

Git Bash prompt settings:

if test -f ~/.config/git/git-prompt.sh; then
  . ~/.config/git/git-prompt.sh
else
  PS1='\[\033]0;\W\007\]'       # set window title
  PS1="$PS1"'\n'                # new line
  PS1="$PS1"'\[\033[32m\]'      # change to green
  PS1="$PS1"'\u@\h '            # user@host<space>
  PS1="$PS1"'\[\033[33m\]'      # change to brownish yellow
  PS1="$PS1"'\w'                # current working directory

  if test -z "$WINELOADERNOEXEC"; then
    GIT_EXEC_PATH="$(git --exec-path 2>/dev/null)"
    COMPLETION_PATH="${GIT_EXEC_PATH%/libexec/git-core}"
    COMPLETION_PATH="${COMPLETION_PATH%/lib/git-core}"
    COMPLETION_PATH="$COMPLETION_PATH/share/git/completion"

    if test -f "$COMPLETION_PATH/git-prompt.sh"; then
      . "$COMPLETION_PATH/git-completion.bash"
      . "$COMPLETION_PATH/git-prompt.sh"
      PS1="$PS1"'\[\033[36m\]'  # change color to cyan
      PS1="$PS1"'`__git_ps1`'   # bash function
    fi
  fi

  PS1="$PS1"'\n'                # new line
  PS1="$PS1"'\[\033[1;31m\]'    # change color to red
  PS1="$PS1"'$ '                # prompt: always $
  PS1="$PS1"'\[\033[36m\]'      # change color to cyan //0 for white
fi

MSYS2_PS1="$PS1"                # for detection by MSYS2 SDK's bash.basrc

# Evaluate all user-specific Bash completion scripts (if any)
if test -z "$WINELOADERNOEXEC"; then
  for c in "$HOME"/bash_completion.d/*.bash; do
    # Handle absence of any scripts (or the folder) gracefully
    test ! -f "$c" ||
    . "$c"
  done
fi

1 Answer 1

2
+100

Remove the antialiasingMode property in settings.json.

Also, setting the backgroundImageStretchMode mode to either fit or uniformToFill is recommended to make the image actually fit to the full screen area proportionally instead of leaving bars at the sides:

"backgroundImageStretchMode": "fit"
3
  • Yes, that would make the image fit to screen instead of leaving bars at the sides
    – Someone
    Commented Aug 12, 2020 at 12:42
  • 1
    Fill will resize the image to the canvas of the Windows Terminal, meaning that stretching will be applied. Although it sounds just fine for non-proportional images like lines and shapes, with proportional ones, the setting will break the image. Meanwhile, fit (I don't know why it doesn't show up in the documentation) will just zoom the image to cover the whole screen, reserving the aspect and proportion of the image, even after the window got resized.
    – Someone
    Commented Aug 12, 2020 at 12:55
  • I'm not sure, since "fit" is not mentioned in any docs I've searched so far. So, after all, it might just be another name for uniformToFill, being a stretch mode in WPF and other products from Microsoft, making it seems convincing enough to me. But for now, I've tested both modes, and still haven't seen any difference between these two, so it's up to you to choose which one to stick with. Or just uniformToFill to match the reference.
    – Someone
    Commented Aug 12, 2020 at 13:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .