When using a small fish function I’ve cobbled together (not a developer here, so please be gentle … 😌) for accessing a number of regularly needed ssh hosts, I’m seeing a strange effect: The bracket paste mode get’s activated for the ssh session.
This is the script:
function mssh
set hosts host1 host2 host3 hostn
set domain mydomain.com
set user myusername
set number (count $hosts)
set numlength (string length $number)
echo
echo "Hosts:"
echo
for i in (seq $number)
if test (string length "$i") -lt "$numlength"
echo \t" "$i")" $hosts[$i]
else
echo \t$i")" $hosts[$i]
end
end
echo
while read --nchars $numlength -l response --prompt-str="Please select: "; or return 1
if test "$response" -le "$number" 2>/dev/null
ssh $user@$hosts[$response].$domain
break
else
echo "Invalid selection"
continue
end
end
end
With that, just for context, I was basically trying to reproduce the functionality of this zsh script (that I got from somewhere):
#!/bin/zsh
hosts=(host1 host2 host3)
domain="mydomain.com"
user="username"
PS3='Select: '
select host in ${hosts[@]}
do
if [ "$host" = "" ]; then
echo "Invalid selection."
else
ssh ${user}@${host}.${domain}
break
fi
done
But as I mentioned at the beginning my own script seems to be be somewhat erroneous at using it turns on fish’s bracket paste mode for the ssh session and everything I paste get’s wrapped in tilde characters (~paste example~
).
It happens both in iTermin2 and the macOS terminal client.
It does not happen with the zsh script (or when I just call ssh directly).
Any pointers as to where I went wrong are welcome. Thanks in advance.