Tilde sign in Terminal (Mac)

Hello

How do I get the Tilde-sign ~ in the Terminal? Using Mac (can’t copy and paste).

How is this ROS related topic? Key combination for such character can depend on keyboard layout for specific language or you can get tilde in other apps on text input, like TextEdit, but you cannot in Terminal? Anyway, this is macOS topic for some other forum, I’m using macOS and I don’t have such issue, can get that character (directly from keyboard or c/p) in Terminal generally, in ROS shell over ssh, in WinBox terminal using wine…
Open Keyboard Viewer and if you cannot see that character on virtual keyboard press shift, ctrl, option(alt), cmd keys standalone on in different combinations until you see which key you need to press in such combination to get it if that’s the case.

As I can get it in regular text such as Safari or Notes somebody might know a trick to do it in Terminal? The combo for making that sign doesn’t work in Terminal.
Need to use that sign so just wanted to know how?!

Hold on… Are we talking about tilde as diacritic? e.g. Ñ ã õ ñ etc unicode chars VS a plain ~ char?

There is no unicode support in winbox’s Terminal — so it will not let you enter accented chars. It will store and display them in comments, but you can’t enter them from the Terminal window. Only via SSH to router will the option-N + char work, only for comment= lines.

As I understand it is plain ~, for me it’s same combination in any app for selected keyboard layout. Maybe it’s something in Terminal Settings to set, if it’s ~ in combination with Option key and there is Terminal Settings option in Keyboard tab “Use Option as Meta key”, if checked it will not work, but still c/p should work anyway.
Or maybe it is Unicode tilde (∼)? - looks similar but it cannot be entered or c/p in non unicode text encoding Terminal and even if you configure (Mac, not WinBox) Terminal to accept unicode characters (Text encoding in Advanced settings) still ti will not work in ROS shell over it (eg. over ssh) as @Amm0 mentioned.
You can check if that character for your kb layout is generated in unicode or not, save file with that single character in it and execute in Mac Terminal:

$ xxd <file>

if output is with 3 bytes (0xE2, 0x88, 0xBC), then is unicode:

00000000: e288 bc                                  ...

if is single byte (0x7E), then is plain ascii:

00000000: 7e                                       ~

If is unicode then you will need to switch kb layout which generates ascii if you want to input it directly from kb, or you will need to c/p ascii character from some text or character viewer.
If is ascii, can’t tell what could be reason why is not displayed then (unless is some font issue)…

Plain. I got this code I need to try out, but that sign seems hard to get

/ip firewall connection print where src-address~":123\$" and so on...

On Mac, if you enable “Show input menu in menu bar” option in System Preferences — in Keyboard section, there is the “Text Input” section, and button for “Edit…”. Then in the task bar, another icon will appear where you can select the “Show Keyboard Viewer” & that might let you type the tilde.

But I can write it anywhere else. But that combination doesn’t work in Terminal.
So the code I mentioned above can’t be used?

Edit: Also backslash seems to be a problem

https://discussions.apple.com/browse, sign in, ask question there, maybe you get response

I don’t know, but maybe the issue is between the same character (tilde) across two “standards”, it is perfectly possible that you are typing/inserting in other programs the Unicode tilde whilst terminal wlll only accept ASCII (from the little I know of Macintosh they use Unicode).

The ASCII tilde is 0126, it should be obtainable with a combiination of keys, but it depends on the keyboard/language (national) in use, if you have a Swedish keyboard, it should be Alt + ^ :
https://apple.stackexchange.com/questions/60943/how-to-type-this-tilde-in-mac-i-can-only-type-˜-using-fn-n-on-an-italian-m

Would this work?
https://apple.stackexchange.com/questions/339738/how-do-you-type-a-character-with-its-ascii-code

If you like to use the terminal, you can do this:

printf “\x0c” | pbcopy

This pipes a single formfeed character to the pbcopy, which stores it in the system clipboard. You may then paste it into whatever app you need.

of course using 126, i.e. 7E:

printf “\x7e” | pbcopy

Here we go!!!
Thanks a lot. This worked :smiley:

Which one, the printf/pbcopy?
Good :slight_smile: though it seems to me overly complex.

It is strange that they haven’t a “simple” mode like on Windows (ALT+<dec_ascii_code>), maybe this approach also works:
https://superuser.com/questions/258825/how-to-type-non-printable-ascii-characters-in-mac-os-x-terminal
though the key combination needed before typing 0126 (or 007E) seems like variable.

Something is wrong in on that macOS if copy from bytes is needed to get plain text character anyway… How is not possible to just simply c/p character from plain text, is some utility software running that intercepts clipboard which alters characters?

Whole thing sounds strange. But yeah RouterOS would drop high ASCII chars (unicode) on a paste.

Maybe a mismatch between the keyboard being used and type selected in System Preference under Keyboard?

Yeah but when you copy plain ascii character (~) from some text to cliboard (cmd+c) and paste it (cmd+v) it should be the same plain text character. Command with pbcopy is doing same thing but from bytes and it seems on paste there is no problem, I don’t get it. Check with c/p command

echo -n "~" | xxd

it shuld be 0x7E.

But tilde is not even in the “extended” ASCII, it is within the first “normal” 128 (0-127) range (and it is of course the same in Unicode).
https://ss64.com/ascii.html
https://www.compart.com/en/unicode/U+007E

The whatever is generated on other programs must be a “different” (with higher ID/address) tilde. :open_mouth:

Maybe this one:
https://www.compart.com/en/unicode/U+223C

This means that his system/browser replaces ascii tilde to whatever tilde from my prev. post and also in any other app like some plain text editors? How is possible to work on that? :slight_smile:

I have no idea, one of the references is about making characters with tilde, and goes on to suggest to make the key combo and then enter space, but that (maybe) would result in using the “small tilde” over a space:
https://www.compart.com/en/unicode/U+02DC

I am already ?abbergasted by this :wink: :
https://shkspr.mobi/blog/2024/01/a-small-text-rendering-bug-in-bailii/

There is no end to the issues created (largely in perfectly good faith) by programmers.

On a US Mac keyboard, use Opt+N and then press spacebar to generate “~”.

Opt+n is actualy shortcut to put tilde as diacritic on character that can have such diacritic, like Opt+n n prints ñ, or for ˆ diacritic Opt+i (on US) o to get ô, etc… But it can be used with space to print standalone diacritic. When Keyboard Viewer is active it shows which character supports diacritic on such shortcut.