Code change:
for (( i=0; i < "${#str}"; ++i )); do byte="${str:$i:1}" <del> # Escape backslashes, semi-colons specially, then special ASCII chars below space (0x20) </del> <ins> # Escape backslashes, semi-colons specially, then special ASCII chars below space (0x20). # This is done in an unwrapped loop instead of using printf as the latter is very slow. </ins> if [ "$byte" = "" ]; then token="" elif [ "$byte" = ";" ]; then token="x3b" <del> elif (( $(builtin printf '%d' "'$byte") < 31 )); then token=$(builtin printf 'x%02x' "'$byte") </del> <ins> elif [ "$byte" = $'x00' ]; then token="x00" elif [ "$byte" = $'x01' ]; then token="x01" elif [ "$byte" = $'x02' ]; then token="x02" elif [ "$byte" = $'x03' ]; then token="x03" elif [ "$byte" = $'x04' ]; then token="x04" elif [ "$byte" = $'x05' ]; then token="x05" elif [ "$byte" = $'x06' ]; then token="x06" elif [ "$byte" = $'x07' ]; then token="x07" elif [ "$byte" = $'x08' ]; then token="x08" elif [ "$byte" = $'x09' ]; then token="x09" elif [ "$byte" = $'x0a' ]; then token="x0a" elif [ "$byte" = $'x0b' ]; then token="x0b" elif [ "$byte" = $'x0c' ]; then token="x0c" elif [ "$byte" = $'x0d' ]; then token="x0d" elif [ "$byte" = $'x0e' ]; then token="x0e" elif [ "$byte" = $'x0f' ]; then token="x0f" elif [ "$byte" = $'x10' ]; then token="x10" elif [ "$byte" = $'x11' ]; then token="x11" elif [ "$byte" = $'x12' ]; then token="x12" elif [ "$byte" = $'x13' ]; then token="x13" elif [ "$byte" = $'x14' ]; then token="x14" elif [ "$byte" = $'x15' ]; then token="x15" elif [ "$byte" = $'x16' ]; then token="x16" elif [ "$byte" = $'x17' ]; then token="x17" elif [ "$byte" = $'x18' ]; then token="x18" elif [ "$byte" = $'x19' ]; then token="x19" elif [ "$byte" = $'x1a' ]; then token="x1a" elif [ "$byte" = $'x1b' ]; then token="x1b" elif [ "$byte" = $'x1c' ]; then token="x1c" elif [ "$byte" = $'x1d' ]; then token="x1d" elif [ "$byte" = $'x1e' ]; then token="x1e" elif [ "$byte" = $'x1f' ]; then token="x1f" </ins> else token="$byte" fi

Related discussion:
text: Apparently printf is just extremely slow on git bash
I had this terminal slowdown problem, in git bash, and found setting fixed the problem - the terminal was back to being fast. However, after the last, or recent, insiders update, even with that setting set to , the terminal is slow again - and it's showing the icons, etc. like it is ignoring this setting: ! !
you probably just didn't restart the terminal. This is now fixed and will come in the next Insiders and likely 1.90.1
Actually, I had the shell integration disabled for the last several insiders updates, so it has been off for a while. Terminal windows have been created and closed many time since. For whatever reason, when launching VSCode and the terminal session was restored, this last time, the integration feature was ignoring the flag. I terminated the terminal and started another, and the integration went away again. So basically the integration flag was ignored when the terminal session was restored. I just did a quick test of quitting VSCode, with a terminal window open, then relaunching, and the integration was still disabled. Unsure what happened. Guessing, also, you type-o-ed the version? I am already running 1.91.0 insider !
what happened was the terminal was restored which re-creates the process after vscode starts with the original environment, args, etc. No the next insiders build on Monday and v1.90.1 (stable)
when will be the next minor update, not the insider build so this terminal slowness is resolved?
FWIW, I can also observe the prompt's slowness on Linux (bash 5.1.16(1)-release on Ubuntu 22.04.4 LTS) on the order of a half-second or so (still annoying but bearable). looks like a temporary workaround for Git Bash only; will we fix the underlying cause of the slowness?
I also observe this to be slow over linux using an ssh remote. It's much slower if I have a starship prompt enabled (4s) and around 1s if I have the default debian prompt.
I have this issue (Win 10, git bash). The suggested workaround of disabling shell integration then restarting terminals worked for me.
Also having this problem. Disable terminal integration worked for me too. (Win 11, Git bash).