Skip to content

Commit ac83043

Browse files
committed
Add .zsh_history support
1 parent ac83d17 commit ac83043

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

cmd/evade-bash-history/main.go renamed to cmd/evade-shell-history/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
func main() {
13-
if err := simulate.TruncateBashHistory(); err != nil {
13+
if err := simulate.TruncateShellHistory(); err != nil {
1414
log.Fatalf("unexpected error: %v", err)
1515
}
1616
}

pkg/simulate/bash_history.go renamed to pkg/simulate/shell_history.go

+7-2
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)