Hi Allan,
I love this new features in the latest release of SubEthaEdit: It installs a shell command, see, which lets you open up files from the command line by just typing see myfile.rb (or some other file—you get the picture).
Now could we get the same thing for TextMate, please? That would be really useful, since I'm always working in both TextMate and the shell at the same time, and if I need to edit a particular file, it would typically be faster to just open the file from the shell, than to grab the mouse and click-expand/scroll around the folders tree to locate and open it.
I know that I can say open file.name, if that file is already associated with TextMate, but it opens in a separate window, not as part of my project. It would be nice with a command that just always opens TextMate, regardless of associations.
And when you make this feature, make sure you check if the file is already included in one of my open projects, and open it there, not in a separate window.
Thanks! :)
/Lars
Also posted at http://www.pinds.com/blog/one-entry?entry%5fid=21472
For now you can do this by adding the folowing alias to your .bash_profile or whatever shell you use:
tm () { open -a TextMate.app "$*"; }
Jeroen.
On 14. jan 2005, at 15:15, Jeroen van der Ham wrote:
For now you can do this by adding the folowing alias to your .bash_profile or whatever shell you use:
tm () { open -a TextMate.app "$*"; }
Yeah.. I don't think a command is really needed, when an alias like this will do just as well.
I'd disagree. The really nice thing with the bbedit command-line tool is the various options it can take:
bbedit [ -bchlpsuvVw --clean --resume --view-top ] [ -e <encoding_name> ] [ -t <string> ] [ +<n> ] [ file (or) <S/FTP URL> ... ]
you can pass bbedit an ftp/sftp url to open. You can also pipe to it, which can't be done with the alias you mention. Also, there are nifty options like specifying what line number to jump to from the command line (which could be very useful for integrating the editor with a debugger like gdb). You can specify a title for a piped input, print a file from bbedit, and there is the 'wait' option, which causes the bbedit command-line program to wait to exit until the file is closed. This is necessary if you want to define bbedit as your EDITOR environment variable and have it work for pine, crontab, etc.
Some of those features would be very nice to have, and can't be easily accomplished with a shell alias.
On Jan 14, 2005, at 11:17 AM, Sune Foldager wrote:
On 14. jan 2005, at 15:15, Jeroen van der Ham wrote:
For now you can do this by adding the folowing alias to your .bash_profile or whatever shell you use:
tm () { open -a TextMate.app "$*"; }
Yeah.. I don't think a command is really needed, when an alias like this will do just as well.
-- Sune.
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On 14. jan 2005, at 17:45, Noah M. Daniels wrote:
I'd disagree. The really nice thing with the bbedit command-line tool is the various options it can take [...]
True.
Oh and.. please don't top-/bottom-quote! I have to scroll down and figure out what you mean. It's rather confusing :-p. Please people, take the time to quote relevant parts of the message you reply to.
On 14-01-2005 17:45, Noah M. Daniels wrote:
I'd disagree. The really nice thing with the bbedit command-line tool is the various options it can take:
Note that I said "for now".
Allan has a CLI on his (extensive) todo list.
Jeroen.
and there is the 'wait' option, which causes the bbedit command-line program to wait to exit until the file is closed. This is necessary if you want to define bbedit as your EDITOR environment variable and have it work for pine, crontab, etc.
It's actually possible to use TM as your bash editor with a little fiddling... Set the EDITOR variable to the location of the following script, make it executable, and there you are. Works for me, in any case.
Marcin
-------------
#!/bin/sh
## ## This script makes it possible to use TextMate as the editor for the fc ## command, which allows you to edit previous commands in bash, and can be ## invoked on the curent command via ^x^e. ##
tempfile="$1" tempfileBN=`basename "$tempfile"` TMwindowname="Editing from the Command Line..."
# add 'sh' as extension of temp file generated by bash so TM knows it's a # shell file: mv "$tempfile" "$tempfile.sh"
open -a TextMate "$tempfile.sh" # open the temp file containining the command
# set name of TM window and get its id: osascript -e 'tell app "TextMate.app" to set name of front window to "'"$TMwindowname"'"' TMwindowid=`osascript -e 'tell app "TextMate.app" to return id of front window'`
# wait until done editing the temp file: while [[ `osascript -e 'tell app "TextMate.app" to return name of every window whose id is '"$TMwindowid"` != "" ]]; do sleep 0 # set this to something else if there's some need to done
# remove added 'sh' extension from tempfile: mv "$tempfile.sh" "$tempfile"
osascript -e 'tell app "Terminal" to activate'
On Jan 14, 2005, at 8:17 AM, Sune Foldager wrote:
On 14. jan 2005, at 15:15, Jeroen van der Ham wrote:
For now you can do this by adding the folowing alias to your .bash_profile or whatever shell you use:
tm () { open -a TextMate.app "$*"; }
Yeah.. I don't think a command is really needed, when an alias like this will do just as well.
We need a command that will block waiting for the editor window to be closed. For BBEdit, that's the critical function that the 'bbedit' command line tool provides. I would assume that the 'see' tool can do it as well.
The reason is that many command-line tools invoke an external $EDITOR. CVS, Subversion, and especially Perforce's bloody 'forms' are good examples of this.
Chris
On Jan 14, 2005, at 17:51, Chris Thomas wrote:
On Jan 14, 2005, at 8:17 AM, Sune Foldager wrote:
On 14. jan 2005, at 15:15, Jeroen van der Ham wrote:
For now you can do this by adding the folowing alias to your .bash_profile or whatever shell you use:
tm () { open -a TextMate.app "$*"; }
Yeah.. I don't think a command is really needed, when an alias like this will do just as well.
We need a command that will block waiting for the editor window to be closed. For BBEdit, that's the critical function that the 'bbedit' command line tool provides. I would assume that the 'see' tool can do it as well.
What if TextMate is already open? You'd possibly want to close the window created for that file, but not the application, which is how cvs and friends know you're done editing the log file when EDITOR is a console editor like vi.
The only workaround I can think of is something like this (untested, for sh-like shells)
function tm() { open -a TextMate.app "$*" echo -n press a key when done read }
But I don't know AppleScript, maybe something better may be accomplished with it. Anyone?
-- fxn
On 14.01.2005, at 17:51, Chris Thomas wrote:
We need a command that will block waiting for the editor window to be closed. For BBEdit, that's the critical function that the 'bbedit' command line tool provides. I would assume that the 'see' tool can do it as well.
The reason is that many command-line tools invoke an external $EDITOR. CVS, Subversion, and especially Perforce's bloody 'forms' are good examples of this.
IMHO, the right way to do this would be to have a command line tool that uses the ODB interface (which is what FTP clients use to edit remote files) to tell TM to edit the file and notify the tool when the file is saved or closed (so that the tool can then exit).
One problem with this approach is that ODB works with Apple Events, and AFAIK, for TM to notify the tool, the tool must be an application, and must have a unique creator code.
I have some unreleased code that does work around this issue by launching a faceless background helper application, and then making a blocking call to the helper app (via DO) which in turn tells TM to edit the file and notify the helper app when done.
BTW, the helper app can already retreive remote files via SCP (if you have passwordless authentication set up) and upload them when the file is saved by TM.
And while I'm at it, I also have a command line wrapper around SSH that lets you initiate the editing session from the remote shell. That means you can ssh to the remote server, do whatever you have to do there, and when you need to edit a file, run a command that downloads said file to your local Mac, tells your favorite GUI editor (aka TM) to open the file, and re-uploads the file when you save it. (And yes, this is a definitive hack.)
I really think that all of this is pretty cool and would like to release it as open source, but unfortunately I'm currently lacking the time to polish it for release (it works for me already, you know :-)
So, I'm not sure where to go with this. Are people on this list interested in the whole thing, or just in the blocking editor command? I'd really appreciate some feedback.
Thanks, -Ralph.
Hi,
I'm interested in that program and would help out with polishing it if needed. I'm not too good on Applescript yet, but sounds like a good way to learn some more about it. :)
Jeroen.
On 15. jan 2005, at 14:25, Ralph Pöllath wrote:
IMHO, the right way to do this would be to have a command line tool that uses the ODB interface (which is what FTP clients use to edit remote files) to tell TM to edit the file and notify the tool when the file is saved or closed (so that the tool can then exit).
One problem with this approach is that ODB works with Apple Events, and AFAIK, for TM to notify the tool, the tool must be an application, and must have a unique creator code.
Yes, a problem indeed. I think Allan is aiming to use something else (distributed objects) to provide the necessary interface. I think launching faceless background applications etc. is very ugly. A more general, more Cocoa way of doing it (also since ODB really has very poor Cocoa support) would be nice. Allan can correct me if I am wrong, but I think that is what is planned :-).
On 15.01.2005, at 14:25, Ralph Pöllath wrote:
And while I'm at it, I also have a command line wrapper around SSH that lets you initiate the editing session from the remote shell. That means you can ssh to the remote server, do whatever you have to do there, and when you need to edit a file, run a command that downloads said file to your local Mac, tells your favorite GUI editor (aka TM) to open the file, and re-uploads the file when you save it. (And yes, this is a definitive hack.)
I would find that very useful. I administer many servers and grow weary of vi. Can you make this hack available to me? I'd like to see how you're solving the problem.