mattgately
mattgately

Reputation: 1042

automatic selection of workspace when launching p4v

In the shell, when I am in a directory located as part of a p4 workspace, I can run p4 commands in the shell and it knows what workspace I am in.

However, when I launch p4v, I have to manually find the workspace that I want to load. Since, the context of p4 commands to run is already known in the shell, how I can I pass that to p4v, so it will launch in the same workspace. There's no reason why I should have to select a workspace when I launch the tool, since the p4 toolchain already can self-determine the context.

I should only have to select the workspace if I am wanting to select some other workspace that I am not currently operating under.

Upvotes: 1

Views: 256

Answers (1)

Samwise
Samwise

Reputation: 71542

As you've found, P4V has its own settings file and ignores the shell's environment. Per this blog post:

https://www.perforce.com/blog/100114/p4v-secrets-calling-p4v-command-line

the way I'd handle this would be to write a script/alias that wraps P4V and passes the current environment to it. Something along these lines:

$_ = `p4 -Ztag -F "%serverAddress%@%clientName%@%userName%" info`;
@env = split /\@/;
exec "p4v -p $env[0] -c $env[1] -u $env[2]";

Upvotes: 2

Related Questions