Dasmowenator
Dasmowenator

Reputation: 5448

Paste into SSH terminal capitalizes last character and doesn't allow me to edit it

I'm running Terminal on my Mac and SSH'ing into a Linux host. When I paste text, it will often capitalize the last character of whatever I'm pasting, and the cursor will turn gray and I won't be able to type additional characters or delete characters from whatever I pasted. My only two options at that point are to either ^C to break onto the next line without running the command, or hit enter and run the messed up command.

It doesn't happen 100% of the time. If I copy something and then repeatedly paste it into the shell, I'll see this issue occur about 50% of the time. I have no idea why it's apparently non-deterministic like this. I thought this might also be due to "bracketed paste" issues, but no matter how many times I run the commands printf '\e[?2004l' and set enable-bracketed-paste off, the issue persists. It even persists when I exit and re-SSH to the host with a fresh SSH session, so I know it's not due to some sort of leftover bad state in the SSH session. Can someone please help??? This is killing my productivity!

Here's an example of what the pasted text looks like when the issue occurs:

Paste with issue

(The text I was trying to paste was ParameterKey=Stage with a lowercase e at the end)

I'm aware that other questions have been asked along these lines, like this one from Stack Exchange, but none of the answers on any of these posts have worked for me, so I think my problem may be slightly different than those...

Upvotes: 16

Views: 2736

Answers (2)

bbaassssiiee
bbaassssiiee

Reputation: 6802

Your keybindings are not working for you. You might have tried customizations with Oh My Zsh or not, but anyway bindkey commands mess up your workflow with Terminal.

You can start all over again configuring your zsh environment with rm ~/.zshrc.

Then when you start zsh again (by logging in), you'll see:

This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~).  This function can help you with a few settings that should
make your use of the shell easier.

You can:

(q)  Quit and do nothing.  The function will be run again next time.

(0)  Exit, creating the file ~/.zshrc containing just a comment.
     That will prevent this function being run again.

(1)  Continue to the main menu.

Select this sequence of choices to have the following line configured in your new ~/.zshrc: 1, 3, 1, e, 0, 0

bindkey -e

Upvotes: 0

x3l51
x3l51

Reputation: 731

Check your ZSH config

cat ~/.zshrc

Check if in plugins=(...) you find safe-paste. If it's there, edit the config and delete safe-paste.

if grep -q "safe-paste" "~/.zshrc"; then   # checks if str in contained in file
    sed -e s/safe-paste//g -i ~/.zshrc     # if so, it replaces the str with nothing
fi

As a one liner:

if grep -q "safe-paste" "~/.zshrc"; then; sed -e s/safe-paste//g -i ~/.zshrc; fi

Upvotes: 0

Related Questions