type string using xdotool without being typed on screen twice (type selection of fzf)

Whenever anything is typed in to the terminal it is echoed. This is what are seeing. When bash restarts it sets the terminal to raw in order to handle all the special characters and editing etc, and so also turns off echo. It then reads what xdotool has typed, and dutifully echoes it.

You can get round this by turning off echo before running xdotool, eg:

.. fzf | (stty -F /dev/tty -echo; xargs -I{} xdotool type "{}"; stty -F /dev/tty echo)

Note, instead of xdotool, you can also use ioctl TIOCSTI. There are several C sources and perl scripts to do this. Here's one with the stty included:

#!/usr/bin/perl
# https://superuser.com/a/1663171/458747
use strict;
eval 'sub TIOCSTI () {0x5412;}' unless defined(&TIOCSTI);
system('stty -F /dev/tty -echo');
my $str;
if($#ARGV<0){ $str = join("",<STDIN>); } # read stdin if no args
else{ $str = join(" ",@ARGV); }
foreach my $ch (split('',$str)){
  ioctl(STDOUT, &TIOCSTI, $ch) or die $!;
}
system('stty -F /dev/tty echo');

If you put this in a file pushtype you can avoid the xargs and just ...fzf|pushtype.