How to define comment characters for React JSX in Sublime Text? - sublimetext

In OSX, in Sublime Text 3 (build 3065), with syntax set as JavaScript(JSX) or just JSX, I'm hitting the usual
cmd+/ to comment out the selected text.
However, ST3 is defaulting to the // comment chars, when I want to wrap selection like this:
{/* foobar selected text */}
I'm looking in here, but can't figure out what to edit:
/Users/admin/Library/Application Support/Sublime Text 3/Packages/User/JavaScript (JSX).tmLanguage
Thanks in advance! :)

Create an XML file in Packages/User called Comments.tmPreferences with the following contents (I'm assuming the base scope of your language is source.jsx - you can find this in the .tmLanguage file):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>source.jsx</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<key>name</key>
<string>TM_COMMENT_START</string>
<key>value</key>
<string>// </string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_START_2</string>
<key>value</key>
<string>{/* </string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_END_2</string>
<key>value</key>
<string> */}</string>
</dict>
</array>
</dict>
<key>uuid</key>
<string>F9BFFF1F-1999-4722-B094-52E8AFD234D1</string>
</dict>
</plist>
// will remain the default comment prefix when you hit ⌘/, but when you select some text and hit ⌘Shift/ you will wrap it in {/* blahblahblah */}.
If you want to completely get rid of //, use the following instead:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>source.jsx</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<key>name</key>
<string>TM_COMMENT_START</string>
<key>value</key>
<string>{/* </string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_END</string>
<key>value</key>
<string> */}</string>
</dict>
</array>
</dict>
<key>uuid</key>
<string>F9BFFF1F-1999-4722-B094-52E8AFD234D1</string>
</dict>
</plist>

While the previous answer solves the problem partially, it doesn't remove the comments correctly.
I added a plugin to https://github.com/borela/naomi which correctly detects the required comment type to use, it works for line and block comments.

Related

Fastlane command to update url and bundle identifier

How can i update the url and bundle-identifier for the below plist using fastlane ?
While using the update_info_plist command from fastlane its asking for a block , i dont understand what it is.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>https://server/cache/app.ipa</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>com.demo</string>
<key>bundle-version</key>
<string>1.0</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>CavionNovus</string>
</dict>
</dict>
</array>
</dict>
</plist>

Launchd is not working

I am having troubles making a Launchd script. It is fairly simple, all it needs to do is launch an application - the location is: /Library/Desktop Pictures/wallpaper
I've loaded the file using terminal, and terminal gives no errors but the script does not execute. I need the script to execute every 1 hour.
The plist file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>wallpaper.restart</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Desktop Pictures/wallpaper.wallpaperapp.app</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>1</integer>
</dict>
</dict>
</plist>
Please Help.
Thanks,
Devansh
EDIT:
Below is the next better version of the above code, but still not much luck :(
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>AfterInitialDemand</key>
<true/>
</dict>
<key>Label</key>
<string>com.plisterine.backgroundchanger</string>
<key>LowPriorityIO</key>
<false/>
<key>Nice</key>
<integer>0</integer>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/osascript</string>
<string>/Library/Desktop Pictures/wallpaper/wallpaper.scpt</string>
</array>
<key>StartInterval</key>
<integer>3600</integer>
</dict>
</plist>
StartCalendarInterval runs the script at a specific time every day, in your case at 01:00 (1 am)
To run it every hour you have to write
<key>StartInterval</key>
<integer>3600</integer>

How can I avoid using a bash script in my launchd plist?

This is my launchd plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.localhost.hexo</string>
<key>ProgramArguments</key>
<array>
<string>/Users/frankg/dev/bin/start-hexo.sh</string>
</array>
<key>UserName</key>
<string>frankg</string>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/Users/frankg/hexo</string>
<key>StandardOutPath</key>
<string>/Users/frankg/hexo</string>
</dict>
</plist>
This is my bash script
hexo server --cwd /Users/frankg/dev/code/apps/blog >> /tmp/MyLaunchdTest.out
This is working. How can I avoid the use of a bash script.
Specify the full path to the hexo executable, followed by each argument to it as a separate string in the ProgramArguments array. I'm a bit confused by the various output redirects -- in the current .plist you specify output to /Users/frankg/hexo, but in the script you redirect it to /tmp/MyLaunchdTest.out instead; I assume the latter is what you actually want? AIUI you could also use the WorkingDirectory key to replace the --cwd option. Something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.localhost.hexo</string>
<key>ProgramArguments</key>
<array>
<string>/path/to/hexo</string>
<string>server</string>
</array>
<key>UserName</key>
<string>frankg</string>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/Users/frankg/hexo</string>
<key>StandardOutPath</key>
<string>/tmp/MyLaunchdTest.out</string>
<key>WorkingDirectory</key>
<string>/Users/frankg/dev/code/apps/blog</string>
</dict>
</plist>

Detect Mac Application moved to trash folder using launch Agents

I want to run a script when my application moved into trash folder and I come to know that using launch agents its possible, I googled and made the plist but its not working or not calling the script..
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.meet.anywhere</string>
<key>WatchPaths</key>
<array>
<string>~/.Trash</string>
</array>
<key>ProgramArguments</key>
<array>
<string>/Users/eclit/Desktop/DeleteScript.scpt</string>
</array>
<key>KeepAlive</key>
<false/>
</dict>
</plist>
launchd cannot run the applescript directly. You need to use the command line tool osascript to run the applescript. As such your ProgramArguments portion should look like the following. Also, there's no need for the KeepAlive section. It does nothing so I'd remove it.
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/Users/eclit/Desktop/DeleteScript.scpt</string>
</array>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.meet.anywhere</string>
<key>WatchPaths</key>
<array>
<string>~/.Trash/AppName.app</string>
</array>
<key>ProgramArguments</key>
<array>
<string>osascript</st
<string>/Users/eclit/Desktop/DeleteScript.scpt</string>
</array>
<key>KeepAlive</key>
<false/>
</dict>
</plist>

Whitelist error in Cordova/Phonegap

I have the following in my Cordova.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeyboardDisplayRequiresUserAction</key>
<true/>
<key>SuppressesIncrementalRendering</key>
<false/>
<key>UIWebViewBounce</key>
<false/>
<key>TopActivityIndicator</key>
<string>gray</string>
<key>EnableLocation</key>
<false/>
<key>EnableViewportScale</key>
<false/>
<key>AutoHideSplashScreen</key>
<true/>
<key>ShowSplashScreenSpinner</key>
<true/>
<key>MediaPlaybackRequiresUserAction</key>
<false/>
<key>AllowInlineMediaPlayback</key>
<false/>
<key>OpenAllWhitelistURLsInWebView</key>
<false/>
<key>BackupWebStorage</key>
<string>cloud</string>
<key>ExternalHosts</key>
<array/>
<key>item 0</key>
<string>*</string>
<key>Plugins</key>
<dict>
<key>NavigationBar</key>
<string>NavigationBar</string>
<key>EmailComposer</key>
<string>EmailComposer</string>
<key>Device</key>
<string>CDVDevice</string>
<key>TabBar</key>
<string>TabBar</string>
<key>Logger</key>
<string>CDVLogger</string>
<key>Compass</key>
<string>CDVLocation</string>
<key>Accelerometer</key>
<string>CDVAccelerometer</string>
<key>Camera</key>
<string>CDVCamera</string>
<key>NetworkStatus</key>
<string>CDVConnection</string>
<key>Contacts</key>
<string>CDVContacts</string>
<key>Debug Console</key>
<string>CDVDebugConsole</string>
<key>Echo</key>
<string>CDVEcho</string>
<key>File</key>
<string>CDVFile</string>
<key>FileTransfer</key>
<string>CDVFileTransfer</string>
<key>Geolocation</key>
<string>CDVLocation</string>
<key>Notification</key>
<string>CDVNotification</string>
<key>Media</key>
<string>CDVSound</string>
<key>Capture</key>
<string>CDVCapture</string>
<key>SplashScreen</key>
<string>CDVSplashScreen</string>
<key>Battery</key>
<string>CDVBattery</string>
<key>Globalization</key>
<string>CDVGlobalization</string>
</dict>
</dict>
</plist>
I have added * as an external host which previously has always worked without issue, I am using Cordova 2.2.0 and when trying to make AJAX calls I am getting the White-list error.
I don't see where I am going wrong!
I have changed this part of the XML -
<array/>
<key>item 0</key>
<string>*</string>
To this -
<key>ExternalHosts</key>
<array>
<string>*</string>
</array>

Resources