Skip to content

Commit c7b33c3

Browse files
mibkbradfitz
authored andcommitted
ssh/terminal: support ^N and ^P
This makes it possible to navigate the history without leaving the home row on the keyboard. Change-Id: Id24c43f8eb6090520ab37bf8126264901b70c489 Reviewed-on: https://go-review.googlesource.com/c/33618 Run-TryBot: Matt Layher <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Matt Layher <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 057139c commit c7b33c3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Diff for: ssh/terminal/terminal.go

+4
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ func bytesToKey(b []byte, pasteActive bool) (rune, []byte) {
159159
return keyClearScreen, b[1:]
160160
case 23: // ^W
161161
return keyDeleteWord, b[1:]
162+
case 14: // ^N
163+
return keyDown, b[1:]
164+
case 16: // ^P
165+
return keyUp, b[1:]
162166
}
163167
}
164168

Diff for: ssh/terminal/terminal_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ var keyPressTests = []struct {
9191
{
9292
in: "\x1b[B\r", // down
9393
},
94+
{
95+
in: "\016\r", // ^P
96+
},
97+
{
98+
in: "\014\r", // ^N
99+
},
94100
{
95101
in: "line\x1b[A\x1b[B\r", // up then down
96102
line: "line",

0 commit comments

Comments
 (0)