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