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

Add variable export mode #276

Open
alerque opened this issue Mar 29, 2021 · 3 comments
Open

Add variable export mode #276

alerque opened this issue Mar 29, 2021 · 3 comments

Comments

@alerque
Copy link
Collaborator

alerque commented Mar 29, 2021

Extracted from #248...

There are some cases where instead of opening a new shell using vcsh enter ... it would actually be more useful to setup the current shell for use with Git tooling connected to a VCSH repository.

Since it's impossible to manipulate the parent process environment the implementation for this would have to do what everybody else does: dump code that can be evaled in the parent shell. Usage might look like:

$ eval $(vcsh export repo_name)

This could be wrapped in a shell function in the user's profile something like this:

vcsh-switch () {
  eval $(vcsh export $1)
}

To be used thus:

$ vcsh-switch repo_name
@RichiH
Copy link
Owner

RichiH commented Mar 29, 2021

Historical context:

The earliest versions of vcsh allowed both being sourced and executed; which broke down trying to support Bash and Zsh at once. The overhead of execution is neglible.

vcsh export was "reserved" for putting vcsh repos onto remote machines which didn't have it installed, and vcsh import the inverse of taking in changes from remote machines. Not sure if the use case makes much sense any more. Would vcsh expose-work-tree or something make sense?

@alerque
Copy link
Collaborator Author

alerque commented Mar 29, 2021

I saw #75 re vcsh export after this. The name isn't that important, something like vcsh dump_vars might be better anyway.

The bash vs. zsh vs. foo thing should be a pretty much non issue if all that is involved is exporting some ENV vars. Whatever is being done along those lines already works across shells.

I'll have to review my own old use case for this. I know I scripted around it and it might not be important, but I do remember this being a pain point and thought it worth extracting from the other issue and reviewing on its own.

@RichiH
Copy link
Owner

RichiH commented Mar 30, 2021

Aye, NP. So let's keep export free and use something else; even if there's no active use case for you or me, exposing vars might still be useful and is easy enough to do.

As to Zsh/Bash/Posix: The early versions could be sourced and executed with the same codebase. Took some hacks, but was fun while it lasted :p

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

No branches or pull requests

2 participants