Store cwd in history

This commit is contained in:
Kovid Goyal 2022-11-02 08:06:52 +05:30
parent c8e8cb5ad5
commit 8574e136cd
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 2 deletions

View File

@ -120,7 +120,8 @@ func exec_command(rl *readline.Readline, cmdline string) bool {
if len(parsed_cmdline) == 0 {
return true
}
hi := readline.HistoryItem{Timestamp: time.Now(), Cmd: cmdline, ExitCode: -1}
cwd, _ := os.Getwd()
hi := readline.HistoryItem{Timestamp: time.Now(), Cmd: cmdline, ExitCode: -1, Cwd: cwd}
switch parsed_cmdline[0] {
case "exit":
hi.ExitCode = 0

View File

@ -16,8 +16,9 @@ var _ = fmt.Print
type HistoryItem struct {
Cmd string `json:"cmd"`
Cwd string `json:"cwd,omitempty"`
Timestamp time.Time `json:"timestamp"`
Duration time.Duration `json:"duration"`
Duration time.Duration `json:"duration,omitempty"`
ExitCode int `json:"exit_code"`
}