diff --git a/thefuck/const.py b/thefuck/const.py index 19128f3d..3f71d39b 100644 --- a/thefuck/const.py +++ b/thefuck/const.py @@ -12,6 +12,12 @@ class _GenConst(object): KEY_UP = _GenConst('↑') KEY_DOWN = _GenConst('↓') KEY_CTRL_C = _GenConst('Ctrl+C') +KEY_CTRL_N = _GenConst('Ctrl+N') +KEY_CTRL_P = _GenConst('Ctrl+P') + +KEY_MAPPING = {'\x0e': KEY_CTRL_N, + '\x03': KEY_CTRL_C, + '\x10': KEY_CTRL_P} ACTION_SELECT = _GenConst('select') ACTION_ABORT = _GenConst('abort') diff --git a/thefuck/system/unix.py b/thefuck/system/unix.py index e6e87ea2..9ae01cf4 100644 --- a/thefuck/system/unix.py +++ b/thefuck/system/unix.py @@ -22,8 +22,8 @@ def getch(): def get_key(): ch = getch() - if ch == '\x03': - return const.KEY_CTRL_C + if ch in const.KEY_MAPPING: + return const.KEY_MAPPING[ch] elif ch == '\x1b': next_ch = getch() if next_ch == '[': diff --git a/thefuck/system/win32.py b/thefuck/system/win32.py index 190d5430..577b3561 100644 --- a/thefuck/system/win32.py +++ b/thefuck/system/win32.py @@ -16,8 +16,8 @@ def get_key(): if ch in (b'\x00', b'\xe0'): # arrow or function key prefix? ch = msvcrt.getch() # second call returns the actual key code - if ch == b'\x03': - return const.KEY_CTRL_C + if ch in const.KEY_MAPPING: + return const.KEY_MAPPING[ch] if ch == b'H': return const.KEY_UP if ch == b'P': diff --git a/thefuck/ui.py b/thefuck/ui.py index 221f5238..37b14acd 100644 --- a/thefuck/ui.py +++ b/thefuck/ui.py @@ -14,9 +14,9 @@ def read_actions(): key = get_key() # Handle arrows, j/k (qwerty), and n/e (colemak) - if key in (const.KEY_UP, 'k', 'e'): + if key in (const.KEY_UP, const.KEY_CTRL_N, 'k', 'e'): yield const.ACTION_PREVIOUS - elif key in (const.KEY_DOWN, 'j', 'n'): + elif key in (const.KEY_DOWN, const.KEY_CTRL_P, 'j', 'n'): yield const.ACTION_NEXT elif key in (const.KEY_CTRL_C, 'q'): yield const.ACTION_ABORT