1

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.

mattgately
  • 932
  • 8
  • 22
  • It seems that this question is the reverse of another question: http://stackoverflow.com/questions/9885053/perforce-p4-command-line-is-not-using-same-client-as-the-one-used-in-p4v And I found in http://answers.perforce.com/articles/KB/2911 that the p4v prefs are located in ~/.p4qt/, but I'm still not sure how to take the p4 environment variables and translate them directly to p4v prefs or p4v command-line options so that it pops up the correct workspace by default. – mattgately Nov 29 '16 at 15:20

1 Answers1

2

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]";
Samwise
  • 68,105
  • 3
  • 30
  • 44
  • Thanks Sam for getting me started with the `p4 info` formatting. I was unable to get the code to execute directly, but I posted my final _bash_ solution as an example. – mattgately Nov 29 '16 at 19:34