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 a way to initialize new terminals #91284

Closed
Hubro opened this issue Feb 24, 2020 · 3 comments
Closed

Add a way to initialize new terminals #91284

Hubro opened this issue Feb 24, 2020 · 3 comments

Comments

@Hubro
Copy link

Hubro commented Feb 24, 2020

For basically all my projects, I have a dev-session.sh script that sets up environment variables and paths for language runtimes (usually NodeJS and Python.)

Every time I open a new terminal in VSCode, I run source dev-session.sh.

It would save me a lot of key presses over the years if VSCode could add a way to automatically initialize new terminal windows.

One way to do this would be to make a general version of the vscode-python python.terminal.activateEnvironment option. For example an option like terminal.integrated.shellSetupCommand that I could set to a string like "source dev-session.sh".

All this would need to do is wait 500ms after a new terminal is opened, then write the contents of the setting followed by "\n".

@ArturoDent
Copy link

Do the shellArgs setting work for you?

@Hubro
Copy link
Author

Hubro commented Feb 24, 2020

Do the shellArgs setting work for you?

Doesn't that setting just let you pass options to the shell? (in my case, zsh)

I don't know of any way to use that option to achieve what I'm trying to do (open the shell like normal, but insert a command right after the shell opens.)

@Hubro
Copy link
Author

Hubro commented Feb 24, 2020

Huh... I've actually had this issue for quite a while, but just now I thought of a nice workaround. I've added this to the bottom of my .zshrc:

#
# Allow parent to initialize shell
#
if [[ -n $ZSH_INIT_COMMAND ]]; then
    echo "Running: $ZSH_INIT_COMMAND"
    eval "$ZSH_INIT_COMMAND"
fi

And I added this to my workspace settings:

{
  "settings": {
    "terminal.integrated.env.linux": {
      "ZSH_INIT_COMMAND": "source dev-session.sh"
    },

    // ...

It's not ideal, as it requires me to modify my shell config file, but it works perfectly. It eliminates my need for this feature though, so I'll just close this for now.

@Hubro Hubro closed this as completed Feb 24, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Apr 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@Hubro @ArturoDent and others