├── README.org ├── keys.el └── keys.txt /README.org: -------------------------------------------------------------------------------- 1 | * Get all the emacs keys working in the Linux Console 2 | This adds support for some of the chords that doesn't work by default when running emacs in the Linux Console, such as a range of combination of arrows, =C=, =M=, =S= and =RET=. I use org pretty extensively, and all of the keys for that should be covered. 3 | 4 | Note: This works for the Linux Console (the one you're in before starting X) but it doesn't necessarrily work for terminal emulators in X. 5 | 6 | ** Config 7 | Load =keys.txt= to the keymap by putting this somewhere appropriate like =/etc/rc.local=: 8 | 9 | #+BEGIN_SRC sh 10 | loadkeys /path/to/keys.txt 11 | #+END_SRC 12 | 13 | Load =keys.el= by putting this somewhere in your emacs init file: 14 | 15 | #+BEGIN_SRC emacs-lisp 16 | (load "/path/to/keys.el") 17 | #+END_SRC 18 | 19 | That's it. 20 | -------------------------------------------------------------------------------- /keys.el: -------------------------------------------------------------------------------- 1 | ;;; TTY Key hacks 2 | ;;; The translations with the settings below fit the adjustments to the key table. 3 | (define-key function-key-map "\e[25~" [(control return)]) ;f13 4 | (define-key input-decode-map "\e[26~" [(control shift return)]) ;f14 5 | (define-key input-decode-map "\e[28~" [(meta shift return)]) ;f15 6 | (define-key input-decode-map "\e[29~" [(meta shift left)]) ;f16 7 | (define-key input-decode-map "\e[31~" [(meta shift right)]) ;f17 8 | (define-key input-decode-map "\e[32~" [(meta shift up)]) ;f18 9 | (define-key input-decode-map "\e[33~" [(meta shift down)]) ;f19 10 | (define-key input-decode-map "\e[34~" [(meta left)]) ;f20 11 | (define-key input-decode-map "\e[35~" [(meta right)]) ;f21 12 | (define-key input-decode-map "\e[36~" [(meta up)]) ;f22 13 | (define-key input-decode-map "\e[37~" [(meta down)]) ;f23 14 | (define-key input-decode-map "\e[38~" [(control left)]) ;f24 15 | (define-key input-decode-map "\e[39~" [(control right)]) ;f25 16 | (define-key input-decode-map "\e[40~" [(control up)]) ;f26 17 | (define-key input-decode-map "\e[41~" [(control down)]) ;f27 18 | (define-key input-decode-map "\e[42~" [(shift left)]) ;f28 19 | (define-key input-decode-map "\e[43~" [(shift right)]) ;f29 20 | (define-key input-decode-map "\e[44~" [(shift up)]) ;f30 21 | (define-key input-decode-map "\e[45~" [(shift down)]) ;f31 22 | (define-key input-decode-map "\e[46~" [(control shift left)]) ;f32 23 | (define-key input-decode-map "\e[47~" [(control shift right)]) ;f33 24 | (define-key input-decode-map "\e[48~" [(control shift up)]) ;f34 25 | (define-key input-decode-map "\e[49~" [(control shift down)]) ;f35 26 | (define-key input-decode-map "\e[50~" [(shift tab)]) ;f36 27 | (define-key input-decode-map "\e[51~" [(shift return)]) ;f37 28 | (define-key input-decode-map "\e[52~" [(control meta left)]) ;f38 29 | (define-key input-decode-map "\e[53~" [(control meta right)]) ;f39 30 | (define-key input-decode-map "\e[54~" [(control meta up)]) ;f40 31 | (define-key input-decode-map "\e[55~" [(control meta down)]) ;f41 32 | -------------------------------------------------------------------------------- /keys.txt: -------------------------------------------------------------------------------- 1 | # Turn CapsLock into Control. Exclude if you don't want that. 2 | keycode 58 = Control 3 | 4 | # Define S- 5 | keycode 15 = Tab 6 | shift keycode 15 = F36 7 | 8 | # Define C-/S-/C-S-/M-/M-S- 9 | keycode 28 = Return 10 | control keycode 28 = F13 11 | shift keycode 28 = F37 12 | shift control keycode 28 = F14 13 | alt keycode 28 = Meta_Control_m 14 | shift alt keycode 28 = F15 15 | 16 | # Define C-/M-/S-C-S/M-S- 17 | keycode 103 = Up 18 | control keycode 103 = F26 19 | alt keycode 103 = F22 20 | control alt keycode 103 = F40 21 | shift keycode 103 = F30 22 | control shift keycode 103 = F34 23 | alt shift keycode 103 = F18 24 | 25 | # Define C-/M-/S-C-S/M-S- 26 | keycode 105 = Left 27 | control keycode 105 = F24 28 | alt keycode 105 = F20 29 | control alt keycode 105 = F38 30 | shift keycode 105 = F28 31 | control shift keycode 105 = F32 32 | alt shift keycode 105 = F16 33 | 34 | # Define C-/M-/S-C-S/M-S- 35 | keycode 106 = Right 36 | control keycode 106 = F25 37 | alt keycode 106 = F21 38 | control alt keycode 106 = F39 39 | shift keycode 106 = F29 40 | control shift keycode 106 = F33 41 | alt shift keycode 106 = F17 42 | 43 | 44 | # Define C-/M-/S-C-S/M-S- 45 | keycode 108 = Down 46 | control keycode 108 = F27 47 | alt keycode 108 = F23 48 | control alt keycode 108 = F41 49 | shift keycode 108 = F31 50 | control shift keycode 108 = F35 51 | alt shift keycode 108 = F19 52 | 53 | # Map the menu key (the key next to AltGr on some keyboards) to C-\. That way, the key can be used as a tmux prefix key with the following in tmux.conf: "set -g prefix 'C-\'" 54 | keycode 127 = Control_backslash 55 | 56 | # Define a string for all the F-keys we've used. 57 | # F13-20 should be defined like this in the default keymap. They are added here for completeness. 58 | string F13 = "\033[25~" 59 | string F14 = "\033[26~" 60 | string F15 = "\033[28~" 61 | string F16 = "\033[29~" 62 | string F17 = "\033[31~" 63 | string F18 = "\033[32~" 64 | string F19 = "\033[33~" 65 | string F20 = "\033[34~" 66 | string F21 = "\033[35~" 67 | string F22 = "\033[36~" 68 | string F23 = "\033[37~" 69 | string F24 = "\033[38~" 70 | string F25 = "\033[39~" 71 | string F26 = "\033[40~" 72 | string F27 = "\033[41~" 73 | string F28 = "\033[42~" 74 | string F29 = "\033[43~" 75 | string F30 = "\033[44~" 76 | string F31 = "\033[45~" 77 | string F32 = "\033[46~" 78 | string F33 = "\033[47~" 79 | string F34 = "\033[48~" 80 | string F35 = "\033[49~" 81 | string F36 = "\033[50~" 82 | string F37 = "\033[51~" 83 | string F38 = "\033[52~" 84 | string F39 = "\033[53~" 85 | string F40 = "\033[54~" 86 | string F41 = "\033[55~" 87 | --------------------------------------------------------------------------------