今天主要介绍Sublime Text2 的 package control.
资料地址:http://wbond.net/sublime_packages/package_control/installation
Installaton
Please note that the following method can not validate the sublime.wbond.net SSL certificate. If you have concern over the security of the download, please follow the Manual Instructions below.
Installation is through the Sublime Text 2 console. This is accessed via the ctrl+` shortcut. Once open, paste the following command into the console.
This command creates the Installed Packages folder for you (if necessary), and then downloads the Package Control.sublime-package into it.
Manual Instructions
If for some reason the console installation instructions do not work for you (such as having a proxy on your network), perform the following steps to manually install Package Control:
- Click the Preferences > Browse Packages… menu entry
- Browse up a folder and then into the Installed Packages folder
- Download Package Control.sublime-package and copy it into the Installed Packages directory
- Restart Sublime Text
Testing Version
If you want to help test the latest changes, or you are having trouble with the stable version (v1.6.3) of Package Control, please use the instructions below to install the testing version (v1.6.9.0). See the testing version changelog on GitHub.
Notable changes include:
- Refactoring in prep to support Python 3 for Sublime Text 3.
Upgrade
If you already have Package Control installed and want to help test the new version.
- Run the Package Control: Add Repository command via the command palette and enter the following URL:
https://sublime.wbond.net/testing/packages.json - Run the Package Control: Upgrade Package command and select Package Control from the list
Manual Install
If Package Control is not currently working for you, you’ll have to manually install.
- Click the Preferences > Browse Packages… menu entry
- Browse up a folder and then into the Installed Packages folder
- Download the testing version of Package Control.sublime-package and copy it into the Installed Packages directory
- Restart Sublime Text
- Run the Package Control: Add Repository command via the command palette and enter the URL to keep the testing version of Package Control up-to-date:
https://sublime.wbond.net/testing/packages.json
Sublime Text 3
There is an alpha quality release of Package Control for Sublime Text 3 available. Please note that it currently functions the same as for ST2, however there will be changes in the future to properly support the new preferred method of keeping .sublime-package files on disk instead of extracting them to the Packages/ folder.
Please use GitHub issues and prefix all bug titles with ST3: .
Git Install
Since Sublime Text 3 no longer extracts the contents of .sublime-package files by default, and the fact that Package Control needs to read CA cert files from disk for SSL certificate verification, the only viable install method right now is via Git.
Please note, the Packages/ folder listed below refers to the folder that opens when you use the Preferences > Browse Packages…menu.
git clone https://github.com/wbond/sublime_package_control.git "Package Control"
cd "Package Control"
git checkout python3
Testing on Sublime Text 2
The new version of Package Control is targetted at both Sublime Text 2 and Sublime Text 3. If you are still running ST2, and can help, please spend some time testing to make sure it does not regress.
- Run the Package Control: Add Repository command via the command palette and enter the following URL:
https://sublime.wbond.net/alpha/packages.json - Run the Package Control: Upgrade Package command and select Package Control from the list
Usage
Package Control is driven by the Command Pallete. To open the pallete, press ctrl+shift+p (Windows, Linux) or cmd+shift+p (OS X). All Package Control commands begin with Package Control:, so start by typing Package.
The command pallete will now show a number of commands. Most users will be interested in the following:
-
Install Package
- Show a list of all available packages that are available for install. This will include all of the packages from the default channel, plus any from repositories you have added. Add Repository
- Add a repository that is not included in the default channel. This allows users to install and automatically update packages from GitHub and BitBucket. To add a package hosted on GitHub, enter the URL in the form https://github.com/username/repo. Don’t include .git at the end! BitBucket repositories should use the format https://bitbucket.org/username/repository. Remove Package
- This removes the package folder, and the package name from the installed_packages list in Packages/User/Package Control.sublime-settings. The installed_packages list allow Package Control to automatically install packages for you if you copy your Packages/User/ folder to another machine.
By default Package Control checks for new versions on startup. This setting, plus the list of channels and repositories are managed through theSettings.
Additional commands include:
-
Add Repository Channel
- Adds another channel that lists repositories. This is uncommon, but allows users to create a custom channel of repositories to share. Create Package File
- For package developers. Takes a package folder and generates a .sublime-package file that can be uploaded onto the web and referenced in the packages.json file for a repository. Create Binary Package File
- For package developers. Creates a .sublime-package file that does not include the source .py files, but instead the .pyc bytecode files. This is useful to distribute commercial packages. Be sure to check the resulting .sublime-package file to ensure that at least one .py file is included so that Sublime Text will load the package. Disable Package
- Disables a package, which causes any Python scripts to be unloaded, and other files such as .sublime-keymap files to be unloaded also. Discover Packages
- Opens up a web browser to the Community Packages list. Enable Package
- Re-enables a package that has been disabled. Upgrade/Overwrite All Packages
- This will upgrade ALL packages, including ones that were not installed via Package Control. If you are developing a custom copy of a package, you may not want to use this command. Upgrade Package
- Show a list of packages that are available for upgrade and let the user pick which they would like to update. Package Control Settings – Default
- Open the default settings file, which can be used as a reference for changing the User settings. Any changes to this file will be lost whenever Package Control is automatically or manually upgraded. Package Control Settings – User
- Opens the user’s settings for Package Control. Any settings changes should be saved here so they are not overwritten when a new version of Package Control is released.
Settings
The default settings can be viewed by accessing the Preferences > Package Settings > Package Control > Settings – Default menu entry. To ensure settings are not lost when the package is upgraded, make sure all edits are saved to Settings – User.
-
debug
-
If set to
true, will print HTTP headers and other debug information to the Sublime Text console.
Default: false
submit_usage
-
If installs, upgrades and removals should be logged to the reporting URL. This data will be used to power the community package listing and will be displayed in aggregate only. No user-identifiable information is sent, just the: package name, operation, package version, package control version, sublime version and sublime platform.
Default: yes
submit_url
-
Where the usage information should be sent to.
Default: "http://sublime.wbond.net/submit"
installed_packages
-
A list of packages that have been installed. Package Control will automatically install any packages in this list that are not currently installed, allowing this to be used for sharing package lists with other users. This setting is only tracked in Settings – User.
Default: []
repository_channels
-
A list of URLs that each contain a JSON file with a list of repositories. The repositories from these channels are placed in order after the repositories from the
repositories setting.
Default: ["http://sublime.wbond.net/repositories.json"]
repositories
-
A list of URLs that contain a packages JSON file. These repositories are placed in order before repositories from the
repository_channelssetting.
Default: []
package_name_map
-
This helps solve naming issues where a repository it not named the same as the package should be. This is primarily only useful for GitHub and BitBucket repositories. This mapping will override the mapping that is retrieved from the repository channels.
Default: {}
auto_upgrade
-
If packages installed via Package Control should be checked for updates when Sublime Text starts. Updates will be automatically installed.
Default: true
auto_upgrade_frequency
-
The number of hours to wait before trying to auto upgrade packages again.
Default: 6
auto_upgrade_ignore
-
Packages to exclude from the auto upgrade functionality.
Default: []
install_missing
-
If set to
false, will not automatically install packages from the
installed_packages setting that are not present on the current machine. This is really only useful if you don’t want Sublime Text to connect to the internet without explicitly requesting it. In that case you’ll want to set
auto_upgrade to
false also.
Default: true
timeout
-
The HTTP timeout (in seconds) to use when downloading channels, repositories and packages.
Default: 30
cache_length
-
The number of seconds to cache channel and repository metadata for.
Default: 300
http_proxy
-
The proxy to use for HTTP requests. Should be in the form
domainname:port or
ip:port.
Default: ""
https_proxy
-
The proxy to use for HTTPS requests. If
http_proxy is set and this settings is not, the value from
http_proxy will be used. If set to
false, then
http_proxy will not be inherited. Should be in the form
domainname:port or
ip:port.
Default: ""
proxy_username
- The username to use for proxy authentication. Default: "" proxy_password
- The password to use for proxy authentication. Default: "" user_agent
- The user agent used by the various downloaders. Default: "Sublime Package Control" git_binary
-
The path to git, when using a git repository to track a package. When an empty string, Package Control will look in default locations for the current OS.
Default: ""
git_update_command
-
The parameters passed to git to update a package.
Default: ["pull", "origin", "master"]
hg_binary
-
The path to hg, when using an hg repository to track a package. When an empty string, Package Control will look in default locations for the current OS.
Default: ""
hg_update_command
-
The parameters to pass to hg to update a package. Be sure to keep the remote name as the last parameter, even if it is
default.
Default: ["pull", "--update", "default"]
ignore_vcs_packages
-
If git and hg repositories should be ignored when trying to update packages.
Default: false
dirs_to_ignore
-
A list of folders to ignore when creating a
.sublime-package file.
Default: [".hg", ".git", ".svn", "_darcs", "CVS"]
files_to_ignore
-
A list of file glob patterns to ignore when creating a
.sublime-package file.
Default: [".hgignore", ".gitignore", ".bzrignore", "*.pyc", "*.sublime-project", "*.tmTheme.cache"]
package_destination
-
The folder to copy a newly created package to. Default to the user’s Desktop if blank. Setting this destination to the
Installed Packagesdirectory will cause your source code changes to be overwritten when Sublime Text restarts!
Default: ""
certs
-
A list of CA cert information for the purpose of providing a secure way to download packages. A default list is provided with Package Control, but then the default repository channel provides updates to the list. It is also possible to add your own entries for custom download locations, or for supporting your local proxy server.
To add your own, be sure to copy the JSON object below and then add your custom entries. The key in the JSON object is the domain the cert applies to. The value is an array with two elements, the first being an identifier for the cert, and the second being a location to copy the cert from. The identifier is used to ensure that Package Control has a copy of the latest version of the cert in its certs/ folder. The location can be either an absolute file path on your local machine, or a URL to download it from.
To create a CA cert that is ensured to be present no matter what domain is being accessed (such as for a proxy server), set the domain name to *, like in the example on the next line:
"*": ["my_proxy_cert", "/file/path/to/proxy/ca_certs"]
This ca cert needs to live somewhere on your machine permanently so that it can be re-added to the ca-bundle.crt file that is provided with each Package Control upgrade.
Default:{ "api.bitbucket.org": ["d867a7b2aecc46f9c31afc4f2f50de05", ""], "api.github.com": ["1c5282418e2cb4989cd6beddcdbab0b5", ""], "bitbucket.org": ["897abe0b41fd2f64e9e2e351cbc36d76", ""], "nodeload.github.com": ["1c5282418e2cb4989cd6beddcdbab0b5", ""], "raw.github.com": ["1c5282418e2cb4989cd6beddcdbab0b5", ""], "sublime.wbond.net": ["7f4f8622b4fd001c7f648e09aae7edaa", ""] }