LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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

Reply
 
LinkBack Search this Thread
Old 08-08-2011, 09:46 AM   #1
jithin1987
LQ Newbie
 
Registered: May 2007
Location: Bangalore
Distribution: Arch
Posts: 6

Rep: Reputation: 0
How to find the character sequence for Ctrl-l


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.
 
Old 08-08-2011, 10:38 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 2,864

Rep: Reputation: 698Reputation: 698Reputation: 698Reputation: 698Reputation: 698Reputation: 698
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!).
Code:
        Dec     Hex     Octal   Binary          ASCII
        012     00c     0014    00001100        NP      (Ctrl-L)
Here's all the control characters:
Code:
        Dec     Hex     Octal   Binary          ASCII
        000     000     0000    00000000        NUL     (Ctrl-@)
        001     001     0001    00000001        SOH     (Ctrl-A)
        002     002     0002    00000010        STX     (Ctrl-B)
        003     003     0003    00000011        ETX     (Ctrl-C)
        004     004     0004    00000100        EOT     (Ctrl-D)
        005     005     0005    00000101        ENQ     (Ctrl-E)
        006     006     0006    00000110        ACK     (Ctrl-F)
        007     007     0007    00000111        BEL     (Ctrl-G)
        008     008     0010    00001000        BS      (Ctrl-H)
        009     009     0011    00001001        HT      (Ctrl-I)
        010     00a     0012    00001010        NL      (Ctrl-J)
        011     00b     0013    00001011        VT      (Ctrl-K)
        012     00c     0014    00001100        NP      (Ctrl-L)
        013     00d     0015    00001101        CR      (Ctrl-M)
        014     00e     0016    00001110        SO      (Ctrl-N)
        015     00f     0017    00001111        SI      (Ctrl-O)
        016     010     0020    00010000        DLE     (Ctrl-P)
        017     011     0021    00010001        DC1     (Ctrl-Q)
        018     012     0022    00010010        DC2     (Ctrl-R)
        019     013     0023    00010011        DC3     (Ctrl-S)
        020     014     0024    00010100        DC4     (Ctrl-T)
        021     015     0025    00010101        NAK     (Ctrl-U)
        022     016     0026    00010110        SYN     (Ctrl-V)
        023     017     0027    00010111        ETB     (Ctrl-W)
        024     018     0030    00011000        CAN     (Ctrl-X)
        025     019     0031    00011001        EM      (Ctrl-Y)
        026     01a     0032    00011010        SUB     (Ctrl-Z)
        027     01b     0033    00011011        ESC     (Ctrl-[)
        028     01c     0034    00011100        FS      (Ctrl-\)
        029     01d     0035    00011101        GS      (Ctrl-])
        030     01e     0036    00011110        RS      (Ctrl-^)
        031     01f     0037    00011111        US      (Ctrl-_)
        032     020     0040    00100000        SP      (Ctrl-`)
and here's a link that explains what the ASCII alpha codes mean: http://www.december.com/html/spec/ascii.html if you're interested.

Alternately, you could alias cls as clear (without, by the way, the trailing New Line) and achieve the same thing.

Hope this helps some.
 
1 members found this post helpful.
Old 08-08-2011, 10:56 AM   #3
jithin1987
LQ Newbie
 
Registered: May 2007
Location: Bangalore
Distribution: Arch
Posts: 6

Original Poster
Rep: Reputation: 0
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?
 
Old 08-08-2011, 04:55 PM   #4
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 2,864

Rep: Reputation: 698Reputation: 698Reputation: 698Reputation: 698Reputation: 698Reputation: 698
Quote:
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.

Hope this helps some.
 
1 members found this post helpful.
  


Reply

Tags
bash, screen


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the meta character for the Ctrl button? SentralOrigin Programming 3 09-02-2008 02:52 PM
hi I need help changing the ctrl/alt f1 f2 etc sequence.. extendedping Linux - Software 2 10-01-2007 12:32 PM
Problem in getting telnet client prompt by pressing Escape character( ctrl -] ) Prassanta Suse/Novell 0 01-23-2007 12:33 AM
Question about inserting a character into a 2dimensional sequence. RHLinuxGUY Programming 6 11-27-2005 10:52 PM
How do I map a key sequence to a specific character? QtCoder Linux - General 0 11-28-2003 12:03 PM


All times are GMT -5. The time now is 03:42 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration