File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import (
1010)
1111
1212func main () {
13- if err := simulate .TruncateBashHistory (); err != nil {
13+ if err := simulate .TruncateShellHistory (); err != nil {
1414 log .Fatalf ("unexpected error: %v" , err )
1515 }
1616}
Original file line number Diff line number Diff line change @@ -10,13 +10,18 @@ import (
1010 cp "github.com/otiai10/copy"
1111)
1212
13- func TruncateBashHistory () error {
13+ func TruncateShellHistory () error {
1414 home , err := os .UserHomeDir ()
1515 if err != nil {
1616 return fmt .Errorf ("home dir: %w" , err )
1717 }
1818
1919 path := filepath .Join (home , ".bash_history" )
20+ _ , err = os .Stat (path )
21+ if err != nil {
22+ path = filepath .Join (home , ".zsh_history" )
23+ }
24+
2025 log .Printf ("backing up %s ..." , path )
2126 if err := cp .Copy (path , path + ".bak" ); err != nil {
2227 return fmt .Errorf ("copy: %w" , err )
@@ -42,6 +47,6 @@ func TruncateBashHistory() error {
4247 }
4348
4449 log .Printf ("stat: %+v" , s )
45- time .Sleep (1 * time .Second )
50+ time .Sleep (15 * time .Second )
4651 return nil
4752}
You can’t perform that action at this time.
0 commit comments