Community discussions

MikroTik App
 
Favazza
newbie
Topic Author
Posts: 35
Joined: Fri Jan 26, 2024 5:05 pm

Tilde sign in Terminal (Mac)

Mon Feb 12, 2024 4:35 pm

Hello

How do I get the Tilde-sign ~ in the Terminal? Using Mac (can't copy and paste).
 
optio
Long time Member
Long time Member
Posts: 675
Joined: Mon Dec 26, 2022 2:57 pm

Re: Tilde sign in Terminal (Mac)

Mon Feb 12, 2024 8:32 pm

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.
 
Favazza
newbie
Topic Author
Posts: 35
Joined: Fri Jan 26, 2024 5:05 pm

Re: Tilde sign in Terminal (Mac)

Mon Feb 12, 2024 8:52 pm

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?!
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3509
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Tilde sign in Terminal (Mac)

Mon Feb 12, 2024 9:05 pm

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.
 
optio
Long time Member
Long time Member
Posts: 675
Joined: Mon Dec 26, 2022 2:57 pm

Re: Tilde sign in Terminal (Mac)

Mon Feb 12, 2024 9:10 pm

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)...
 
Favazza
newbie
Topic Author
Posts: 35
Joined: Fri Jan 26, 2024 5:05 pm

Re: Tilde sign in Terminal (Mac)

Mon Feb 12, 2024 11:07 pm

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.

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...
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3509
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 2:14 am

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.
 
Favazza
newbie
Topic Author
Posts: 35
Joined: Fri Jan 26, 2024 5:05 pm

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 1:43 pm

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
 
optio
Long time Member
Long time Member
Posts: 675
Joined: Mon Dec 26, 2022 2:57 pm

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 2:42 pm

https://discussions.apple.com/browse, sign in, ask question there, maybe you get response
 
jaclaz
Long time Member
Long time Member
Posts: 667
Joined: Tue Oct 03, 2023 4:21 pm

Re: Tilde sign in Terminal (Mac)  [SOLVED]

Tue Feb 13, 2024 6:56 pm

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/questio ... -italian-m

Would this work?
https://apple.stackexchange.com/questio ... 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
 
Favazza
newbie
Topic Author
Posts: 35
Joined: Fri Jan 26, 2024 5:05 pm

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 7:16 pm

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/questio ... -italian-m

Would this work?
https://apple.stackexchange.com/questio ... 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 :D
 
jaclaz
Long time Member
Long time Member
Posts: 667
Joined: Tue Oct 03, 2023 4:21 pm

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 8:13 pm

Here we go!!!
Thanks a lot. This worked :D
Which one, the printf/pbcopy?
Good :) 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/ ... x-terminal
though the key combination needed before typing 0126 (or 007E) seems like variable.
 
optio
Long time Member
Long time Member
Posts: 675
Joined: Mon Dec 26, 2022 2:57 pm

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 8:24 pm

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?
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3509
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 8:29 pm

Something is wrong in on that macOS if copy from bytes is needed to get plain text character anyway...
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?
 
optio
Long time Member
Long time Member
Posts: 675
Joined: Mon Dec 26, 2022 2:57 pm

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 8:35 pm

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.
 
jaclaz
Long time Member
Long time Member
Posts: 667
Joined: Tue Oct 03, 2023 4:21 pm

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 8:40 pm

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. :shock:

Maybe this one:
https://www.compart.com/en/unicode/U+223C
 
optio
Long time Member
Long time Member
Posts: 675
Joined: Mon Dec 26, 2022 2:57 pm

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 8:44 pm

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? :)
 
jaclaz
Long time Member
Long time Member
Posts: 667
Joined: Tue Oct 03, 2023 4:21 pm

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 8:54 pm

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-smal ... in-bailii/

There is no end to the issues created (largely in perfectly good faith) by programmers.
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1068
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 9:08 pm

On a US Mac keyboard, use Opt+N and then press spacebar to generate "~".
 
optio
Long time Member
Long time Member
Posts: 675
Joined: Mon Dec 26, 2022 2:57 pm

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 9:51 pm

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.
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1068
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 10:33 pm

Well thanks, but Opt+n followed by spacebar is still the standard procedure for producing a plain 'tilde'..
 
optio
Long time Member
Long time Member
Posts: 675
Joined: Mon Dec 26, 2022 2:57 pm

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 10:44 pm

