[SOLVED] How to find the character sequence for Ctrl-l
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I am facing a strange problem with bash. I use a mac and is using iTerm2 for terminal needs. Inside iTerm2 pressing Ctrl-l locally on my mac works, It clears the screen. But when I am ssh'ed to a RHEL box Ctrl-l just triggers a new line(pressing enter key). But on same RHEL Ctrl-works on a screen session.
Now putting this in my .inputrc works
# for Ctrl+l clear screen
"\C-l":'clear\n'
But I want to know the exact character sequence generated when pressing Ctrl-l so that I can check if any existing key sequences is overriding it.
Kindly help me out.
Last edited by jithin1987; 08-08-2011 at 09:58 AM.
Well, Ctrl-L (that is an ell, right, not a vertical bar?) is the code for New Page or Form Feed (like, kick a new piece of paper in a printer). Probably not what you want.
Ctrl-L is a single value (as are all the ASCII control characters, not the same thing as X code sequence!).
I figured out the issue. I was compiling and installing screen 4.0.3 on my own. And I replaced /etc/termcap with a custom file given in the source code. Reverting the file fixed the issue.
I guess all these mappings were defined there?
Also @tronayne how did you generate those mappings? Is there any linux app which does that?
Also @tronayne how did you generate those mappings? Is there any linux app which does that?
It's a little C program I wrote some years ago that produces everything from zero (NUL) to 255 (decimal); got written just 'cause there wasn't anything I could find a the time that did it.
Here 'tis (cross.c:
Code:
#ident "$Id: cross.c,v 1.2 2011/08/08 21:46:04 trona Exp $"
/*
* Copyright (C) 2000-2011 Thomas Ronayne
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General
* Public License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*
* Name: $Source: /usr/local/cvsroot/utils/cross.c,v $
* Purpose: Display the ASCII character set as a cross-reference,
* also useful with troff (but you need tbl and the mm macros)
* Version: $Revision: 1.2 $
* Modified: $Date: 2011/08/08 21:46:04 $
* Author: T. N. Ronayne
* Date:
* $Log: cross.c,v $
* Revision 1.2 2011/08/08 21:46:04 trona
* prepare for public release
*
* Revision 1.1.1.1 2009/10/07 18:06:40 trona
* initial installation Slackware 13.0
*
* Revision 1.1.1.1 2009/01/29 15:03:25 trona
* inital
*
* Revision 1.1.1.1 2007/06/12 12:45:53 trona
* initial installation after SATA failure
*
* Revision 1.3 2006/04/23 18:29:35 trona
* print more characters
*
* Revision 1.2 2006/01/01 22:55:47 trona
* add unistd.h for getopt() function
*
* Revision 1.1.1.1 2006/01/01 22:48:42 trona
* initial on fubar
*
* Revision 1.2 1998/08/24 19:48:39 trona
* fix the spelling of Binary
*
* Revision 1.1.1.1 1998/02/12 20:11:57 trona
* initial installation
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#ifndef TRUE
# define TRUE 1
#endif
#ifndef FALSE
# define FALSE 0
#endif
static char *ascii [] = {
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
"BS", "HT", "NL", "VT", "NP", "CR", "SO", "SI",
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
"CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US", "SP"
};
extern char *optarg; /* command line argument */
extern int optind; /* command line argument ptr */
void main (int argc, char *argv [])
{
int i, j, k = 59;
int c; /* general-purpose */
int error = FALSE; /* error flag */
int topt = FALSE; /* process through tbl & troff */
int vopt = FALSE; /* verbose option */
/* process the command line arguments */
while ((c = getopt (argc, argv, "?tv")) != EOF) {
switch (c) {
case '?':
error = TRUE;
break;
case 't':
topt = TRUE;
(void) fprintf (stdout,
".PH \"''\\f3Decimal\\(emHexadecimal\\(emOctal\\(emBinary\\(emASCII\\fP''\"\n");
(void) fprintf (stdout, ".PF \"''\\f3Page %%\\fP''\"\n");
(void) fprintf (stdout, ".2C\n");
(void) fprintf (stdout, ".TS H\n");
(void) fprintf (stdout, "cB cB cB cB cB\n");
(void) fprintf (stdout, "n r n n c.\n");
(void) fprintf (stdout, "Dec Hex Octal Binary ASCII\n");
(void) fprintf (stdout, "_\n");
(void) fprintf (stdout, ".TH\n");
break;
case 'v':
vopt = TRUE;
break;
default:
(void) fprintf (stderr, "getopt() bug\n");
exit (EXIT_FAILURE);
}
}
/* any errors in the arguments, or a '?' entered... */
if (error) {
(void) fprintf (stderr, "usage: %s [-t troff] [-v]\n", argv [0]);
exit (EXIT_FAILURE);
}
for (i = 0; i < 256; i++) {
if (!topt) {
if (k == 59) {
(void) fprintf (stdout,
"\tDec\tHex\tOctal\tBinary\t\tASCII\n");
k = 0;
}
}
/* print the decimal, hex, and octal */
if (!topt)
(void) fprintf (stdout, "\t");
(void) fprintf (stdout, "%03d\t%03x\t%04o\t", i, i, i);
/* print the binary */
for (j = sizeof (char) * 8 - 1; j >= 0; j--) {
(void) fprintf (stdout, "%c",
((1 << j) & i) ? '1' : '0');
}
(void) fprintf (stdout, "\t");
/* unprintable? */
if (i < 33) {
(void) fprintf (stdout, "%s\t(Ctrl-%c)\n",
ascii [i], i+64);
} else if (i == 127) {
(void) fprintf (stdout, "DEL\n");
} else if (i < 255) {
if (topt) { /* output for troff? */
switch (i) {
case 61: case 95:
(void) fprintf (stdout, "\\&%c\n", i);
break;
case 92:
(void) fprintf (stdout, "%ce\n", i);
break;
default:
(void) fprintf (stdout, "%c\n", i);
break;
}
} else { /* just print it */
(void) fprintf (stdout, "%c\n", i);
}
} else {
(void) fprintf (stdout, ".\n");
}
if (!topt) {
k++;
}
}
if (topt) {
(void) fprintf (stdout, ".TE\n");
(void) fprintf (stdout, ".1C\n");
}
exit (0);
}
You may want to change the definition of main to int instead of void; old habits die hard.
You run it as cross; pipe the output to pg, more or lp.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.