diff --git a/CHANGELOG.md b/CHANGELOG.md index 79a52ab..d0aeb9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `sqrt` - `randomTri` - `tempFileExt` +- CLI Alt-D inserts the current date as `YYYY-MM-DD` ### Fixed diff --git a/doc/mshell.md b/doc/mshell.md index c87d577..2d56a76 100644 --- a/doc/mshell.md +++ b/doc/mshell.md @@ -6,6 +6,7 @@ History search is prefix-based and case-insensitive. The prefix is whatever is c - Ctrl-N: search forward through history by prefix - Ctrl-Y: accept the inline history completion - Ctrl-Space: insert a literal space without expanding aliases +- Alt-D: insert the current date as YYYY-MM-DD - Alt-.: insert the last argument from history; repeat to cycle older entries - Tab: complete the current token; press Tab again to cycle matches and fill the input - Shift-Tab: cycle completion backward when matches are active diff --git a/mshell/Main.go b/mshell/Main.go index c746b03..91b6dca 100644 --- a/mshell/Main.go +++ b/mshell/Main.go @@ -1635,6 +1635,7 @@ var SpecialKeyName = []string{ "KEY_HOME", "KEY_END", "KEY_ALT_B", + "KEY_ALT_D", "KEY_ALT_F", "KEY_ALT_O", "KEY_ALT_DOT", @@ -1667,6 +1668,7 @@ const ( KEY_END KEY_ALT_B + KEY_ALT_D KEY_ALT_F KEY_ALT_O KEY_ALT_DOT @@ -1941,6 +1943,8 @@ func (state *TermState) InteractiveLexer(stdinReaderState *StdinReaderState) (Te } else if c == 98 { // Alt-B // Move cursor left by word return KEY_ALT_B, nil + } else if c == 100 { // Alt-D + return KEY_ALT_D, nil } else if c == 102 { // Alt-F // Move cursor right by word return KEY_ALT_F, nil @@ -3309,6 +3313,9 @@ func (state *TermState) HandleToken(token TerminalToken) (bool, error) { fmt.Fprintf(os.Stdout, "\r\n") fmt.Fprintf(state.f, "Exiting mshell using ALT-o...\n") return true, nil + } else if t == KEY_ALT_D { + dateStr := time.Now().Format("2006-01-02") + state.PushChars([]rune(dateStr)) } else if t == KEY_ALT_DOT { state.cycleLastArgument() } else if t == KEY_SHIFT_TAB {