Not on all layouts, try on German for eg... For US you have much simpler shortcut, shift+` prints ~
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1068
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 11:24 pm

That usually works fine with "normal" keyboards. However, on a MacBook, pressing shift + grave accent + space might, under certain conditions, produce "±". That's why using opt+n might be a better choice. MacBook keyboards equipped with a hat key (^) can use it in combination with opt.
 
optio
Long time Member
Long time Member
Posts: 675
Joined: Mon Dec 26, 2022 2:57 pm

Re: Tilde sign in Terminal (Mac)

Tue Feb 13, 2024 11:57 pm

Could be, but from my experience using external BT Magic Keyboard and keyboard on MBP never had such issues, but I'm not on US layout.
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1068
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: Tilde sign in Terminal (Mac)

Wed Feb 14, 2024 12:24 am

Yeah, the Magic Keyboard is a winner!
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3509
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Tilde sign in Terminal (Mac)

Wed Feb 14, 2024 3:17 am

For US you have much simpler shortcut, shift+` prints ~
True. It's just a key left of the 1. But do know not all keyboards are created equal.

Well thanks, but Opt+n followed by spacebar is still the standard procedure for producing a plain 'tilde'..
Well...on a US keyboard, Option-N+Space gets you ˜ not the required ~.

Not sure but also might vary depending on locale ("Language & Region" in System Preference). I'm just sure there is SOME way to type a tilde with the OP's combo of settings/hw.

At least it's not a subtle problem (e.g. why does my regex not work e.g. name˜"ether" vs name~"ether) since RouterOS will drop the unicode before you see the ˜
 
Favazza
newbie
Topic Author
Posts: 35
Joined: Fri Jan 26, 2024 5:05 pm

Re: Tilde sign in Terminal (Mac)

Wed Feb 14, 2024 2:19 pm

Here we go!!!
Thanks a lot. This worked :D
Which one, the printf/pbcopy?
Good :) 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/ ... x-terminal
though the key combination needed before typing 0126 (or 007E) seems like variable.
I added the Unicode Hex keyboard to my system. This way I could find - and add - them into the Terminal.
 
Favazza
newbie
Topic Author
Posts: 35
Joined: Fri Jan 26, 2024 5:05 pm

Re: Tilde sign in Terminal (Mac)

Wed Feb 14, 2024 2:23 pm

On a US Mac keyboard, use Opt+N and then press spacebar to generate "~".
Even in the MikroTik Terminal?
I can write it here ~ but in the Terminal nothing happens with the exact same combo. That is the real issue here.
 
jaclaz
Long time Member
Long time Member
Posts: 667
Joined: Tue Oct 03, 2023 4:21 pm

Re: Tilde sign in Terminal (Mac)

Wed Feb 14, 2024 2:47 pm

I can write it here ~ but in the Terminal nothing happens with the exact same combo. That is the real issue here.
Yep, as said before, it is possible that that "key combo" leads to producing a "different" tilde, not the ASCII one, likely the "small tilde", which is UNicode only.

To recap, there are (at least) three tilde's in Unicode:
1) "real" tilde, Ascii and Unicode 126 or 0x7E: https://www.compart.com/en/unicode/U+007E

2) Math symbol tilde Unicode only, 0x223C https://www.compart.com/en/unicode/U+223C

3) Small tilde (the one that normally goes above a tilde accented character), Unicode only, 0x02DC: https://www.compart.com/en/unicode/U+02DC

This latter is what in Postscript (AFAICR MacOS has often many points in common with Postscript when it comes to text) is actually called "tilde", the first one in Postscript is called instead asciitilde.

The Mikrotik terminal surely want the asciitilde.
Last edited by jaclaz on Wed Feb 14, 2024 8:11 pm, edited 1 time in total.
 
optio
Long time Member
Long time Member
Posts: 675
Joined: Mon Dec 26, 2022 2:57 pm

Re: Tilde sign in Terminal (Mac)

Wed Feb 14, 2024 5:53 pm

1) "real" tilde, Ascii and Unicode 126 or 0x0E: https://www.compart.com/en/unicode/U+007E
No, it's 0x7E hex (as on link)

And yes, on some layouts Opt+n can produce different character (non ascii) since this shortcut is for adding diacritic on supported character, as I mentioned

