Where is the default settings file, which stores thing such as "font_size", located for Sublime Text 4? - sublimetext

I'm using Sublime Text 4 (Build 4126) on Linux Ubuntu 18.04. The Packages/Default directory (full path would be $HOME/.config/sublime-text-3/Packages/User), which this answer refers to: What is the default font of Sublime Text?, no longer exists.
Where are these defaults stored now? I can see them in the left-hand pane in Preferences --> Settings, but where is that file?
If you go to Preferences --> Settings in Sublime Text 4 it opens the preferences, with the defaults on the left, and it even shows the path as ~/.config/sublime-text-3/Packages/Default/Preferences.sublime-settings even though that file doesn't actually exist on my file system (the Default folder in that path does not exist).
To try to find a file ending in sublime-settings, and containing "font_face":, for instance, I ran this command, but didn't find any "defaults" type file anywhere:
# Read all paths with "sublime-settings" in their path name into a regular bash
# "indexed" array named `array`
mapfile -t array <<< "$(find / 2> /dev/null | grep -E "sublime-settings")"
# Pass this list of files to `grep` and search for `"font_size":`
grep -i '"font_size":' -- "${array[#]}"
Also, here is the result of find ~/.config/ | grep -e sublime-text:
$ find ~/.config/ | grep -e sublime-text
/home/gabriel/.config/sublime-text-3
/home/gabriel/.config/sublime-text-3/Packages
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/SublimeTutor.sublime-settings
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/Default (Windows).sublime-keymap
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_4_5.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2_7.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2_10.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2_13.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_4.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_5_4.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/code
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/code/chapter_1.rb
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/sublimetutor.sublime-project
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_1.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_3_6.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_5_3.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_4_1.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_4_3.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2_3.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_4_2.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_3_8.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2_12.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_5_2.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2_8.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2_1.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2_15.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/contents.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2_2.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_3_5.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2_5.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2_11.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_6.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2_14.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_3_2.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2_9.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2_4.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_3_4.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_3_7.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_3_3.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_3_1.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_2_6.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_3.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_5_5.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_4_4.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/sublimetutor.sublime-workspace
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/README.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_5.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_5_1.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/tutorial/chapter_4_6.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/package-metadata.json
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/sublime_tutor.py
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/Default (OSX).sublime-keymap
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/Main.sublime-menu
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/Default.sublime-commands
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/LICENSE
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/CONTRIBUTORS.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/Default (Linux).sublime-keymap
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/.no-sublime-package
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/messages.json
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/messages
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/messages/1.0.1.txt
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/messages/install.txt
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/README.md
/home/gabriel/.config/sublime-text-3/Packages/Sublime Tutor/.gitignore
/home/gabriel/.config/sublime-text-3/Packages/User
/home/gabriel/.config/sublime-text-3/Packages/User/Git Config.sublime-settings
/home/gabriel/.config/sublime-text-3/Packages/User/Build.sublime-settings
/home/gabriel/.config/sublime-text-3/Packages/User/MarkdownTOC.sublime-settings
/home/gabriel/.config/sublime-text-3/Packages/User/Preferences.sublime-settings
/home/gabriel/.config/sublime-text-3/Packages/User/C++.sublime-settings
/home/gabriel/.config/sublime-text-3/Packages/User/Markdown.sublime-settings
/home/gabriel/.config/sublime-text-3/Packages/User/Python.sublime-settings
/home/gabriel/.config/sublime-text-3/Packages/User/Makefile.sublime-settings
/home/gabriel/.config/sublime-text-3/Packages/User/SBSCompareTheme.hidden-tmTheme
/home/gabriel/.config/sublime-text-3/Packages/User/SBSCompareScheme.hidden-color-scheme
/home/gabriel/.config/sublime-text-3/Packages/User/Package Control.sublime-settings
/home/gabriel/.config/sublime-text-3/Packages/User/Package Control.user-ca-bundle
/home/gabriel/.config/sublime-text-3/Packages/User/ANSIescape
/home/gabriel/.config/sublime-text-3/Packages/User/ANSIescape/ansi.sublime-color-scheme
/home/gabriel/.config/sublime-text-3/Packages/User/YAML.sublime-settings
/home/gabriel/.config/sublime-text-3/Packages/User/Bash.sublime-settings
/home/gabriel/.config/sublime-text-3/Packages/User/Plain text.sublime-settings
/home/gabriel/.config/sublime-text-3/Packages/User/XML.sublime-settings
/home/gabriel/.config/sublime-text-3/Installed Packages
/home/gabriel/.config/sublime-text-3/Installed Packages/Github Tools.sublime-package
/home/gabriel/.config/sublime-text-3/Installed Packages/Awk.sublime-package
/home/gabriel/.config/sublime-text-3/Installed Packages/Case Conversion.sublime-package
/home/gabriel/.config/sublime-text-3/Installed Packages/Git.sublime-package
/home/gabriel/.config/sublime-text-3/Installed Packages/Tabright.sublime-package
/home/gabriel/.config/sublime-text-3/Installed Packages/Git blame.sublime-package
/home/gabriel/.config/sublime-text-3/Installed Packages/Package Control.sublime-package
/home/gabriel/.config/sublime-text-3/Installed Packages/Devicetree DTS Highlighting.sublime-package
/home/gabriel/.config/sublime-text-3/Installed Packages/MarkdownTOC.sublime-package
/home/gabriel/.config/sublime-text-3/Installed Packages/Compare Side-By-Side.sublime-package
/home/gabriel/.config/sublime-text-3/Installed Packages/0_package_control_loader.sublime-package
/home/gabriel/.config/sublime-text-3/Installed Packages/ANSIescape.sublime-package
/home/gabriel/.config/sublime-text-3/Log
/home/gabriel/.config/sublime-text-3/Local
/home/gabriel/.config/sublime-text-3/Local/Session.sublime_session
/home/gabriel/.config/sublime-text-3/Local/License.sublime_license
/home/gabriel/.config/sublime-text-3/Local/Auto Save Session.sublime_session
/home/gabriel/.config/sublime-text-3/Lib
/home/gabriel/.config/sublime-text-3/Lib/python3.3
/home/gabriel/.config/sublime-text-3/Lib/python33
/home/gabriel/.config/sublime-text-3/Lib/python38
It seems to me that ~/.config/sublime-text-3/Packages/Default/Preferences.sublime-settings file may not actually exist, and may just be a fake path Sublime Text created for historical reasons. Perhaps those defaults are actually built into the binary of Sublime Text 4 now, instead.
Anyway, I guess the main takeaway is that for Sublime Text 3 and 4 you can just see the defaults by looking in the left-hand pane that opens up when you go to Preferences --> Settings.
References
[my own answer which I referenced for the find and mapfile cmd above] Super User: Can't pipe in bash's "mapfile" ... but why?

