File tree 2 files changed +8
-3
lines changed
2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import (
10
10
)
11
11
12
12
func main () {
13
- if err := simulate .TruncateBashHistory (); err != nil {
13
+ if err := simulate .TruncateShellHistory (); err != nil {
14
14
log .Fatalf ("unexpected error: %v" , err )
15
15
}
16
16
}
Original file line number Diff line number Diff line change @@ -10,13 +10,18 @@ import (
10
10
cp "github.com/otiai10/copy"
11
11
)
12
12
13
- func TruncateBashHistory () error {
13
+ func TruncateShellHistory () error {
14
14
home , err := os .UserHomeDir ()
15
15
if err != nil {
16
16
return fmt .Errorf ("home dir: %w" , err )
17
17
}
18
18
19
19
path := filepath .Join (home , ".bash_history" )
20
+ _ , err = os .Stat (path )
21
+ if err != nil {
22
+ path = filepath .Join (home , ".zsh_history" )
23
+ }
24
+
20
25
log .Printf ("backing up %s ..." , path )
21
26
if err := cp .Copy (path , path + ".bak" ); err != nil {
22
27
return fmt .Errorf ("copy: %w" , err )
@@ -42,6 +47,6 @@ func TruncateBashHistory() error {
42
47
}
43
48
44
49
log .Printf ("stat: %+v" , s )
45
- time .Sleep (1 * time .Second )
50
+ time .Sleep (15 * time .Second )
46
51
return nil
47
52
}
You can’t perform that action at this time.
0 commit comments