Copy Relative Command
Copy's a command relative of your current active file!
Details
Installs
- Total 134
- Win 77
- Mac 41
- Linux 16
| Dec 25 | Dec 24 | Dec 23 | Dec 22 | Dec 21 | Dec 20 | Dec 19 | Dec 18 | Dec 17 | Dec 16 | Dec 15 | Dec 14 | Dec 13 | Dec 12 | Dec 11 | Dec 10 | Dec 9 | Dec 8 | Dec 7 | Dec 6 | Dec 5 | Dec 4 | Dec 3 | Dec 2 | Dec 1 | Nov 30 | Nov 29 | Nov 28 | Nov 27 | Nov 26 | Nov 25 | Nov 24 | Nov 23 | Nov 22 | Nov 21 | Nov 20 | Nov 19 | Nov 18 | Nov 17 | Nov 16 | Nov 15 | Nov 14 | Nov 13 | Nov 12 | Nov 11 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Windows | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| Mac | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Linux | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
Copy Relative Command 📋️
A helpful command to copy a command to the clipboard based on configured settings, per language!
Installation 💻️
Within Sublime Text: - open the command palette (Windows/Linux: Ctrl + Shift + P, MacOS: Cmd + Shift + P) - search for “Package Control: Install Package” and press enter - search for “Copy Relative Command” and press enter on the mactching entry
Alternative installation 💻️
Within terminal:
- clone this repository into your respective operating systems Packages directory
- Linux: cd ~/.config/sublime-text/Packages && git clone git@github.com:patoui/CopyRelativeCommand.git
- MacOS: cd ~/Library/Application Support/Sublime Text 3/Packages && git clone git@github.com:patoui/CopyRelativeCommand.git
Quick start 🚀️
- open command palette and search for “Copy Relative Command Settings”
- add language settings, example:
{
"languages": {
"php": [
{
"glob": "**Test.php",
"command": [
"vendor/bin/phpunit",
"{relative_path}",
"--filter={current_function_or_class}"
]
},
{
"glob": "*",
"command": ["php -l {relative_path}"],
},
],
}
}
- execute
Copy Relative Commandwithin the configured language, such as aphpfile in our above example:- if the open file (active view) is a file named
test/Unit/ExampleTest.phpand the cursor is within a function nametest_it_should_be_true, the command copied to the clipboard would be:vendor/bin/phpunit test/Unit/ExampleTest.php --filter=test_it_should_be_true
- if the open file (active view) is a file named
app/Http/Controllers/UserController.phpthe command copied to the clipboard would be:php -l app/Http/Controllers/UserController.php
- if the open file (active view) is a file named
- That's it! Add your own configurations for language commands 👌️
Add a key binding 🔑️
To add a key binding, open “Preferences / Key Bindings - User” and add:
{ "keys": ["alt+c", "alt+c"], "command": "copy_relative_command" }
With this setting pressing alt + c + c will copy the configured relative command to your system clipboard
Settings 👨💻️
| Key | Parent | Description |
|---|---|---|
languages |
N/A | Contains a dictionary of all configured languages commands (e.g. php, go, python) and has a special value of * to apply to all languages |
glob |
languages.* |
contains a Unix filename pattern to identify which files the current command applies to (see fnmatch and glob) |
command |
languages.* |
a list (array) of strings which represent the command to be run. The command key has a few helper values:
|
Project Settings 📽️
- Open your project settings
- edit existing project settings “Project: Edit Project”
- create new project settings “Project: Save As”
- Add the same settings as you would in your general settings under the
Copy Relative Commandkey
{
"folders":
[
{
"path": "."
}
],
"settings": {
"Copy Relative Command": {
"languages": {
"php": [
{
"glob": "**Test.php",
"command": [
"vendor/bin/phpunit",
"{relative_path}",
"--filter={current_function_or_class}"
]
},
{
"glob": "*",
"command": ["php -l {relative_path}"],
},
]
}
}
}
}