diff --git a/core/src/main/java/com/taobao/arthas/core/shell/system/impl/JobImpl.java b/core/src/main/java/com/taobao/arthas/core/shell/system/impl/JobImpl.java
index 66459de0..6f37e863 100644
--- a/core/src/main/java/com/taobao/arthas/core/shell/system/impl/JobImpl.java
+++ b/core/src/main/java/com/taobao/arthas/core/shell/system/impl/JobImpl.java
@@ -1,6 +1,8 @@
package com.taobao.arthas.core.shell.system.impl;
+import java.io.File;
import java.util.Date;
+import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import com.taobao.arthas.core.shell.future.Future;
@@ -11,6 +13,10 @@ import com.taobao.arthas.core.shell.session.Session;
import com.taobao.arthas.core.shell.system.ExecStatus;
import com.taobao.arthas.core.shell.system.Job;
import com.taobao.arthas.core.shell.system.Process;
+import com.taobao.arthas.core.shell.term.Term;
+import com.taobao.arthas.core.shell.term.impl.TermImpl;
+import com.taobao.arthas.core.util.Constants;
+import com.taobao.arthas.core.util.FileUtils;
/**
* @author Julien Viet
@@ -234,6 +240,12 @@ public class JobImpl implements Job {
}
terminateFuture.complete();
+ // save command history
+ Term term = shell.term();
+ if (term instanceof TermImpl) {
+ List history = ((TermImpl) term).getReadline().getHistory();
+ FileUtils.saveCommandHistory(history, new File(Constants.CMD_HISTORY_FILE));
+ }
}
}
diff --git a/core/src/main/java/com/taobao/arthas/core/util/FileUtils.java b/core/src/main/java/com/taobao/arthas/core/util/FileUtils.java
index 1c321efb..99cfcea3 100644
--- a/core/src/main/java/com/taobao/arthas/core/util/FileUtils.java
+++ b/core/src/main/java/com/taobao/arthas/core/util/FileUtils.java
@@ -104,7 +104,7 @@ public class FileUtils {
public static void saveCommandHistory(List history, File file) {
OutputStream out = null;
try {
- out = openOutputStream(file, false);
+ out = new BufferedOutputStream(openOutputStream(file, false));
for (int[] command: history) {
for (int i : command) {
out.write(i);