Skip to content

Commit dff4793

Browse files
committed
Bind Alt+F7 to ClearHistory
cmd/PowerShell Windows mode supports clearing history with Alt+F7, so PSReadline will too.
1 parent 8b5ee55 commit dff4793

File tree

6 files changed

+30
-7
lines changed

6 files changed

+30
-7
lines changed

PSReadLine/Changes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ New key bindings:
2929
* Ctrl+N/Ctrl+P bound to NextHistory/PreviousHistory in Emacs mode
3030
* Ctrl+PageUp bound to ScrollDisplayUpLine
3131
* Ctrl+PageDown bound to ScrollDisplayDownLine
32+
* Alt+F7 bound to ClearHistory in Windows mode
3233

3334
New options:
3435
* Set-PSReadlineOption

PSReadLine/History.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public static void AddToHistory(string command)
248248
/// <summary>
249249
/// Clears history in PSReadline. This does not affect PowerShell history.
250250
/// </summary>
251-
public static void ClearHistory()
251+
public static void ClearHistory(ConsoleKeyInfo? key = null, object arg = null)
252252
{
253253
if (_singleton._history != null)
254254
{

PSReadLine/KeyBindings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ void SetDefaultWindowsBindings()
135135
{ Keys.Alt9, MakeKeyHandler(DigitArgument, "DigitArgument") },
136136
{ Keys.AltMinus, MakeKeyHandler(DigitArgument, "DigitArgument") },
137137
{ Keys.AltQuestion, MakeKeyHandler(WhatIsKey, "WhatIsKey") },
138+
{ Keys.AltF7, MakeKeyHandler(ClearHistory, "ClearHistory") },
138139
{ Keys.F3, MakeKeyHandler(CharacterSearch, "CharacterSearch") },
139140
{ Keys.ShiftF3, MakeKeyHandler(CharacterSearchBackward, "CharacterSearchBackward") },
140141
{ Keys.F8, MakeKeyHandler(HistorySearchBackward, "HistorySearchBackward") },

PSReadLine/Keys.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,31 @@ public static class Keys
254254
public static ConsoleKeyInfo F23 = new ConsoleKeyInfo((char)0, ConsoleKey.F23, false, false, false);
255255
public static ConsoleKeyInfo F24 = new ConsoleKeyInfo((char)0, ConsoleKey.F24, false, false, false);
256256

257+
public static ConsoleKeyInfo AltF1 = new ConsoleKeyInfo((char)0, ConsoleKey.F1, false, true, false);
258+
public static ConsoleKeyInfo AltF2 = new ConsoleKeyInfo((char)0, ConsoleKey.F2, false, true, false);
259+
public static ConsoleKeyInfo AltF3 = new ConsoleKeyInfo((char)0, ConsoleKey.F3, false, true, false);
260+
public static ConsoleKeyInfo AltF4 = new ConsoleKeyInfo((char)0, ConsoleKey.F4, false, true, false);
261+
public static ConsoleKeyInfo AltF5 = new ConsoleKeyInfo((char)0, ConsoleKey.F5, false, true, false);
262+
public static ConsoleKeyInfo AltF6 = new ConsoleKeyInfo((char)0, ConsoleKey.F6, false, true, false);
263+
public static ConsoleKeyInfo AltF7 = new ConsoleKeyInfo((char)0, ConsoleKey.F7, false, true, false);
264+
public static ConsoleKeyInfo AltF8 = new ConsoleKeyInfo((char)0, ConsoleKey.F8, false, true, false);
265+
public static ConsoleKeyInfo AltF9 = new ConsoleKeyInfo((char)0, ConsoleKey.F9, false, true, false);
266+
public static ConsoleKeyInfo AltFl0 = new ConsoleKeyInfo((char)0, ConsoleKey.F10, false, true, false);
267+
public static ConsoleKeyInfo AltF11 = new ConsoleKeyInfo((char)0, ConsoleKey.F11, false, true, false);
268+
public static ConsoleKeyInfo AltF12 = new ConsoleKeyInfo((char)0, ConsoleKey.F12, false, true, false);
269+
public static ConsoleKeyInfo AltF13 = new ConsoleKeyInfo((char)0, ConsoleKey.F13, false, true, false);
270+
public static ConsoleKeyInfo AltF14 = new ConsoleKeyInfo((char)0, ConsoleKey.F14, false, true, false);
271+
public static ConsoleKeyInfo AltF15 = new ConsoleKeyInfo((char)0, ConsoleKey.F15, false, true, false);
272+
public static ConsoleKeyInfo AltF16 = new ConsoleKeyInfo((char)0, ConsoleKey.F16, false, true, false);
273+
public static ConsoleKeyInfo AltF17 = new ConsoleKeyInfo((char)0, ConsoleKey.F17, false, true, false);
274+
public static ConsoleKeyInfo AltF18 = new ConsoleKeyInfo((char)0, ConsoleKey.F18, false, true, false);
275+
public static ConsoleKeyInfo AltF19 = new ConsoleKeyInfo((char)0, ConsoleKey.F19, false, true, false);
276+
public static ConsoleKeyInfo AltF20 = new ConsoleKeyInfo((char)0, ConsoleKey.F20, false, true, false);
277+
public static ConsoleKeyInfo AltF21 = new ConsoleKeyInfo((char)0, ConsoleKey.F21, false, true, false);
278+
public static ConsoleKeyInfo AltF22 = new ConsoleKeyInfo((char)0, ConsoleKey.F22, false, true, false);
279+
public static ConsoleKeyInfo AltF23 = new ConsoleKeyInfo((char)0, ConsoleKey.F23, false, true, false);
280+
public static ConsoleKeyInfo AltF24 = new ConsoleKeyInfo((char)0, ConsoleKey.F24, false, true, false);
281+
257282
public static ConsoleKeyInfo ShiftF3 = new ConsoleKeyInfo((char)0, ConsoleKey.F3, true, false, false);
258283
public static ConsoleKeyInfo ShiftF8 = new ConsoleKeyInfo((char)0, ConsoleKey.F8, true, false, false);
259284

PSReadLine/PSReadLineResources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
<data name="ClearKillRingDescription" xml:space="preserve">
148148
<value>Remove all items from the kill ring</value>
149149
</data>
150-
<data name="ClearyHistoryDescription" xml:space="preserve">
150+
<data name="ClearHistoryDescription" xml:space="preserve">
151151
<value>Remove all items from the command line history (not PowerShell history)</value>
152152
</data>
153153
<data name="CompleteDescription" xml:space="preserve">

PSReadLine/en-US/about_PSReadline.help.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ LONG DESCRIPTION
216216
History
217217
-------
218218

219-
ClearHistory (Cmd: unbound Emacs: unbound)
219+
ClearHistory (Cmd: Alt+F7 Emacs: unbound)
220220

221221
Clears history in PSReadline. This does not affect PowerShell history.
222222

@@ -545,10 +545,6 @@ LONG DESCRIPTION
545545

546546
Add a command line to history without executing it.
547547

548-
void ClearHistory()
549-
550-
Clear the history.
551-
552548
void ClearKillRing()
553549

554550
Clear the kill ring. This is mostly used for testing.

0 commit comments

Comments
 (0)