Hi. I’ve been trying to improve my command line kung fu, and I’m wondering if meta keys are supported in the labs – and if so, what meta keyboard shortcuts work?
CTRL- (or C-) type combinations work fine in the labs, but I haven’t yet found any Meta (or M-) type combinations that work.
For context, I’m using the information found here:
I’d specifically like to be able to do this:
Meta-f, Meta-b # move cursor forward or backward one word at a time
There are also some meta keyboard shortcuts for killing and yanking text that would be useful.
Thanks!
Ty
Hi,
Have you tried it? The default meta-keys mentioned in that line to the bash manual work for me, as in M-f
and M-b
On a Windows keyboard, this is using the ALT
key.
Hi Alistair,
I’m on a MacBook Pro, so I’m using the Option key – which works as the Meta key in a regular Terminal session on my Mac, but I find it doesn’t work in the labs. I’m using Chrome, but I confirmed the same in Safari.
For example, Meta-f and Meta-b should allow me to move the cursor forward or backward a word at a time. Instead, this is what I get:
[root@centos-host ~]# #Opt-f produces: ƒƒƒ
[root@centos-host ~]# #Opt-b produces: ∫∫∫
I’ve tried a couple other key combinations, but none of them move the cursor. They either do nothing, or they spit out the characters above or:
[root@centos-host ~]# #Opt-Shift-f produces: ÏÏÏ
[root@centos-host ~]# #Opt-Shift-b produces: ııı
Thanks,
Ty
Just bumping this topic, as it hasn’t gotten another reply since I provided more detail.
I’m a mac user, and the question is what context you expect to get Meta-f and Meta-b. If you mean when you are editing a line, then it works like in the emacs program: Meta-f is f, and Meta-b is b. And they work as you expect: they go ahead a word and back a word.
Hi Rob,
Thanks for replying. Do I have to do something specific to use or activate meta keys within the labs? It sounds like you and Alistair are both suggesting it should just work, but I’m not finding that to be the case.
To restate my intent, I’d like to be able to move forward and backward a word at a time, but when I use Option-f and Option-b on my Mac all I get are the funny characters I pasted further up. When I do the same in a Terminal window in Mac OS, those meta keys work as expected.
Here’s an example: On the second line, my cursor was at the end of the line, and then I pressed Option-b several times. On the third line, I moved my cursor using the arrow keys to the first letter in “this” and then pressed Option-f several times. In both cases only those repeated characters were produced.
I hope that helps clarify!
ty
The option key won’t work as a meta key; it’s used to create alternative characters, as you’re seeing there.
No, I mean the “esc” key itself. Linux uses a utility called “readline” that lets you do things like move through a line displayed in the editor, things like:
- Cntl-e to move the the end of the line
- Cntl-a to move the beginning to the line
- Cntl-k to delete from the cursor to the end of the line.
These are all navigation key commands used in emacs, which was created by the same people that originally created the bash shell. Meta-f and Meta-b are also readline command keys. Since there’s an issue about some key boards not really having a meta key (as is the case on the Mac), You use the “esc” key (<esc>
) on the keyboard, which readline interprets as the beginning of a meta key sequence. So to generate META-f, you type “f”, and readline gets what you mean.
Our labs support readline’s key combinations in the terminal pane, and that’s how you do META-f and META-b.
Brilliant! That was exactly the detail I was looking for.
Thanks for that and for explaining the why behind it!
ty