So, keep in mind, the tab
character, Unicode U+0009 "CHARACTER TABULATION" (UTF-8/ASCII hex 09) is simply a regular character. One that is very annoying to deal with, yes. But it is not a 'control character'.
This is different what happens when you press the key on your keyboard labeled tab, which might be mapped to an escape sequence/control character like '\t', which is different.
The specific issue you encountered is indeed "fixed" in 10.4.1+. However, this still doesn't mean you're not going to encounter this or similar errors.
For example, take the sequence:
printf '\033[34mEscape!\033[00m\n'
And try copy/pasting it (or its output) into different shells. Also try setting the Terminal.app setting 'Escape Non-ASCII input with Control-V', or using control-command-V, "Paste Escaped Text". Kinda weird stuff, eh?
- Within a terminal, your best bet for most things is:
- Generally, never use the ⌘C and ⌘V shortcuts to access the clipboard.
- Instead, pipe to the
pbcopy
command, and then use pbpaste
as needed.
So, this would be git status | pbcopy
, and for some this you might want to copy, you might need to combine stderr and stdout: git error 2>&1 | pbcopy
will result in an empty clipboard without 2>&1
.
This still may strip out proper control characters (anything that isn't valid UTF-8). But as you mentioned, you're already aware of why you might not want to copy and paste these. If you're set on capturing "control characters" as well as text, what we're really talking about is just capturing a byte stream, so it is probably best to avoid the clipboard altogether, which has never had the functionality of reproducing arbitrary byte sequences.
P.S. Have you considered switching to iTerm2?