Skip to content

Commit 8e7a438

Browse files
Merge pull request #17 from nihaltp/feat/title
Add TitleCommand to set terminal window title
2 parents 1431ed6 + 38904c9 commit 8e7a438

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/main/java/com/mycmd/App.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ private static void registerCommands(Map<String, Command> commands) {
5151
commands.put("help", new HelpCommand(commands));
5252
commands.put("exit", new ExitCommand());
5353
commands.put("ver", new VersionCommand());
54+
commands.put("title", new TitleCommand());
5455
commands.put("hostname", new HostnameCommand());
5556
commands.put("whoami", new WhoamiCommand());
5657
commands.put("touch", new TouchCommand());
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.mycmd.commands;
2+
3+
import com.mycmd.Command;
4+
import com.mycmd.ShellContext;
5+
6+
public class TitleCommand implements Command {
7+
@Override
8+
public void execute(String[] args, ShellContext context) {
9+
if (args.length > 0) {
10+
String title = String.join(" ", args);
11+
System.out.println("\033]0;" + title + "\007");
12+
} else {
13+
System.out.println("Usage: title <new title>");
14+
}
15+
}
16+
17+
}

0 commit comments

Comments
 (0)