Environment Settings
Sublime Text 3 plugin that allows to define a set of Environment variables per project (in the .sublime_project)
Details
Installs
- Total 3K
- Win 1K
- OS X 981
- Linux 763
Apr 20 | Apr 19 | Apr 18 | Apr 17 | Apr 16 | Apr 15 | Apr 14 | Apr 13 | Apr 12 | Apr 11 | Apr 10 | Apr 9 | Apr 8 | Apr 7 | Apr 6 | Apr 5 | Apr 4 | Apr 3 | Apr 2 | Apr 1 | Mar 31 | Mar 30 | Mar 29 | Mar 28 | Mar 27 | Mar 26 | Mar 25 | Mar 24 | Mar 23 | Mar 22 | Mar 21 | Mar 20 | Mar 19 | Mar 18 | Mar 17 | Mar 16 | Mar 15 | Mar 14 | Mar 13 | Mar 12 | Mar 11 | Mar 10 | Mar 9 | Mar 8 | Mar 7 | Mar 6 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 3 | 4 | 0 | 4 | 3 | 0 | 2 | 2 | 1 | 3 | 2 | 2 | 2 | 0 | 0 | 2 | 1 | 1 | 0 | 0 | 1 | 0 | 2 | 0 | 0 | 0 | 3 | 0 | 4 | 2 | 4 | 4 | 0 | 4 | 4 | 4 | 8 | 3 | 4 | 0 | 0 | 3 | 4 | 6 | 3 |
OS X | 0 | 1 | 3 | 3 | 3 | 0 | 1 | 0 | 2 | 2 | 0 | 1 | 1 | 0 | 2 | 1 | 1 | 1 | 0 | 2 | 1 | 4 | 1 | 2 | 3 | 3 | 0 | 3 | 0 | 3 | 0 | 0 | 3 | 0 | 0 | 5 | 2 | 8 | 2 | 5 | 1 | 2 | 0 | 2 | 0 | 2 |
Linux | 1 | 1 | 4 | 0 | 1 | 1 | 0 | 1 | 0 | 5 | 2 | 1 | 1 | 1 | 1 | 5 | 2 | 0 | 0 | 0 | 0 | 3 | 2 | 2 | 0 | 0 | 1 | 3 | 2 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 5 | 2 | 4 | 1 | 2 | 1 | 1 | 3 | 2 |
Readme
- Source
- bitbucket.org
EnvironmentSettings
A plugin for SublimeText 3 that allows to set environment variables in the .sublime-project file.
Description:
Variables set with EnvironmentSettings are available throughout Sublime. Builds, scripts, even other plugins can relay and use them.
For example I use it to…
- set PYTHONPATH and have python run successfully scripts that use my custom tools, from within Sublime. Anaconda picks up my PYTHONPATH too and nicely present code completion on my custom code.
- Set PATH to point to some custom tools, for example FabricEngine's KL and then have a custom build that can call
kl $file
and run kl code from within Sublime - Define all the possible custom environment variables that my project needs. (obviously!)
The very nice thing about EnvironmentSettings is that all the variables it sets are set per project. EnvironmentSettings can catch when a Sublime's project change and re-set the environment variables accordingly. Even more, if you have two or more Sublime's windows open at the same time, each time you get focus on one of them, EnvironmentSettings will run and re-set the variables. All this is completely transparent to the user.
Setup Project Variables
The variables can be set in the “settings” part of a .sublime-project file.
Here two entries can be created:
- env_file
To point to an external shell file. If this file sets variables, those variables will be set also in Sublime.
Paths can be relative to the project file itself (ex: “../../env.sh”) - env
is a dictionary. Each key:value pair will be set as environment variable.
Both the entries can, actually must, specify which operative system the variables are for.
the possible values are the ones returned by the Python's function platform.system(). The value may change depending on the system you are but the common and most probable are:
- Linux
- Darwin (Mac OSX)
- Windows
At least one must be present.
For example:
{
"folders":
[
{
"path": "my/path"
}
],
"settings":
{
"env_file":
{
"Windows": "%HOME%/Documents/myEnv.bat",
"Darwin": "~/Documents/myEnv.sh",
"Linux": "~/Documents/myEnv.sh"
},
"env":
{
"Windows":
{
"PATH": "%PATH%;%HOME%/Documents/MyTool"
},
"Darwin":
{
"PATH": "$PATH:~/Documents/MyTool"
},
"Linux":
{
"PATH": "$PATH:~/Documents/MyTool"
}
}
}
}
User Variables
Beside setting variables per project, it's also possible to set variables for all the projects and sections of Sublime.
To do that, just open your user EnvironmentSettings.sublime-settings and set the variables in there.
To open the Users's EnvironmentSettings.sublime-settings go to Preferences -> Package Settings -> Environment Settings -> Settings (User)
example:
User's EnvironmentSettings.sublime-settings contents
{
"print_output": true,
"env_file":
{
"Windows": "%HOME%/Documents/myEnv.bat",
"Darwin": "~/Documents/myEnv.sh",
"Linux": "~/Documents/myEnv.sh"
},
"env":
{
"Windows":
{
"PATH": "%PATH%;%HOME%/Documents/MyTool"
},
"Darwin":
{
"PATH": "$PATH:~/Documents/MyTool"
},
"Linux":
{
"PATH": "$PATH:~/Documents/MyTool"
}
}
}
Settings
there are few settings you can change in EnvironmentSettings.sublime-settings:
print_output
When this is set to true, some informations are printed out to console.set_sublime_variables
If true some variables from within Sublime will be set too
this variables are:
“project_path”, “project”, “project_name”, “project_base_name”, “packages”sublime_variables_prefix
It may be useful to add a prefix to those variables so that they don't confict with yourssublime_variables_capitalized
Those variables can be all capitalised if you wish.
ex: “project” -> “PROJECT”
Note:
The variables in env_file are always set first. This means that env can potentially override what env_file did.
Installation
Using Package Control:
Go to Preferences -> Package Control -> Install Package then type into the text-box “Environment Settings”
Click on it, the package will be installed and ready for use.
Using Mercurial:
Locate your Sublime Text Packages directory by using the menu item Preferences -> Browse Packages.
While inside the Packages directory, clone EnvironmentSettings in it:
hg clone https://bitbucket.org/daniele-niero/environmentsettings