How to paste a tab into OS X Terminal from clipboard?

2

1

Tabs are getting removed from text that I paste into the Terminal. Any suggestions?

An example of my use case is to paste sections of TSV files into a remote ssh session terminal, bypassing the tedious multi-hop scp process.

This is not about using other editors/tools (e.g. emacs/vi) and I am already aware of how to enter a single tab char via CTL-Tab. These do not meet the need.

javadba

Posted 2013-12-12T03:05:41.100

Reputation: 2 201

For Ubuntu: http://superuser.com/questions/607410/how-to-copy-paste-tab-characters-via-the-clipboard-into-terminal-session-on-gnom

– Ciro Santilli 新疆改造中心法轮功六四事件 – 2015-06-09T11:04:43.523

I think we'll need more info than that about what you're doing. When I ssh into another computer, run cat >data.tsv, and then paste in tab-delimited data (followed by Control-D to terminate the file), it works as expected. You must be doing something that's different from this in some important way, but I have no idea what it is. – Gordon Davisson – 2013-12-14T02:01:47.090

Answers

0

In both linux and OS/x there does not appear to be a means to paste tabs into a terminal. If anyone (eventually) comes up with a solution please feel free to add the answer.

javadba

Posted 2013-12-12T03:05:41.100

Reputation: 2 201

2

If you just need to insert a tab, you can press control-v and tab.

To temporarily allow pasting tabs in bash, run:

bind '"\t":self-insert'

If you're pasting text to emacs, you can use a function like this instead of command-v:

(defun pbpaste ()
  (interactive)
  (shell-command-on-region
    (point)
    (if mark-active (mark) (point))
    "pbpaste" nil t))

Lri

Posted 2013-12-12T03:05:41.100

Reputation: 34 501

An example of my use case is to paste sections of TSV files into a remote ssh session terminal, bypassing the tedious multi-hop scp process. So this answer does not actually address my use case. – javadba – 2013-12-13T12:54:23.910

@javadba: In that case you should probably explain your use case in more detail. What sequence of ssh sessions, shells, etc are you trying to pass a tab through? Where is it going on the other end: into a file, into a shell, into stdin of some process, etc? – Gordon Davisson – 2013-12-13T15:33:48.533

@GordonDavisson updated the question – javadba – 2013-12-13T18:21:32.063

1

Sort of a workaround (at least in Linux)

  • v=$(cat)
  • then paste your text
  • then ctrl-D to close the 'cat' command
  • and there you have your text with tabs in $v, which you can output with echo "$v"

Daniel

Posted 2013-12-12T03:05:41.100

Reputation: 191

Maybe this works on *nix but i'm on macos where it does not. Will upvote anyways as an interesting idea – javadba – 2019-11-06T03:45:22.333