Still c/p plain ascii character is confusing why is not working...
 
jaclaz
Long time Member
Long time Member
Posts: 667
Joined: Tue Oct 03, 2023 4:21 pm

Re: Tilde sign in Terminal (Mac)

Wed Feb 14, 2024 8:12 pm

Sorry, typo, corrected. :oops:
 
optio
Long time Member
Long time Member
Posts: 675
Joined: Mon Dec 26, 2022 2:57 pm

Re: Tilde sign in Terminal (Mac)

Thu Feb 15, 2024 12:13 am

@Favazza if you still have issue with tilde, you can try with this Applescript run by Quick Action (Service):
on run {input, parameters}
    tell application "System Events" to keystroke (ASCII character 126) & " "
    return input
end run
run Automator app->Quick Action->drag "Run AppleScript" from actions to workflow->paste above script->save (choose name you like)
That quick action will appear as is named in "Services" menu item under app name menu in all Mac apps and you can choose it to perform in that app, script will perform ascii tilde character keystroke. Also you can even assign shortcut for that action from "Services Settings..." menu item in same "Services" menu -> General section, doubleclick on shortcut (none if not assigned) and press keystroke combination for it (choose some that's not overlapping with some other).
Note: First time when you run this quick action on app macOS will ask for that app Accessibility permission and it must be allowed to perform. This setting is per app so on each app you must allow where you need it.

If above script is not working for you, you can try with this one which is using clipboard:
on run {input, parameters}
    set the clipboard to (ASCII character 126)
    tell application "System Events"
        keystroke "v" using command down
        key code 124
    end tell
    return input
end run
 
Favazza
newbie
Topic Author
Posts: 35
Joined: Fri Jan 26, 2024 5:05 pm

Re: Tilde sign in Terminal (Mac)

Thu Feb 15, 2024 3:26 pm

Thanx Optio!

I already solved it with adding the extra keyboard.
 
User avatar
patrikg
Member Candidate
Member Candidate
Posts: 262
Joined: Thu Feb 07, 2013 6:38 pm
Location: Stockholm, Sweden

Re: Tilde sign in Terminal (Mac)

Fri Feb 16, 2024 9:44 am

Now you can press this bar to mark your thread as solved.

Image
 
infabo
Long time Member
Long time Member
Posts: 695
Joined: Thu Nov 12, 2020 12:07 pm

Re: Tilde sign in Terminal (Mac)

Fri Feb 16, 2024 3:09 pm

not quite
You do not have the required permissions to view the files attached to this post.
 
Favazza
newbie
Topic Author
Posts: 35
Joined: Fri Jan 26, 2024 5:05 pm

Re: Tilde sign in Terminal (Mac)

Fri Feb 16, 2024 3:40 pm

Corrected. Hope you're happy.
 
infabo
Long time Member
Long time Member
Posts: 695
Joined: Thu Nov 12, 2020 12:07 pm

Re: Tilde sign in Terminal (Mac)

Sat Feb 17, 2024 9:29 am

I don't even care. Tilde works on my MacOS Terminal. But it is good to know a) a topic was solved and b) what exactly helped to solve. Furthermore, anyone having the same or alike issue like you may come here to the forum (in the future), find this topic and can see the "solved" answer immediately. Quick win - instead of having to read a whole thread.
 
jaclaz
Long time Member
Long time Member
Posts: 667
Joined: Tue Oct 03, 2023 4:21 pm

Re: Tilde sign in Terminal (Mac)

Sat Feb 17, 2024 11:27 am

Well, to recap, here we have several possible solutions:
1) an "ugly" (IMHO) command line workaround:
viewtopic.php?t=204461#p1056148

2) the (still IMHO) "right" way, adding the Unicode Hex Input to the keyboard.
viewtopic.php?t=204461#p1056157
(that allows to use option+<hex_code> similar to the Windows Alt+<dec_code>)

3) a couple applescripts by optio:
viewtopic.php?t=204461#p1056431

What is relevant, no matter the method one chooses is the confirmation that the method that is suggested *everywhere* (using the special key combo to create a diacritic tilde followed by a space instead of a letter) leads to a different character, that looks like tilde but is not the ascii tilde needed in terminal.

Who is online

Users browsing this forum: Bing [Bot], Pilo2710 and 17 guests