function sendShellScript(iTerm, folder) {
if (folder == null || folder == "") return
var shellScript = " cd " + quotedFormOf(folder) + " && clear && printf '\\e[3J'"
// loop for up to ~10s waiting for iTerm to be ready, in case it's just starting up
for (var attempt = 0; attempt < 100; attempt++) {
try {
iTerm.currentWindow.currentSession.write({ text: shellScript })