You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(cd/wt): move path check logic to command level
Move fzf selection and clipboard logic from shared helper to cd/wt commands.
This makes the flow clearer and implementation consistent across all three versions.
Flow:
- Path provided → call _open_shell/openShellInDir (opens shell)
- No path → use fzf selection, then copy to clipboard
Justfile.cross:
- _open_shell now only opens shell (path required)
- cd/wt commands handle path check and fzf/clipboard logic
- 3 lines in _open_shell, clear logic in cd/wt
Go (src-go/main.go):
- openShellInDir helper (path required, opens shell)
- cdCmd/wtCmd handle path check and fzf/clipboard logic
- Same structure as Justfile
Rust (src-rust/src/main.rs):
- open_shell_in_dir helper (path required, opens shell)
- Commands::Cd/Wt handle path check and fzf/clipboard logic
- Same structure as Justfile and Go
All three implementations now have identical logic flow.
Copy file name to clipboardExpand all lines: Justfile.cross
+25-14Lines changed: 25 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -771,36 +771,47 @@ _copy_to_clipboard text:
771
771
exit 1
772
772
fi
773
773
774
-
# Internal: Open shell or copy path (shared logic for cd/wt)
774
+
# Internal: Open shell in target directory
775
775
# target: "local_path" or "worktree"
776
+
# path: must be provided (non-empty)
776
777
[no-cd]
777
-
_open_shell target path="":
778
+
_open_shell target path:
778
779
#!/usr/bin/env fish
779
-
# If no path provided, use fzf to select
780
-
set -l selected_path "{{path}}"
781
-
if test -z "$selected_path"
782
-
set selected_path (just cross list | tail -n +3 | fzf --height 40% 2>/dev/null | awk '{print $NF}')
783
-
test -z "$selected_path" && exit 0
784
-
end
785
-
# Resolve context and determine target directory
786
-
just cross _resolve_context2 "$selected_path" | source || exit 1
780
+
just cross _resolve_context2 "{{path}}" | source || exit 1
787
781
set -l dir (test "{{target}}" = "local_path" && echo $local_path || echo $worktree)
788
-
# Open shell if path was provided, else copy to clipboard (fzf case)
789
-
test -n "{{path}}" && cd {{REPO_DIR}}/$dir && exec $SHELL || just cross _copy_to_clipboard {{REPO_DIR}}/$dir && just cross _log success "Path copied: $dir"
782
+
cd {{REPO_DIR}}/$dir && exec $SHELL
790
783
791
784
# Go to worktree directory (for working with git history)
792
785
# With path: opens subshell
793
786
# Without path: uses fzf selection and copies to clipboard
794
787
[no-cd]
795
788
wt path="":
796
-
just cross _open_shell worktree "{{path}}"
789
+
#!/usr/bin/env fish
790
+
if test -n "{{path}}"
791
+
just cross _open_shell worktree "{{path}}"
792
+
else
793
+
set -l selected (just cross list | tail -n +3 | fzf --height 40% 2>/dev/null | awk '{print $NF}')
794
+
test -z "$selected" && exit 0
795
+
just cross _resolve_context2 "$selected" | source || exit 1
796
+
just cross _copy_to_clipboard {{REPO_DIR}}/$worktree
797
+
just cross _log success "Path copied: $worktree"
798
+
end
797
799
798
800
# Go to local_path directory (for editing patched files)
799
801
# With path: opens subshell
800
802
# Without path: uses fzf selection and copies to clipboard
801
803
[no-cd]
802
804
cd path="":
803
-
just cross _open_shell local_path "{{path}}"
805
+
#!/usr/bin/env fish
806
+
if test -n "{{path}}"
807
+
just cross _open_shell local_path "{{path}}"
808
+
else
809
+
set -l selected (just cross list | tail -n +3 | fzf --height 40% 2>/dev/null | awk '{print $NF}')
810
+
test -z "$selected" && exit 0
811
+
just cross _resolve_context2 "$selected" | source || exit 1
812
+
just cross _copy_to_clipboard {{REPO_DIR}}/$local_path
813
+
just cross _log success "Path copied: $local_path"
814
+
end
804
815
805
816
806
817
# AICONTEXT: "status" shows status of current local_path patch vs. WT, and WT upstream. Input argument is local_path (or understand user stand in the under git-cross'ed local_path and call this comand). It shall be called to get status of local_path from "list" command. Either the status of remote WT upstream (as resource consuming, shall be optional or only ocasional)
0 commit comments