Quick find find ~/.config/ | grep -e sublime-text on my system shows
.config/sublime-text
.config/sublime-text/Packages
.config/sublime-text/Packages/User
.config/sublime-text/Packages/User/Preferences.sublime-settings
.config/sublime-text/Installed Packages
.config/sublime-text/Local
.config/sublime-text/Local/Session.sublime_session
.config/sublime-text/Log
.config/sublime-text/Lib
.config/sublime-text/Lib/python33
.config/sublime-text/Lib/python38
Run the above command and check if there is anything similar.
I have only Sublime Text 4 (Build 4126) installed. You most probably have both somehow.

I think I found it!
Open the file at /opt/sublime_text/Packages/Default.sublime-package. If you double-click it in a GUI file manager it opens up like a zip file.
From there, open up Preferences (Linux).sublime-settings, and I see this:
{
"font_face": "Monospace",
"font_size": 10,
"move_to_limit_on_up_down": true,
"mouse_wheel_switches_tabs": true
}
Going further
Interesting, it looks like the mouse scroll wheel settings are here too as button2, but I haven't tried messing with them. I wonder perhaps if changing those scroll wheel settings (which do NOT exist in the left-hand pane of Preferences --> Settings) might be an alternative to using imwheel to change scroll speed (see here, here, and here--search for "Sublime Text" in this last one).
From the Scroll Bar (Linux).sublime-mousemap file inside that default package compressed file above:
[
{
"button": "button1",
"press_command": "scroll_drag",
},
{
"button": "button1", "modifiers": ["shift"],
"press_command": "scroll_step",
"press_args": { "follow_mouse": false, "delay": 1000, "interval": 200 },
},
{
"button": "button2",
"press_command": "scroll_adjust",
"press_args": {
"acceleration_dead_zone": 15,
"acceleration_area": 200,
"min_speed": 200,
"max_speed": 5000,
},
},
{
"button": "button3",
"press_command": "scroll_step",
"press_args": { "follow_mouse": false, "delay": 1000, "interval": 200 },
},
]
There is also a file named Default (Linux).sublime-keymap, and there are files for ...(OSX)... and ...(Windows)....

Related

bash or powershell parsing jason file content

I would like to manipulate the content of jason file.
I've tried with powershell or linux bash but I was unable to get what I want.
On linux, I was thinking to use jq tool, despite obtains data, I cannot manipulate them.
jq '.[].pathSpec, .[].scope' jasonfilepath
Current output:
"file"
"file"
"/u01/app/grid/*/bin/oracle"
"/u01/app/oracle/product/*/db_1/bin/oracle"
My goal is to obtain something similar as:
scope pathSpec
Like:
file /u01/app/grid/*/bin/oracle
file /u01/app/oracle/product/*/db_1/bin/oracle
Jason file sample
[
{
"actions": [
"upload",
"detect"
],
"deep": false,
"dfi": true,
"dynamic": true,
"inject": false,
"monitor": false,
"pathSpec": "/u01/app/grid/*/bin/oracle",
"scope": "file"
},
{
"actions": [
"upload",
"detect"
],
"deep": false,
"dfi": true,
"dynamic": true,
"inject": false,
"monitor": false,
"pathSpec": "/u01/app/oracle/product/*/db_1/bin/oracle",
"scope": "file"
}
]
Do you have any idea to get this kind of expected output in Powershell and bash?
Thanks by advance,
Assuming a JSON input file named file.json:
In a Linux / Bash environment, use the following:
jq -r '.[] | .scope + " " + .pathSpec' file.json
In PowerShell, use the following (adapted from a comment by JohnLBevan):
(Get-Content -Raw file.json | ConvertFrom-Json) |
ForEach-Object { '{0} {1}' -f $_.scope, $_.pathSpec }
Note the (...) around the pipeline with the ConvertFrom-Json call, which is necessary in Windows PowerShell (but no longer in PowerShell (Core) 7+) to ensure that the parsed JSON array is enumerated in the pipeline, i.e. to ensure that its elements are sent one by one - see this post for more information.

ansible awx/tower not accepting list of values in a variable

I am trying to launch an awx/tower job template passing a list of values in a variable but the task is getting executed only on one target host.
sample request
curl -H "Content-Type: application/json" -X POST -s -u admin:admin123 -d '{ "extra_vars": { "domain": "dom-cn-1", "targets": "dev-cn-c1", "targets": "dev-cn-c2", "fwcmd": "fw sam -v -J src 192.168.10.10" }}' -k https://172.16.102.4/api/v2/job_templates/10/launch/
The above command does not execute as expected and runs on a single host. However, this is working as expected when I run the same playbook via cli.
vars file snip
domain: dom-cn-1
targets:
- dev-cn-c1
- dev-cn-c2
Playbook file
- name: "Create output file"
check_point_mgmt:
command: run-script
parameters:
script-name: "Create output file"
script: "fw sam -v -J src 192.168.10.10"
targets: "{{ targets }}"
session-data: "{{login_response}}"
Let's extract your json in your curl command:
{
"extra_vars": {
"domain": "dom-cn-1",
"targets": "dev-cn-c1",
"targets": "dev-cn-c2",
"fwcmd": "fw sam -v -J src 192.168.10.10"
}
}
You are not passing a list but twice the same parameter with different values. You have to correct you json like this:
{
"extra_vars": {
"domain": "dom-cn-1",
"targets": ["dev-cn-c1", "dev-cn-c2"],
"fwcmd": "fw sam -v -J src 192.168.10.10"
}
}

Save terminal tabs to saved workspace VSCode

Is it possible to save Terminal settings to a workspace? For most of my projects I always have two terminal tabs open. One where I do all of my git work and one where I run gulp tasks. These are two different folders and neither are the project root. When I open a saved workspace it always just opens one tab to the project root.
Look at the Restore Terminals extension. For example, in your settings.json:
"restoreTerminals.runOnStartup": false, // true is the default
// set to false if using a keybinding or command palette
"restoreTerminals.terminals": [
{
"splitTerminals": [
{
"name": "git",
"commands": [
"cd <your directory>",
"npm run test" // your git command(s)
]
}
]
},
{
"splitTerminals": [
{
"name": "gulp",
"commands": [
"cd zip",
"gulp sass"
]
}
]
}
]
will open two terminals, one for your git work and one for the gulp work. They can each take multiple commands.
Example keybinding:
{
"key": "shift+alt+t", // whatever keybinding if you wish
"command": "restore-terminals.restoreTerminals",
},
or you can it run at start-up.
The Tasks feature is the current recommended way to handle this. There is no need for an extension. See Automating launching of terminals in the VS Code documentation.
Then make sure that tasks are run automatically when the folder is opened by running command Tasks: Manage Automatic Tasks in Folder and choosing Allow Automatic Tasks in Folder (see Run behavior).
Please also see the note here that:
Task support is only available when working on a workspace folder. It is not available when editing single files."
For a Linux not-so-officially-recommended way that works. The xdotool key emulator for linux can be used. I'm sure any Windows key emulator could be used to accomplish the same thing.
First, set the Terminal: Change Color to a keyboard shortcut. Here I'm using Ctrl+Shift+C. This is done by bringing up the command pallet (Cntrl+Shift+P) and, typing Terminal: Change Color
Here is my Restore Terminals json from VS Code settings. The lengthy cli command to update the colors needs to be activated on the last tab, as it is the tab that is focused when Restore Tabs is finished restoring tabs.
We need a bit of a timeout between the setting of each tab color, as VS Code takes just about a 10th of a second to complete the command. The built in keyboard shortcut cntrl+Page_Up is used to bring the previous tabs into focus. This script is for a WorkSpace that includes a Docker-Compose enviroment that contains 3 repos.
Be sure to save this in your Workspace settings, not your user settings. For more info, visit: https://code.visualstudio.com/docs/getstarted/settings
"restoreTerminals.terminals": [
{
"splitTerminals": [
{
"name": "docker-compose",
"commands": ["cd ..", "cd docker-compose", "clear"]
},
]
},
{
"splitTerminals": [
{
"name": "api",
"commands": ["cd ..", "cd api", "clear"]
},
]
},
{
"splitTerminals": [
{
"name": "ui",
"commands": [
"cd ..",
"cd ui",
"xdotool key ctrl+shift+c && xdotool type 'cyan' && xdotool key Return && sleep .2",
"xdotool key ctrl+Page_Up && xdotool key ctrl+shift+c && xdotool type 'green' && xdotool key Return && sleep .2",
"xdotool key ctrl+Page_Up && xdotool key ctrl+shift+c && xdotool type 'yellow' && xdotool key Return",
"clear"
]
},
]
}
],
And the end result... Is that all tab colors are updated after they are restored.
Of course, anyone who has ever used keyboard emulation for automating tasks should know you can not be entering text or clicking elsewhere until the task is complete.
If you're on windows you can use powershell to create a similar effect to #CodeBloodedChris's solution.
Create a powershell script in your workspace root directory (or where ever the last terminal's final path is) and name it something like 'restore-terminal-customization.ps1' or something like that. Then add the following code to it:
# Uses windows forms to send keystrokes to customize vscode Terminals
Add-Type -AssemblyName System.Windows.Forms
$tabDelay = .6
# Last Terminal
[System.Windows.Forms.SendKeys]::SendWait("^+cRed~")
# Second to last Terminal
[System.Windows.Forms.SendKeys]::SendWait("^{PGUP}"); Start-Sleep -s $tabDelay
[System.Windows.Forms.SendKeys]::SendWait("^+cYellow~")
# Third to last Terminal
[System.Windows.Forms.SendKeys]::SendWait("^{PGUP}"); Start-Sleep -s $tabDelay
[System.Windows.Forms.SendKeys]::SendWait("^+cMagenta~")
In this script the '^+c' is ctrl+shift+c and '~' is the enter key.
Similarly I had also set up a keybinding for the icons which uses ctrl+shift+i '^+i'. Here's an example of setting both the color and the icon of a terminal:
# Fourth to last Terminal
[System.Windows.Forms.SendKeys]::SendWait("^{PGUP}"); Start-Sleep -s $tabDelay
[System.Windows.Forms.SendKeys]::SendWait("^+cGreen~^+iorganization~")
In your restoreTerminal's config call the script you created as a command in the last terminal on your list.
"restoreTerminals.terminals": [
{
"splitTerminals": [
{
"name": "docker-compose",
"commands": ["cd ..", "cd docker-compose", "clear"]
},
]
},
{
"splitTerminals": [
{
"name": "api",
"commands": ["cd ..", "cd api", "clear"]
},
]
},
{
"splitTerminals": [
{
"name": "ui",
"commands": [
"cd ..",
"cd ui",
".\restore-terminal-customization.ps1",
"clear"
]
},
]
}
],
Don't forget to set the keybindings to the Terminal: Change Color and Terminal: Change Icon commands in VsCode.

Changing files (using sed) in Packer script leaves files unchanged

currently I am looking into building a build-pipeline using packer and docker.
This is my packer.json:
{
"builders": [{
"type": "docker",
"image": "php:7.0-apache",
"commit": true
}],
"provisioners": [
{
"type": "file",
"source": "./",
"destination": "/var/www/html/"
},
{
"type": "shell",
"inline": [
"chown -R www-data:www-data /var/www/html",
"sed '/<Directory \\/var\\/www\\/>/,/<\\/Directory>/ s/AllowOverride None/AllowOverride all/' /etc/apache2/apache2.conf",
"sed '/<VirtualHost/,/<\\/VirtualHost>/ s/DocumentRoot \\/var\\/www\\/html/DocumentRoot \\/var\\/www\\/html\\/web/' /etc/apache2/sites-enabled/000-default.conf"
]
}
]
}
The Shell Script inside the provisioners section contains some sed commands for changing the AllowOverride and DocumentRoot variables inside the apache config.
When packer runs this script it is working all fine and I am getting a positive sed output, so sed seems to work fine. But in the docker image the files are unchanged.
Copying the files in the file provisioner is working fine.
What am I doing wrong?
It seems you're missing -i (or --in-place) flag in your sed commands. Try with:
"sed -i <expression> <file>"

Sublime build system to open file at local server address

For a website I'm developing with the help of a local server (running at http://127.0.0.1:4000), I try to write a build system for my Sublime Text project settings.
I have access to these variables (provided by Sublime Text):
$file: Stores the absolute path to the file on disk:C:\Users\User\dev\repos\base\dir\index.html
$project_path: Stores the location of the project file (usually the root of the project):C:\Users\User\dev\repos\base
Now what I want is the content of $file but instead of the $project_path I want http://127.0.0.1:4000/~base. For that task I tried the following with Bash cmd.exe:
CALL SET result=%file:%project_path%=http://127.0.0.1:4000\~base\% && echo %result%
This gives the desired result, however I can't seem to be able to apply it to the build system inside Sublime Text.
For now, I try to generate the correct address and output it via cmd.exe:
{
"build_systems":
[
{
"name": "Preview in browser",
"selector": "text.html",
"windows":
{
"shell": true,
"cmd": [
"start", "cmd", "/k",
"CALL SET result=$file:$project_path=http://127.0.0.1:4000\\~base\\ && echo $result"
]
}
}
]
}
Result:
> echo %result%
C:\Users\Philipp\dev\repos\base\dir\index.html:C:\Users\Philipp\dev\repos
\base=http://127.0.0.1:4000\~base\
So the substitution is not working when doing it in the build system, but in cmd.exe it does. I'm confused.
You can do something like this:
{
"build_systems":
[
{
"name": "Preview in browser",
"selector": "text.html",
"windows":
{
"shell_cmd": "CALL SET filePath=$file && CALL SET result=%filePath:$project_path=http://127.0.0.1:4000\\~base% && CALL C:/Progra~2/Google/Chrome/Application/chrome.exe %result%"
}
}
]
}
The problem was with windows replacement and variable asignation rather than with sublime builds.
As it has been said in chat and comments multiple CALL are necessary to use the real value variable because if not used windows will expand their value at parse time before the wanted value is asigned at execution time. In addition, shell_cmd can be used to run a unique command in shell.

Resources