I bet this is really obvious but I can't find how to open the linked file that the Caret is currently on in Textmate. For example in the likes of Dreamweaver you can click in the index.html portion of <a href"index.html" hit cmd-D and it opens this file in a new tab. Is this possible?
Would also be good to do this with <img src="image.jpg" to open the file directly into Photoshop.
Solved!
Solution for Patrick below.
I used a modified version of Daustin777's example above to create a Command called OpenatCaret.
The command is: open "$TM_PROJECT_DIRECTORY"/"$TM_SELECTED_TEXT"
I then extended this by installing a macro which allowed you to select a path between double quotes but not including the quotes. I got this from the macromates board here. http://lists.macromates.com/textmate/2009-June/028965.html
To wrap them both together I put my cursor in a path and recorded a new macro where I run the "Select within double quotes" macro and then the OpenatCaret command. I then named this OpenProjectFileAtCaret and bound this macro to cmd-D.
Works a treat and is used all the time. Just make sure you have the correct default apps setup for each file type you are opening eg. Textmate for php, asp, html and it will open them in a new tab.
I don't have a full solution as a linked bundle but this should get you close.
You can use the Bundle Editor to create a command that will open an image if you select the path. Create a new command and enter this:
open "$TM_DIRECTORY"/"$TM_SELECTED_TEXT"
Set Input to Selected Text or Word Set Output to Discard Set Key Equivalent to an unused key combination.
Close the editor. Now you should be able to select an image path and it will open when you press the appropriate keyboard shortcut.
You can add the -a flag to the open command to specify which application to use to open the selected file. This is just a basic example and not an entire solution that will work with every type of file path.
You can get info on Textmate environment variables here.
Related
I would like to add a context menu item in MacOS Mojave which gives the option to create a new file in the finder on a right click (the way you would in windows). I would also like to be able to specify the file type (text, word, html, css, javascript, etc)
I have followed a tutorial online in order to create the context menu item with automator but I am not familiar with writing shell scripts.
is it just as simple as:
for f in "$#"
do
touch "$f"
done
I was able to implement this following the instructions here: How to get Create New Text File from context menu
The only drawback as it stands is that you need to select a folder in finder to get the context menu. I would like to be able to click in the current I am in and get the menu but I can live with this. Hope this helps someone else.
This tool provides the "Create a file here" option out of the box. With this tool you can easily create your own options as well by writing simple shell scripts. The tool is free and the page has a link to the source if you want to check the source. The source has a shell script that creates a file in a directory that is given as an argument to the script. The script avoids file name conflicts when creating new files.
How to create a .vm (velocity template file) from command line in Windows
Based on you comment I assume what you really mean is how to made file which by default opens with some specific program you have. Here is several thing to be taken into account:
To create .vm file from command line you can use this question
By default windows doesn't show file extensions in explorer - so you won't actually see that it is .vm file in explorer. Reffer this guide to show file extensions.
There is such thing as file associations - e.g. default program to be use when you open file (for example double click). Also this affect icon shown for the file in explorer.
So to summarize - file created from command line(using method from referred question) have .vm extension. You don't see this cause your windows settings doesn't show extensions. You assume it is text file cause notepad++ icon shown for it as well as it opens with notepad++. That's a wrong assumption - simple you have notepad++ associated to open .vm files. If you want to use different program - you need either:
Change file associations (see link above).
Use open with option to open file with another program (right click menu option)
Use Open function from inside your program.
I am creating a directory synch application in java programming application. Now i want to add share option when user right click with in a specific directory, and want to open an dynamic url on clicking that new option. Can anyone help me to find any good solution. Can anyone provide me Registry Script For this task.
An msdn resource on Extending Shortcut Menus will be good for you.
Anyway, I'd like to introduce my own "minimal" example. This opens a gnuplot's wgnuplot terminal at the right-clicked directory after choosing "Open gnuplot here" shortcut.
You can add keys into HKEY_CLASSES_ROOT\Directory\shell. I added HKEY_CLASSES_ROOT\Directory\shell\gnuplot with string (name: (Default)) Open gnuplot here, provided an icon string with the program's icon path, a LegacyEnable empty string and a command key that windows have to execute when clicking. You can reach the right clicked directory name with %V (You can find out more special variables on this Q&A thread at SU). Here's the code that creates the structure:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\gnuplot]
#="Open gnuplot here"
"Icon"="\"C:\\Windows\\icons\\wgnuplot.ico\""
"LegacyEnable"=""
[HKEY_CLASSES_ROOT\Directory\shell\gnuplot\command]
#="\"C:\\Users\\Cron\\Documents\\egyetem\\gnuplot\\bin\\pgnuplot.exe\" -e \"cd '%V'\" -persist"
A lot of dev environments have some basic parsing logic applied to the output of programs while debugging such that if a program writes to the console (as a result of an error, assert) something like:
/Users/Foo/Project/SomeFile.m:12 - SOMETHING BAD HAPPENED HERE
the file path & line name are automatically detected as link to source, and one can click or double click on the text in question inside the console window to make the source editor jump here.
I have been trying to find out if XCode has something similar, but I haven't had much luck. Is any such functionality missing in XCode or am I just not finding the preferred text shape that it prefers?
Thanks
I just remembered "Open Quickly…". If you copy the text of the file name, then use the "Open Quickly…" function (Cmd-Shift-O by default), you can paste the filename in and press enter, and it will display the file.
I often want to find uncommented print statements in my (Python) file. I have a simple regex ^\s*print that does the job. Is there a way to assign this to a keyboard shortcut so it will Find the next uncommented print, without me having to enter the regex?
My first thought was to create a command that will find it, but I don't have a way to move the cursor to the line once I find it.
You can use the Macro feature inside TextMate:
Go to Bundles > Macros > Start Recording (⌥⌘M)
Perform a single find command with your regex
Go to Bundles > Macros > Stop Recording (⌥⌘M)
Go to Bundles > Macros > Save Last Recording (⌃⌘M)
Save your macro with a suitable name and keyboard shortcut into which ever bundle you like. A nice idea would be to save it into the default Python Bundle, so that the keyboard shortcut is only available when you have a Python file open.