Replies: 3 comments 1 reply
|
Here is a helper function I use for the fish shell: # Defined in ~/.config/fish/functions/__jj_primary_root_if_linked.fish
function __jj_primary_root_if_linked --description 'Print the primary JJ workspace root from a linked workspace'
set -l jj_root (command jj root 2>/dev/null)
or return 1
test -f "$jj_root/.jj/repo"
or return 1
set -l rel (command cat "$jj_root/.jj/repo")
or return 1
path resolve "$jj_root/.jj/$rel"
end |
0 replies
|
I think there might be a typo: the third example script does not seem to be using fish syntax. From your gist, looks like that one is zsh. |
1 reply
|
I think this request is #8758, which is still open. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
How to find the backing repo of a non-default workspace?
So far I've found two ways, but neither is ideal:
If such a thing doesn't exist, I would ask the maintainers if they would be willing to add a JJ command for it?
jj workspace root --name defaultThis is not guaranteed to find the primary repo. It only works if primary workspace has not been renamed from its default "default" value.
resolve the contents of the
repofile to make a pathThis is guaranteed to work. Syntax depends on the shell.
Note: here I'm explaining how I do it for a non-colocated JJ project. In a non-default workspace, the file
.jj/repois plain text that contains a directory-relative path to the primary repo. (The primary repo does not have to be named "default".)LLM notice: scripts written by Claude Opus 5. Full write-up as a Gist.
I verified the above on my machine (macOS) for recent versions of all the shells.
Why?
I use nono as a sandbox for Claude and Codex. I have a wrapper script for each. When I launch my wrapper scripts, I want to tell the sandbox to give read+write access to the primary backing git repo, if I'm in a non-primary workspace.
All reactions