Results 1 to 3 of 3

Thread: How can I map keys in the terminal?

  1. #1
    Join Date
    Jul 2008
    Location
    Dating spots
    Beans
    4
    Distro
    Ubuntu 8.04 Hardy Heron

    Question How can I map keys in the terminal?

    I use XShell (a sort of PuTTY on steroids) on Windows to connect to my Ubuntu box. My shell is bash.

    How can I map keys so that when I press Ctrl+LeftArrow, the shell does Alt+B (move cursor one word to the left) and when I press Ctrl+RightArrow, the shell receives Alt+F (move cursor one word right)?

    I think this is very basic customization, but I haven't found a short answer for it after quite a lot of searching. I found this Linux keyboard and console FAQ but it's overly long and complex. What I want is very simple, just to map two keyboard shortcuts. How can I do that, easily, on the Ubuntu box (not in XShell, Putty, on Windows, or in my brain)?

    Thanks!

  2. #2
    Join Date
    Dec 2007
    Beans
    222

    Re: How can I map keys in the terminal?

    How can I map keys so that when I press Ctrl+LeftArrow, the shell does Alt+B
    (move cursor one word to the left) and when I press Ctrl+RightArrow, the shell
    receives Alt+F (move cursor one word right)?
    Here is a quick fix:

    Code:
    echo "\"\e[1;5C\": forward-word
    > \"\e[1;5D\": backward-word" >> ~/.inputrc
    bash
    To view all default bash keybindings:

    Code:
    bind -p
    And some here:

    Code:
    stty -a
    ...after quite a lot of searching.
    Code:
    man bash
    /^READLINE

    Help yourself | [Hints] Disassemble your laptop

    "Si peccasse negamus, fallimur,
    Et nulla est in nobis veritas--"

  3. #3
    Join Date
    Jul 2008
    Location
    Dating spots
    Beans
    4
    Distro
    Ubuntu 8.04 Hardy Heron

    Exclamation Re: How can I map keys in the terminal?

    [QUOTE=pauper;5505633]Here is a quick fix:

    Code:
    echo "\"\e[1;5C\": forward-word
    > \"\e[1;5D\": backward-word" >> ~/.inputrc
    bash
    Thanks, but that apparently did nothing. To be clear, I created .inputrc and added the following two lines:
    Code:
    "\e[1;5C": forward-word
    "\e[1;5D": backward-word
    Worse, if I simply create a 0-byte .inputrc, when I press Delete in the SSH client, a tilde (~) is echoed instead of the character under the cursor being deleted.

    I'm sorry, but WTF is it so complicated to bind Ctrl+Arrows to left/right word?!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •