Files with the same name in a TextMate project - macos

One of the few things that bothers me about TextMate is that it can be difficult to differentiate between files that share the same name in a project, e.g:
alt text http://img530.imageshack.us/img530/6791/bild1r.png
In this case, the file on the right is located in the project relative path model/realtimemodel.py, while the other file contains unit tests for that code. Sure, you can command-click the name in the title bar to see a directory list, but it feels sub-optimal. What I would like is something along the lines of:
alt text http://img240.imageshack.us/img240/1783/bild3.png
This gives a quick at-a-glance idea of what file you're working on. Has anyone seen any plugin or bundle that makes this possible?
Edit: Here is a ticket in Macromates tracker that requests this feature (although I would prefer a project-relative path).

This is a start: http://snipplr.com/view/11490/textmate-command-snippet--show-document-path-in-window-title/

I think vasi's solution is the closest you can get to what you want (+1 for him)
I don't think that the bundle can be automatically ran on open, and also, the title changes back to default when switching between tabs, so even if it could, it would be useless.
I've searched for a defaults key (like the one from Finder, _FXShowPosixPathInTitle editable with
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES)
but there isn't any. Here's the list of available keys for Textmate.
Maybe you can write feature request somewhere as it is very useful and not so hard to impletement.

Related

mac default application for any unknown extension

I have a series of files that are all text files that i want to open with text editor (let's say Sublime).
The extensions on these files follow the pattern:
file.sff123
file.sff124
file.sff125
file.sff126
and so on...
Every time i go to open one of these files, the dialog pops up to select the default application for this file type, but since they all have varying extensions, i have to navigate and select the new file type each time. I literally have 1000s of these files and would like to be able to open all of them. Further, i want to be able to open any unknown file with something like Sublime by default. 99% of the time its a random text file... the 1% that it's not i'll "open with".
Is there a way to get Mac to recognize any unknown file extension and open it with an application of my choosing by default?
I am not sure if it is possible, but the following (untested) may help you, or someone else work out how to do it.
OSX uses UTIs (Uniform Type Identifiers) to categorise filetypes and map them to applications - and this works in conjunction with Launch Services to launch the appropriate application.
I don't have one of your .sffnnn files available, but I think you need to run mdls on one and see what kMDItemContentType is. You can do that like this in Terminal:
mdls -name kMDItemContentType somefile.sff123
I am hoping you get the same content type for all your .sffnnn files - if you don't, this approach won't work.
You then need to edit your LaunchServices.plist file which, I think, is in ~/Library/Preferences/com.apple.LaunchServices.plist and make an entry corresponding to the filetype you found above that maps to the sublime application. I suggest you look in there, or the system-wide version to see how entries look.
Once you get the hang of it, you may be able to do it from the command-line with a command like:
defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=xxxType;LSHandlerRoleAll=xxx.yyy.sublime;}'

Clear Recent items in Preview Application of Mac OS X..?

Hello all,
Can anyone tell me how to clear the 'Recent items' list in Preview application of Mac OS X through code? Is there a terminal command that can do this?
Or is there any way to click on 'Clear Menu' in 'Open Recent' of the 'File' menu in Preview?
Alternatively, does someone know where Preview stores this information and how do to remove it?
Check out this image to see what I mean.
Ok, so none of the described methods on the websites I could find actually succeeded in getting rid of all the 'recent document' lists in all of my apps.
I feel the most common sense approach would be (for OSX 10.12 / Sierra):
First go to system settings > general and choose "none" in the recent file dropdown menu (my OSX is in another language so the exact terms might be different, but you should be able to see what I mean). / This will get rid of most, but not all recent-items in different apps.
Get familiar with Apple's 'defaults' command in terminal. Now, hunt for any lists you might still want to get rid off, e.g. none of the options mentioned in the answers already listed here helped to get rid of the recent-items list in Finders "GO" menu. I played around with the defaults command and found that: "write com.apple.finder "FXRecentFolders" '({})' && killall Finder" does the trick for me. Playing around I found similar solutions for many of the other apps that where still able to maintain a list of recent items.
Create a shell script containing the commands you found during step 2.
Schedule the script to be run automatically on a preset interval or action (e.g. log out). AND/OR create an alias in your shell's profile (or directly apply the script as a function inside it) so you can call it with a single command from your terminal. (for instance: I have created an alias to it, so when I now type "killrecent" in terminal, it empties all the recent-items lists I've been able to find.
Hope this will be of some help to others. Good luck!
open Preview ->- go to File ->- Open Recent ->- Clear Menu
You may try the approach outlined here, which is to run
defaults delete com.apple.Preview.LSSharedFileList RecentDocuments
in the Terminal (manually or through your app). However I tried this and it didn't work for me (OSX 10.11), since the Preview defaults file doesn't contain this entry.
You can use
defaults write com.apple.Preview NSRecentDocumentsLimit 0
which will hide all recently used items, but as soon as you set that number to anything greater than 0, they will show up again.
I also checked the ScriptingBridge Interface for Preview, but couldn't find anything useful. So unfortunately it looks like this is not possible.
with 10.11, there are at
~/Library/Application\ Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/com.apple.preview.sfl

Is there a way to autosave on each keystroke in sublime?

I would like sublime to save my file on each key stroke, for live reload purposes.
The neatest action would be to autosave on each keystroke, only if the file has valid syntax.
If compass task was fast enough it would be like working directly in chrome inspector.
You could write a plugin that saves the file using the on_modified listener. Something like the following may work (note untested)
import sublime_plugin
class SaveOnModifiedListener(sublime_plugin.EventListener):
def on_modified(self, view):
view.run_command("save")
If you have a linter, you could validate it, and only save on clean lints. Note that with what I have posted, any edit to any file in sublime will be saved on each keystroke. You may want to add some additional checks for things like file type, if it exist on disk, etc.
I had this very same need some time ago when I was trying to do some very fast feedback prototyping that required the file to be saved before I could analyze its output. However, this is not something I'd need in all my projects.
Luckily I found that there is an elegant plugin that does just what is needed - saves the given file after each and every modification - and does that with a simple addition! You can easily enable and disable the feature when it suits you with a simple key combination. Although it is but a small improvement over the other spot on answer, I hope it'll help someone out there.
The plugin in question is auto-save, and of course, it can be installed through Sublime Package Control.

Setting the Search Path... global setting in MacVim

Noticed an interesting GUI based setting in MacVim, that seems useful but I can't seem to find any official word on what it does exactly.
It is located at Edit Menu > Global Settings > Search Path...
Once there a dialog drops down with the following:
"Enter search path for files"
Separate directory names with a comma.
.,/usr/include,,
From that editable line I get the clue that this appears to be a header search path. Something I would hope works with ctags, etc. But the setting I put in there don't seem to stick between open and closing just MacVim windows with out even quitting the MacVim Application.
Searing Vim help only really turns up new-search-path which I am not sure how to use or set if it is even related?
Is this what I think it is? The header search path. If yes then how do I set the path in my .vimrc or where needed so that the changes to it are persistent.
If this is not a header search path then what does it do?
I think you are right about its purpose, the setting is simply called path: its default value (:set path?) is .,/usr/include,, just as in your question.
You can use it to tell Vim to look for files in specific places.

run applescript on 2x-click

OK, this feels like an idiot question, but I'm stuck - I don't know the first thing about AppleScript. I have a .scpt file and I want to double-click it and just have it run, but instead every time I click, it opens up the AppleScript Editor. This feels like it should just be an option on the file, but I'm missing something obvious.
Please help me feel less dumb, thank you.
From the “File” menu, choose “Export”; there’ll be a “File Format” dropdown underneath the file browser. To get a double-clickable application instead of a document, choose “Application”. This will produce a .app bundle like ordinary Mac applications (this will also let you package other resources with your script if you need to). You can choose “Run Only” or not; if you do, then anybody with just the .app won’t be able to edit your script further, since it’ll be compiled. (But if you’re saving a copy as the application, that might be what you want.)
Another option, as per an anonymous user on Ask Different, would be to save/export your file as a “Script” (.scpt) or “Script Bundle” (.scptd), save it in ~/Library/Scripts/, and check “Show Script menu in menu bar” in Script Editor’s preferences.
(If you’re running an old version of OS X, the first version of this answer has the information you’re looking for.)
There's more than one way to do it; i have found this to be the simplest:
In sum, you create an Automator application and place your applescript inside it (easier than it sounds, and it's not a hack either--there's actually a specific Automator action for this). Then when you are finished, you select "File" from the menubar, next "Save As Application", then select a location. Now check there and you'll see the newly-created Automator icon (little white robot holding a grenade launcher).
You can do anything that you would ordinarily do with this application icon--double click to open, drag it to your dock, etc.
Appstorm has created an excellent step-by-step tutorial for building an applescript-embedded automator action. On the page i linked to, the tutorial author has also supplied an Automator script that you can download and use as a template.
While it's certainly not the simplest route, one benefit to running your script from Automator, as doug suggested, is that you can set a hotkey or keyboard shortcut to execute your script if you hide it in an Automator Service (OSX 10.6+). See:
http://blog.fosketts.net/2010/08/09/assign-keyboard-shortcut-applescript-automator-service/
When you save a new script, a menu should appear asking what you want the file name to be, where it will be stored, any tags for it, and what script format you want it to be. There should be 4 scripts formats:
Script
Script Bundle
Application
Text
The script format you want to use would be "Application." This will turn it into a double-click application if its not in the dock.

Resources