Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support a different target in each terminal window #9

Open
scottfrederick opened this issue Mar 7, 2016 · 4 comments
Open

Support a different target in each terminal window #9

scottfrederick opened this issue Mar 7, 2016 · 4 comments

Comments

@scottfrederick
Copy link

Nice plugin @guidowb. I have a bash script that I've been using for a similar purpose, but I like the idea of using a CLI plugin instead.

However, my script has an additional feature that I find indispensable. It not only makes it fast and easy to switch targets, but allows each open terminal window to use a different target. It does this by creating a cf config directory for each target like your plugin does, but also sets CF_HOME to point to that directory. Since CF_HOME is specific to a terminal session, I can switch between terminal windows and have each window targeting a different org and space.

Any chance you could enhance this plugin to do something similar?

@guidowb
Copy link
Owner

guidowb commented Mar 7, 2016

Love that idea. No promises but will give it some thought.

@bfrancom
Copy link

Nice plugin @guidowb. I have a bash script that I've been using for a similar purpose, but I like the idea of using a CLI plugin instead.

However, my script has an additional feature that I find indispensable. It not only makes it fast and easy to switch targets, but allows each open terminal window to use a different target. It does this by creating a cf config directory for each target like your plugin does, but also sets CF_HOME to point to that directory. Since CF_HOME is specific to a terminal session, I can switch between terminal windows and have each window targeting a different org and space.

Any chance you could enhance this plugin to do something similar?

Does your script still work @scottfrederick ? Do you have a link? Thanks!

@guidowb
Copy link
Owner

guidowb commented Aug 14, 2019

I've always liked this feature suggestion and never thought of a good way to implement this. The plugin doesn't get invoked when using a different cf ... command so it can't intervene based on current directory at the other command's execution time. It just manipulates the config files used by subsequent command invocations.

The best alternative I'm aware of is to use it in conjunction with something like direnv, and use a .envrc file to invoke the appropriate cf set-target <name>. I could probably improve that a little by supporting a special target name like ., so you don't have to create a named target for each directory.

@scottfrederick
Copy link
Author

Here's my script. You'll need to source cfenv.sh somewhere in a .rc file or equivalent for your shell.

I didn't write this myself. I originally got this from someone else who is better at writing shell scripts than I am. I'd give proper attribution but it's been way to long for me to remember who I got it from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants