Copy Relative Command
Copy's a command relative of your current active file!
Details
Installs
- Total 85
- Win 46
- Mac 28
- Linux 11
Sep 15 | Sep 14 | Sep 13 | Sep 12 | Sep 11 | Sep 10 | Sep 9 | Sep 8 | Sep 7 | Sep 6 | Sep 5 | Sep 4 | Sep 3 | Sep 2 | Sep 1 | Aug 31 | Aug 30 | Aug 29 | Aug 28 | Aug 27 | Aug 26 | Aug 25 | Aug 24 | Aug 23 | Aug 22 | Aug 21 | Aug 20 | Aug 19 | Aug 18 | Aug 17 | Aug 16 | Aug 15 | Aug 14 | Aug 13 | Aug 12 | Aug 11 | Aug 10 | Aug 9 | Aug 8 | Aug 7 | Aug 6 | Aug 5 | Aug 4 | Aug 3 | Aug 2 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 1 | 1 | 1 | 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 Command
within the configured language, such as aphp
file in our above example:- if the open file (active view) is a file named
test/Unit/ExampleTest.php
and 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.php
the 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:
// Copy Relative Command
{ "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 Command
key
{
"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}"],
},
]
}
}
}
}