multiple worktree creation
This commit is contained in:
@@ -151,6 +151,7 @@ editor_command = "vi {file}"
|
|||||||
|
|
||||||
[worktree]
|
[worktree]
|
||||||
relative_worktree_path = "./.worktrees"
|
relative_worktree_path = "./.worktrees"
|
||||||
|
split_regex = ","
|
||||||
|
|
||||||
[env.override]
|
[env.override]
|
||||||
ZELLIJ_SESSION_NAME = ""
|
ZELLIJ_SESSION_NAME = ""
|
||||||
@@ -188,8 +189,9 @@ paste = "CTRL+SHIFT+V"
|
|||||||
- `Alt+Shift+h` / `Alt+Shift+l`: previous / next tab
|
- `Alt+Shift+h` / `Alt+Shift+l`: previous / next tab
|
||||||
- `Alt+t`: open the font selector
|
- `Alt+t`: open the font selector
|
||||||
- `Alt+s`: open the active pane scrollback in `$EDITOR`
|
- `Alt+s`: open the active pane scrollback in `$EDITOR`
|
||||||
- `Alt+w`: edit a worktree name, then run `git worktree add <relative_worktree_path>/<name>`
|
- `Alt+w`: edit one or more worktree names, split by `worktree.split_regex`, then run
|
||||||
from the previously focused pane's working directory
|
`git worktree add <relative_worktree_path>/<name>` for each name from the previously focused
|
||||||
|
pane's working directory
|
||||||
- `Alt+y`: enter pane-sync selection mode, commit the selection, or stop an active pane sync
|
- `Alt+y`: enter pane-sync selection mode, commit the selection, or stop an active pane sync
|
||||||
- `Space`: toggle the focused pane in the sync set while pane-sync selection mode is active
|
- `Space`: toggle the focused pane in the sync set while pane-sync selection mode is active
|
||||||
- Once committed, input typed or pasted into any synced pane is mirrored to the other synced panes
|
- Once committed, input typed or pasted into any synced pane is mirrored to the other synced panes
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ editor_command = "vi {file}"
|
|||||||
|
|
||||||
[worktree]
|
[worktree]
|
||||||
relative_worktree_path = "./.worktrees"
|
relative_worktree_path = "./.worktrees"
|
||||||
|
split_regex = ","
|
||||||
|
|
||||||
[env.override]
|
[env.override]
|
||||||
ZELLIJ_SESSION_NAME = ""
|
ZELLIJ_SESSION_NAME = ""
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public record AppConfig(
|
|||||||
boolean kittyGraphics,
|
boolean kittyGraphics,
|
||||||
String scrollbackEditorCommand,
|
String scrollbackEditorCommand,
|
||||||
String worktreeRelativePath,
|
String worktreeRelativePath,
|
||||||
|
String worktreeSplitRegex,
|
||||||
String closeSignal,
|
String closeSignal,
|
||||||
Map<String, String> envOverride,
|
Map<String, String> envOverride,
|
||||||
Map<String, KeyBinding> keybindings
|
Map<String, KeyBinding> keybindings
|
||||||
@@ -77,6 +78,7 @@ public record AppConfig(
|
|||||||
booleanValue(document, "kitty_graphics.enabled", defaults.kittyGraphics),
|
booleanValue(document, "kitty_graphics.enabled", defaults.kittyGraphics),
|
||||||
stringValue(document, "scrollback.editor_command", defaults.scrollbackEditorCommand),
|
stringValue(document, "scrollback.editor_command", defaults.scrollbackEditorCommand),
|
||||||
stringValue(document, "worktree.relative_worktree_path", defaults.worktreeRelativePath),
|
stringValue(document, "worktree.relative_worktree_path", defaults.worktreeRelativePath),
|
||||||
|
stringValue(document, "worktree.split_regex", defaults.worktreeSplitRegex),
|
||||||
closeSignalValue(document, defaults.closeSignal),
|
closeSignalValue(document, defaults.closeSignal),
|
||||||
envOverride(document, defaults.envOverride),
|
envOverride(document, defaults.envOverride),
|
||||||
keybindings(document, defaults)
|
keybindings(document, defaults)
|
||||||
@@ -100,6 +102,7 @@ public record AppConfig(
|
|||||||
true,
|
true,
|
||||||
defaultScrollbackEditorCommand(),
|
defaultScrollbackEditorCommand(),
|
||||||
"./.worktrees",
|
"./.worktrees",
|
||||||
|
",",
|
||||||
"SIGTERM",
|
"SIGTERM",
|
||||||
Map.of(),
|
Map.of(),
|
||||||
Map.ofEntries(
|
Map.ofEntries(
|
||||||
@@ -138,6 +141,7 @@ public record AppConfig(
|
|||||||
kittyGraphics,
|
kittyGraphics,
|
||||||
scrollbackEditorCommand,
|
scrollbackEditorCommand,
|
||||||
worktreeRelativePath,
|
worktreeRelativePath,
|
||||||
|
worktreeSplitRegex,
|
||||||
closeSignal,
|
closeSignal,
|
||||||
envOverride,
|
envOverride,
|
||||||
keybindings
|
keybindings
|
||||||
@@ -241,7 +245,8 @@ public record AppConfig(
|
|||||||
builder.append("[scrollback]\n");
|
builder.append("[scrollback]\n");
|
||||||
builder.append("editor_command = ").append(quoted(scrollbackEditorCommand)).append("\n\n");
|
builder.append("editor_command = ").append(quoted(scrollbackEditorCommand)).append("\n\n");
|
||||||
builder.append("[worktree]\n");
|
builder.append("[worktree]\n");
|
||||||
builder.append("relative_worktree_path = ").append(quoted(worktreeRelativePath)).append("\n\n");
|
builder.append("relative_worktree_path = ").append(quoted(worktreeRelativePath)).append('\n');
|
||||||
|
builder.append("split_regex = ").append(quoted(worktreeSplitRegex)).append("\n\n");
|
||||||
builder.append("[env.override]\n");
|
builder.append("[env.override]\n");
|
||||||
for (Map.Entry<String, String> entry : envOverride.entrySet()) {
|
for (Map.Entry<String, String> entry : envOverride.entrySet()) {
|
||||||
builder.append(entry.getKey()).append(" = ").append(quoted(entry.getValue())).append('\n');
|
builder.append(entry.getKey()).append(" = ").append(quoted(entry.getValue())).append('\n');
|
||||||
|
|||||||
@@ -313,14 +313,32 @@ final class TerminalWindow {
|
|||||||
if (relativePath == null || relativePath.isBlank()) {
|
if (relativePath == null || relativePath.isBlank()) {
|
||||||
relativePath = "./.worktrees";
|
relativePath = "./.worktrees";
|
||||||
}
|
}
|
||||||
|
String splitRegex = config.worktreeSplitRegex();
|
||||||
|
if (splitRegex == null || splitRegex.isBlank()) {
|
||||||
|
splitRegex = ",";
|
||||||
|
}
|
||||||
|
|
||||||
return editorCommand(file)
|
return editorCommand(file)
|
||||||
+ "; editor_status=$?"
|
+ "; editor_status=$?"
|
||||||
+ "; name=$(cat " + quotedFile + ")"
|
+ "; git_status=$editor_status"
|
||||||
+ "; if [ \"$editor_status\" -eq 0 ] && [ -n \"$name\" ]; then"
|
+ "; if [ \"$editor_status\" -eq 0 ]; then"
|
||||||
|
+ " if names_file=$(mktemp); then"
|
||||||
|
+ " if awk -v re=" + shellQuote(splitRegex)
|
||||||
|
+ " '{ text = text $0 \"\\n\" }"
|
||||||
|
+ " END { n = split(text, names, re); for (i = 1; i <= n; i++)"
|
||||||
|
+ " { name = names[i]; sub(/^[[:space:]]+/, \"\", name);"
|
||||||
|
+ " sub(/[[:space:]]+$/, \"\", name); if (name != \"\") print name; } }'"
|
||||||
|
+ " " + quotedFile + " > \"$names_file\"; then"
|
||||||
|
+ " git_status=0"
|
||||||
|
+ "; while IFS= read -r name; do"
|
||||||
+ " git worktree add " + shellQuote(relativePath) + "/\"$name\""
|
+ " git worktree add " + shellQuote(relativePath) + "/\"$name\""
|
||||||
+ "; git_status=$?"
|
+ " || { git_status=$?; break; }"
|
||||||
+ "; else git_status=$editor_status"
|
+ "; done < \"$names_file\""
|
||||||
|
+ "; else git_status=$?"
|
||||||
|
+ "; fi"
|
||||||
|
+ "; rm -f \"$names_file\""
|
||||||
|
+ "; else git_status=$?"
|
||||||
|
+ "; fi"
|
||||||
+ "; fi"
|
+ "; fi"
|
||||||
+ "; rm -f " + quotedFile
|
+ "; rm -f " + quotedFile
|
||||||
+ "; exit \"$git_status\"";
|
+ "; exit \"$git_status\"";
|
||||||
|
|||||||
Reference in New Issue
Block a user