Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



Reply
 
Thread Tools Rate Thread Display Modes
Old 03-13-2003, 07:32 AM   #1
bluehz
MVP
 
Join Date: Jan 2002
Posts: 1,562
10.1 Bindkey use in screen

I am having a hard time wrapping my head around bindkey. In particular - in tcsh I use ctr+a and ctr+e to go to the beginning of the line and the end of a line respectively. But when I use screen in the terminal (which I use about 90% of the time I am in the terminal) the ctr-a key no longer works (ctrl+e) works fine. So I dove in and started reading about key bindings, etc. in an attempt to get my ctr+a working in screen again, but I just can't seem to get it right.

Does anyone have any suggestions for remapping the ctr+a key in screen.

Also in the .screenrc file I am using (picked it up at dot-files.com) there is a listing for binding the F7 and F8 function keys to fwd and back in the window list. This would be very useful but doesn't seem to work in OS X. Here is the pertinent info from the .screenrc:

# Use the function keys F7 and F8
# to cycle backwards/forwards in
# the list of existing windows:
bindkey -k k7 prev
bindkey -k k8 next

Is there anyway to get the F-keys working in the terminal?
bluehz is offline   Reply With Quote
Old 03-14-2003, 07:13 PM   #2
Miga
Triple-A Player
 
Join Date: Aug 2002
Location: Paris, France
Posts: 113
I think (not sure though since I don't know anything about screen, just read the screen man page), you have first to use:

escape xy

to set the command character to x as screen by default use C-a (default is Aa), so that means you cannot use C-a as usual.

Then you can probably use C-a as usual in terminal.
Miga is offline   Reply With Quote
Old 03-14-2003, 07:43 PM   #3
Miga
Triple-A Player
 
Join Date: Aug 2002
Location: Paris, France
Posts: 113
I've just tried it:

in a new terminal:

screen -e^Gg

(note the caret, not control) maps Ctrl-G as the command character, then you can use ctrl-a as you used to.

The problem is to choose a letter which is not used for something useful for you.
Miga is offline   Reply With Quote
Old 03-14-2003, 08:46 PM   #4
ilovja
Prospect
 
Join Date: Mar 2003
Posts: 15
bluehz, I tried everything I could do to make those F7, F8 work with no luck.

However, my curiosity is getting wild because I found out we could do that for F1,F2:

bindkey -k k1 prev
bindkey -k k2 next

I have no idea why this is not working on F7, F8...
ilovja is offline   Reply With Quote
Old 03-15-2003, 07:11 AM   #5
bluehz
MVP
 
Join Date: Jan 2002
Posts: 1,562
Thx guys - been trying to avoid messing with bindkeys - you REALLY have to admit you have a bad unix addiction before you should start messing with bindkeys... well I guess I'm ready to admit...

Put this in the ~/.screenrc file:

escape ^gg

and then you use ctrl+g wherever you would normally use the default ctrl+a (which is used extensively in screen), and the ctrl+a now sends you to beginning of line.

Last edited by bluehz; 03-15-2003 at 11:07 AM.
bluehz is offline   Reply With Quote
Old 03-15-2003, 11:59 AM   #6
breen
Major Leaguer
 
Join Date: Jan 2003
Location: Bay Area
Posts: 327
Okay, bluehz -- added to my bag of tricks. Thanks.

Question (just curious) -- were you doing this to save a keystroke? I've been using 'ctrl-a a' in screen to send a literal ctrl-a to go to the beginning of the line.

Breen
breen is offline   Reply With Quote
Old 03-15-2003, 12:11 PM   #7
bluehz
MVP
 
Join Date: Jan 2002
Posts: 1,562
Actually - I didn't know about the ctr-a a thing. I just wanted the functionality back. I was always hitting ctr+a out of habit and nothing would happen then whenever I hit another key (any key) screen would switch to another screen. So ctl+a is mapped to something already. But it works now - I just wanted continuity between what I am used to in the shell and in screen.

BTW - there is a really nice .screenrc here

http://www.math.fu-berlin.de/~guckes/setup/screenrc

I have been modifying this one. I really like the info in puts at the bottom of the screen.
bluehz is offline   Reply With Quote
Old 03-15-2003, 02:22 PM   #8
Miga
Triple-A Player
 
Join Date: Aug 2002
Location: Paris, France
Posts: 113
I've tried what ilovja said, but I cannot on my installation.

I've read in the screen mailing list searching for F7 (and in the man page too) that the capabilities of screen depends on the capabilities of your termcap. And if your termcap does not define a key, you cannot bind it to anything, which seems to me pure logic.
Miga is offline   Reply With Quote
Old 03-15-2003, 02:52 PM   #9
Miga
Triple-A Player
 
Join Date: Aug 2002
Location: Paris, France
Posts: 113
C-a? displays all bindings.

Then you can change the default command key either with escape or with bindkey in ~/.screenrc file or at launching screen with -e option.

Quote:
Quoted from screen man page

By default, each command begins with a control-a (abbreviated C-a from now on).

C-a C-a
(other) Toggle to the window displayed previously. Note that this binding defaults to the command character typed twice, unless overridden. For instance, if you use the option -e]x", this command becomes ]]".

