mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-30 00:56:56 +13:00
Add custom title to opened terminal windows
This commit is contained in:
parent
0845c7e27d
commit
7b36c1a96b
11 changed files with 20 additions and 13 deletions
|
@ -83,7 +83,7 @@ final class FileContextMenu extends ContextMenu {
|
|||
if (e != null) {
|
||||
pc.executeSimpleBooleanCommand(e);
|
||||
}
|
||||
var cmd = pc.command("\"" + entry.getPath() + "\"").prepareTerminalOpen();
|
||||
var cmd = pc.command("\"" + entry.getPath() + "\"").prepareTerminalOpen("?");
|
||||
TerminalHelper.open(FilenameUtils.getBaseName(entry.getPath()), cmd);
|
||||
});
|
||||
event.consume();
|
||||
|
|
|
@ -6,6 +6,7 @@ import io.xpipe.app.issue.ErrorEvent;
|
|||
import io.xpipe.app.util.BusyProperty;
|
||||
import io.xpipe.app.util.TerminalHelper;
|
||||
import io.xpipe.app.util.ThreadHelper;
|
||||
import io.xpipe.app.util.XPipeDaemon;
|
||||
import io.xpipe.core.impl.FileNames;
|
||||
import io.xpipe.core.store.ConnectionFileSystem;
|
||||
import io.xpipe.core.store.FileSystem;
|
||||
|
@ -277,7 +278,7 @@ final class OpenFileSystemModel {
|
|||
var connection = ((ConnectionFileSystem) fileSystem).getShellControl();
|
||||
var command = s.control()
|
||||
.initWith(connection.getShellDialect().getCdCommand(directory))
|
||||
.prepareTerminalOpen();
|
||||
.prepareTerminalOpen(directory + " - " + XPipeDaemon.getInstance().getStoreName(store.getValue()).orElse("?"));
|
||||
TerminalHelper.open(directory, command);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -14,7 +14,7 @@ public class LaunchExchangeImpl extends LaunchExchange
|
|||
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
|
||||
var store = getStoreEntryByName(msg.getName(), false);
|
||||
if (store.getStore() instanceof LaunchableStore s) {
|
||||
var command = s.prepareLaunchCommand();
|
||||
var command = s.prepareLaunchCommand(store.getName());
|
||||
var split = CommandLine.parse(command);
|
||||
return Response.builder().command(List.of(split.toStrings())).build();
|
||||
}
|
||||
|
|
|
@ -39,11 +39,15 @@ public class ScriptHelper {
|
|||
}
|
||||
|
||||
public static String constructInitFile(
|
||||
ShellControl processControl, List<String> init, String toExecuteInShell, boolean login) {
|
||||
ShellControl processControl, List<String> init, String toExecuteInShell, boolean login, String displayName) {
|
||||
ShellDialect t = processControl.getShellDialect();
|
||||
String nl = t.getNewLine().getNewLineString();
|
||||
var content = String.join(nl, init.stream().filter(s -> s != null).toList()) + nl;
|
||||
|
||||
if (displayName != null) {
|
||||
content = t.changeTitleCommand(displayName) + "\n" + content;
|
||||
}
|
||||
|
||||
if (login) {
|
||||
var applyProfilesCommand = t.applyProfileFilesCommand();
|
||||
if (applyProfilesCommand != null) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.io.IOException;
|
|||
public class TerminalHelper {
|
||||
|
||||
public static void open(String title, CommandControl cc) throws Exception {
|
||||
var command = cc.prepareTerminalOpen();
|
||||
var command = cc.prepareTerminalOpen(title);
|
||||
open(title, command);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public interface ProcessControl extends Closeable, AutoCloseable {
|
|||
|
||||
ProcessControl sensitive();
|
||||
|
||||
String prepareTerminalOpen() throws Exception;
|
||||
String prepareTerminalOpen(String displayName) throws Exception;
|
||||
|
||||
void closeStdin() throws IOException;
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ public interface ShellControl extends ProcessControl {
|
|||
|
||||
ShellControl withMessageFormatter(Function<String, String> formatter);
|
||||
|
||||
String prepareTerminalOpen() throws Exception;
|
||||
String prepareTerminalOpen(String displayName) throws Exception;
|
||||
|
||||
String prepareIntermediateTerminalOpen(String content) throws Exception;
|
||||
String prepareIntermediateTerminalOpen(String content, String displayName) throws Exception;
|
||||
|
||||
String getTemporaryDirectory() throws Exception;
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ public interface ShellDialect {
|
|||
return null;
|
||||
}
|
||||
|
||||
String changeTitleCommand(String newTitle);
|
||||
|
||||
default String applyProfileFilesCommand() {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import io.xpipe.core.process.CommandControl;
|
|||
public interface CommandExecutionStore extends DataStore, LaunchableStore {
|
||||
|
||||
@Override
|
||||
default String prepareLaunchCommand() throws Exception {
|
||||
return create().prepareTerminalOpen();
|
||||
default String prepareLaunchCommand(String displayName) throws Exception {
|
||||
return create().prepareTerminalOpen(displayName);
|
||||
}
|
||||
|
||||
CommandControl create() throws Exception;
|
||||
|
|
|
@ -2,5 +2,5 @@ package io.xpipe.core.store;
|
|||
|
||||
public interface LaunchableStore extends DataStore {
|
||||
|
||||
String prepareLaunchCommand() throws Exception;
|
||||
String prepareLaunchCommand(String displayName) throws Exception;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ public interface ShellStore extends DataStore, StatefulDataStore, LaunchableStor
|
|||
}
|
||||
|
||||
@Override
|
||||
default String prepareLaunchCommand() throws Exception {
|
||||
return control().prepareTerminalOpen();
|
||||
default String prepareLaunchCommand(String displayName) throws Exception {
|
||||
return control().prepareTerminalOpen(displayName);
|
||||
}
|
||||
|
||||
default ShellControl control() {
|
||||
|
|
Loading…
Reference in a new issue