mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-07-08 15:56:09 +12:00
Implement ability to disable shell history
This commit is contained in:
parent
5dcb994f9b
commit
f0eccfb17b
|
@ -3,6 +3,7 @@ package io.xpipe.core.process;
|
|||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import io.xpipe.core.charsetter.NewLine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -32,6 +33,8 @@ public interface ShellType {
|
|||
.collect(Collectors.joining(" "));
|
||||
}
|
||||
|
||||
void disableHistory(ShellProcessControl pc) throws Exception;
|
||||
|
||||
default String getExitCommand() {
|
||||
return "exit";
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.Value;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -105,6 +106,10 @@ public class ShellTypes {
|
|||
return "@echo off\n" + content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableHistory(ShellProcessControl pc) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExitCodeVariable() {
|
||||
return "errorlevel";
|
||||
|
@ -212,6 +217,11 @@ public class ShellTypes {
|
|||
@Value
|
||||
public static class PowerShell implements ShellType {
|
||||
|
||||
@Override
|
||||
public void disableHistory(ShellProcessControl pc) throws Exception {
|
||||
pc.executeCommand("Set-PSReadLineOption -HistorySaveStyle SaveNothing");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addInlineVariablesToCommand(Map<String, String> variables, String command) {
|
||||
var content = "";
|
||||
|
@ -449,6 +459,11 @@ public class ShellTypes {
|
|||
return "echo " + prefix + "$" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableHistory(ShellProcessControl pc) throws Exception {
|
||||
pc.executeCommand("unset HISTFILE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExitCommand() {
|
||||
return "exit 0";
|
||||
|
|
Loading…
Reference in a new issue