Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions doc/mshell.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions mshell/Main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -1667,6 +1668,7 @@ const (
KEY_END

KEY_ALT_B
KEY_ALT_D
KEY_ALT_F
KEY_ALT_O
KEY_ALT_DOT
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down