jsmecham / atom-terminal-tab

Simple terminal for the Atom text editor.
https://atom.io/packages/terminal-tab
MIT License
143 stars 29 forks source link

Is it possible to set launch options? #106

Closed embeddedpenguin closed 4 years ago

embeddedpenguin commented 5 years ago

So I'm trying to use atom for embedded applications, and I want to set an environment variable on launch and possibly remote it upon closure of the terminal. I see there is a "Sanitized Environment Variables" but I'm not sure how to add multiples.

I also need it to set the environment variables after it's already opened because I need it to export its own PID. So like on launch: export DESIRED_PID=$$

Is this possible with the Sanitized Environment Variables field?

Arcesilas commented 5 years ago

I know this issue is a little old...

It seems you have to use a custom command.

Edit your init script and add something like this:

atom.commands.add 'atom-workspace', 'custom:init-term', ->
    atom.workspace.open('terminal-tab://')
        .then (term) ->
            term.pty.write('export DESIRED_PID=$$\n')
            term.pty.clear()

Reload the window from the command palette, then run your custom command (custom:init-term) then type echo $DESIRED_PID in the terminal that has just opened.

You can add a keybinding to open a terminal with this custom command. Obviously, you can execute more than one command when opening the terminal.