When I try to save the file run-only does not show up. This may be because I am on Big Sur.
In Script Editor, the Run-only option is available when using: File > Export…
This has nothing to do with Big Sur.
You have to export the script which makes a lot of sense because saving the current script as run-only will make your source code inaccessible.
Related
So I am looking for a way to set Mac specific extended attributes (specifically kMDItemWhereFroms) for a file (Image File, Jpg) using AppleScript or AppleScript-Objc.
There is a command line tool that will do this xattr -w kMDItemWhereFroms . The problem is that on the several machines that I have access to (10.12, 10.13, and 10.14) when you run this command as a do shell script from within an AppleScript it does not work, the metadata is not added to the file. If I set Script Debugger to debug mode, and go through the script step by step it will actually set the metadata, but since that is not the way I am running the script, it is more of an interesting fluke than anything else. I have tried running the command with both "com.apple.metadata:" included and not included with the shell script and that makes no difference.
I have tried running my script through SD, Script Editor and osascript, and they all fail to update the metadata. So I am thinking that this tool might be broken when called from an AppleScript.
I found setxattr but that looks like it only applies to C.
So my questions are
1. Is there a way to set the extended attributes of a file on MacOS using Aobjc? if not then
2. Is there a way to get setxattr to work with either version of AppleScript? Probably not so
3. Any ideas how I might be able to get the command line tool xattr -w kMDItemWhereFroms to work when using scripting?
This is more of an annoyance for me, I am just being stubborn with wanting the source of the file to show up in the "Where From" data in the Get Info window from the Finder. I already am setting some metadata for the file using exiftool. So it is more of an interesting problem for me, than a critical problem that I must try and solve now. Thanks!
I have started a new thread rather then reviving this one:
Creating your own syntax highlighting in GEdit?
Hope that was the right thing to do. I have created a syntax file for fish shell and placed it in /usr/share/gtksourceview-2.0/language-specs (in Ubuntu). When I open a .fish file with gedit there is no highlighting and the view-->high light mode menu does not show this fish as an option. Is there something that needs to be updated to allow the file to be recognized?
Thanks for reading-Patrick
Make sure you are in fact using Gedit 2 and not Gedit 3 (which uses gtksourceview-3.0). For the newer, 3.0 lang files, you can put them into ~/.local/share/gtksourceview-3.0/language-spec/
If you've installed it to the correct location, you should see the name you specified in the _name attribute in the View > Highlight Mode menu under the sub menu you specified with the _section attribute in your .lang file. For example, if I had test.lang with:
<language id="test" _name="Test Language File" version="2.0" _section="Markup">
Then I would see "Test Language File" under View > Highlight Mode > Markup in the Gedit menu.
As an alternative to /usr/share/gtksourceview-2.0/language-specs/, you could try putting it in ~/.gnome2/gtksourceview-2.0/language-specs/.
Assuming you've restarted gedit after installing your syntax file, then it may just be a syntax error. Try installing the Go syntax file (http://go-lang.cat-v.org/text-editors/gedit/), and if that shows up but your custom one still doesn't, then it's a problem with your file. If none of them show up, then you may need to re-install gedit or gtksourceview.
Also, make sure the permissions on your new file match those of the existing ones. I doubt gedit would need more than read permissions to be able to use the file, but it wouldn't hurt to check.
I want to be able to save a file in a way that opening it with a regular double-click runs it. Also is there a mac equivalent of #ECHO OFF that makes it so no text shows up in terminal?
Probably the easiest thing to do would be to wrap your script or program in a tiny bit of AppleScript:
do shell script "/your/command/here"
Then save it as an application and it will behave like any other OSX application.
The shell shouldn't be printing the commands as they're run unless you're supplying the -x switch so I'm not sure what you want #ECHO OFF for.
If you save a script with the file extension .command, it will be double-clickable in the Finder.
When running the following ruby script:
puts gets.inspect
On the terminal I am prompted for input and then the inspect output is shown, but if I run the same script from inside TextMate using the CMD+R shortcut then it just outputs nil as if there is no gets method.
Why is this? From what I've read TextMate is supposed to show an input dialog when input from STDIN is requested by the script, but that isn't happening in this case.
See this blog entry; presumably you're on Snow Leopard?
From the comments, some users say that this file has worked for them on Snow Leopard. Per #dmarkow's answer, copy this file to:
/Applications/TextMate.app/Contents/SharedSupport/Support/lib/
You may want to keep a copy of the file around as updates to TextMate may replace it.
Specifically, you need to copy the tm_interactive_input.dylib file linked to by Phrogz in the following path:
/Applications/TextMate.app/Contents/SharedSupport/Support/lib/tm_interactive_input.dylib
Keep in mind that it's possible any TextMate updates will overwrite or delete this file.
I have a bash file that does some file manipulation. I don't want to have to open the terminal every time I run it. Is there a way to make the program run when I double click it? (Like a windows .exe file)
Thanks
You can add a ".command" extension to the filename -- then double-clicking it will automatically open Terminal and run the script in a new window. Note: this assumes you still want to watch/interact with the script via a Terminal interface; if you want to avoid this as well, wrapping the script with Platypus, AppleScript, or Automator (as Zifei and Ned suggest) would be better options.
What you need is Platypus.
Platypus is a developer tool for the Mac OS X operating system. It can be used to create native, flawlessly integrated Mac OS X applications from interpreted scripts such as shell scripts or Perl and Python programs. This is done by wrapping the script in an application bundle directory structure along with an executable binary that runs the script.
The easiest thing to do is to type: sudo chmod 755 the_file_Name.This will allow you to double click on the file in the finder.
With OS X 10.5+, you can wrap the bash shell script in an AppleScript application using the AppleScript editor or an Automator application using Automator.app (see the Automator on-line help).
You could write (and there are apps out there that do this) an OS X app that accepts arbitrary .sh files and executes them. However, that's generally a bad idea as it could open you up to attacks if you inadvertently download a malicious shell script file that is automatically opened by your web browser. Better to be explicit.