C-a a
(meta) Send the command character (C-a) to window. See escape command.
[/quote]
Miga is offline   Reply With Quote
Old 03-15-2003, 04:40 PM   #10
bluehz
MVP
 
Join Date: Jan 2002
Posts: 1,562
WOW these keybindings are confusing - now I know I'm addicted. I want to learn how... hahaha
bluehz is offline   Reply With Quote
Old 03-15-2003, 05:27 PM   #11
ilovja
Prospect
 
Join Date: Mar 2003
Posts: 15
Quote:
Originally posted by Miga
I've read in the screen mailing list searching for F7 (and in the man page too) that the capabilities of screen depends on the capabilities of your termcap. And if your termcap does not define a key, you cannot bind it to anything, which seems to me pure logic.

Dangx. I changed term type to xterm and tried F7 thing again and it worked. I guess I need to learn more about termcap(or terminfo). I remember that key bindings in *nix applications worked well when I changed term type from vt100 to xterm, though I still keep vt100 setting.

I'm using bash 2.05b.0(1) installed by fink and screen 3.09.10 which came with jag.

Quote:
Originally posted by bluehzWOW these keybindings are confusing - now I know I'm addicted.

It's been around half a year using screen, but I still feel keybindings are pretty weird. I wouldn't mind Ctrl-A C to create a new window, but Ctrl-A N to change to next window was much hassle to me because I move between at least two windows back and forth so often. Since my keybinding for next window is F2, it's a breeze now. And the .screenrc you pointed at has lots of goodies. http://dotfiles.com is amazing.

Last edited by ilovja; 03-15-2003 at 05:30 PM.
ilovja is offline   Reply With Quote
Old 03-15-2003, 05:44 PM   #12
breen
Major Leaguer
 
Join Date: Jan 2003
Location: Bay Area
Posts: 327
Quote:
Originally posted by bluehz
it works now - I just wanted continuity between what I am used to in the shell and in screen.

BTW - there is a really nice .screenrc here
http://www.math.fu-berlin.de/~guckes/setup/screenrc

Mmm. That one's going to take a while to digest.
Thanks for the pointer.

My problem with remapping standard keystrokes is that I have to remember whether I've created a .screenrc file on each host I use. I almost never use screen if I'm at the machine -- mostly when I'm ssh'd into another box.
Whatever works for you, though!

Breen
breen is offline   Reply With Quote
Old 03-15-2003, 06:45 PM   #13
Miga
Triple-A Player
 
Join Date: Aug 2002
Location: Paris, France
Posts: 113
Just an idea, I don't know if it works, but it may be worth to give it a try.

Create a /etc/screenrc (or maybe /usr/share/screenrc, or /usr/local/screenrc, I'm not sure which file screen look at at initialization time and maybe Apple disabled it) and source it in ~/.screenrc, just as it can be done for ~/.xinitrc and /sw/bin/init.sh.

as it is stated in the screen man page, section bug:

When attaching to a multiuser session, the user's
.screenrc file is not sourced. Each user's personal settings have to be included in the .screenrc file from which the session is booted, or have to be changed manually.

And, many thanks bluehz for having opened this thread. Screen is really interesting. I really should print the screen man page, take a break and read it thoroughly.

ilovja, how do you change the term type?
Miga is offline   Reply With Quote
Old 03-15-2003, 07:35 PM   #14
bluehz
MVP
 
Join Date: Jan 2002
Posts: 1,562
Yes - I really like screen and use it all teh time, but I feel like I really only understand 5% of it. You can create a .screenrc file in your home dir (or I think /etc/.screenrc) and it is read in at screen launch. I just discoverd the .screen rc I listed at the link above and I have learned a LOT just from reading it. I highly recommend grabbinga copy of that and at least looking at it, and even dropping it into your home dir as ".screenrc" just too see what happens.
bluehz is offline   Reply With Quote
Old 03-15-2003, 07:43 PM   #15
Miga
Triple-A Player
 
Join Date: Aug 2002
Location: Paris, France
Posts: 113
I did it, as soon as you mentioned it (thanks :-), it launches fine, but I have not taken the time to study it at the moment. I'll do it at slow pace.
Miga is offline   Reply With Quote
Old 03-16-2003, 01:38 AM   #16
ilovja
Prospect
 
Join Date: Mar 2003
Posts: 15
Quote:
Originally posted by Miga
ilovja, how do you change the term type?


All you have to do is to change a variable named TERM.

In tcsh,

setenv TERM xterm

In bash,

export TERM=xterm
ilovja is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 10:54 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.