I'm working on an action to allow me to quickly open a url in textmate:
res=$(CocoaDialog inputbox --title "Open URL" \ --informative-text "URL:" \ --button1 "Okay" --button2 "Cancel")
[[ $(head -n1 <<<"$res") == "2" ]] && exit_discard
res=$(tail -n1 <<<"$res") /usr/bin/env ruby -e "require 'net/http';require 'uri';Net::HTTP.get_print URI.parse('$res')" | mate
Basically, I'm using ruby to grab the page and output the content to stdout, then piping that to TextMate. If i call this from the command line, it works perfectly. problem is, if i call this as an command from within textmate, it completely freezed the app. The page does open, but tm becomes completely unresponsive and I have to quit and restart. any ideas what I'm doing wrong?
thanks -dave
ok. I was being stupid here. There's no reason for me to pipe this back into tm. Just choosing "Create new document" from the output pulldown does the same thing.
For those that are interested, here's the final code:
res=$(CocoaDialog inputbox --title "Open URL" \ --informative-text "URL:" \ --button1 "Okay" --button2 "Cancel")
[[ $(head -n1 <<<"$res") == "2" ]] && exit_discard
res=$(tail -n1 <<<"$res") /usr/bin/env ruby -e "require 'net/http';require 'uri';Net::HTTP.get_print URI.parse('$res')"
--------------- save: nothing input: none output: Create New Document
activtaion: cmd+shift+o
for my next trick, I'm going to try to allow the selected text to be the default param for the input box.
-dave
On 1/19/07, Dave Grijalva grijalva@gmail.com wrote:
I'm working on an action to allow me to quickly open a url in textmate:
res=$(CocoaDialog inputbox --title "Open URL" \ --informative-text "URL:" \ --button1 "Okay" --button2 "Cancel")
[[ $(head -n1 <<<"$res") == "2" ]] && exit_discard
res=$(tail -n1 <<<"$res") /usr/bin/env ruby -e "require 'net/http';require 'uri';Net:: HTTP.get_print URI.parse('$res')" | mate
Basically, I'm using ruby to grab the page and output the content to stdout, then piping that to TextMate. If i call this from the command line, it works perfectly. problem is, if i call this as an command from within textmate, it completely freezed the app. The page does open, but tm becomes completely unresponsive and I have to quit and restart. any ideas what I'm doing wrong?
thanks -dave
ok. here's the updated version (sorry if nobody cares)
res=$(CocoaDialog inputbox --title "Open URL" \ --text "$TM_SELECTED_TEXT" \ --informative-text "URL:" \ --button1 "Okay" --button2 "Cancel")
[[ $(head -n1 <<<"$res") == "2" ]] && exit_discard
res=$(tail -n1 <<<"$res") /usr/bin/env ruby -e "require 'net/http';require 'uri';Net::HTTP.get_print URI.parse('$res')"
--------------- save: nothing input: selection or nothing output: Create New Document
On 1/19/07, Dave Grijalva grijalva@gmail.com wrote:
ok. I was being stupid here. There's no reason for me to pipe this back into tm. Just choosing "Create new document" from the output pulldown does the same thing.
For those that are interested, here's the final code:
res=$(CocoaDialog inputbox --title "Open URL" \ --informative-text "URL:" \ --button1 "Okay" --button2 "Cancel")
[[ $(head -n1 <<<"$res") == "2" ]] && exit_discard
res=$(tail -n1 <<<"$res") /usr/bin/env ruby -e "require 'net/http';require 'uri';Net::HTTP.get_print URI.parse('$res')"
save: nothing input: none output: Create New Document
activtaion: cmd+shift+o
for my next trick, I'm going to try to allow the selected text to be the default param for the input box.
-dave
On 1/19/07, Dave Grijalva grijalva@gmail.com wrote:
I'm working on an action to allow me to quickly open a url in textmate:
res=$(CocoaDialog inputbox --title "Open URL" \ --informative-text "URL:" \ --button1 "Okay" --button2 "Cancel")
[[ $(head -n1 <<<"$res") == "2" ]] && exit_discard
res=$(tail -n1 <<<"$res") /usr/bin/env ruby -e "require 'net/http';require 'uri';Net:: HTTP.get_print URI.parse('$res')" | mate
Basically, I'm using ruby to grab the page and output the content to stdout, then piping that to TextMate. If i call this from the command line, it works perfectly. problem is, if i call this as an command from within textmate, it completely freezed the app. The page does open, but tm becomes completely unresponsive and I have to quit and restart. any ideas what I'm doing wrong?
thanks -dave
On Jan 19, 2007, at 8:24 PM, Dave Grijalva wrote:
ok. here's the updated version (sorry if nobody cares)
res=$(CocoaDialog inputbox --title "Open URL" \
You might want to google 'tm_dialog'. We are deprecating CocoaDialog.
Also, we have ruby wrappers for typical user interaction windows, that you can use instead of doing the call yourself, if you are willing to work in ruby that is. They are in Support/lib/dialog.rb. I am seeing dialog.py there also, so you might be able to do that from python if that is your preferred scripting language.
Haris
ooh. I'll have to look into that. I wrote that at work to save me some time, so it was sort of the quick and dirty version. I've been thinking about ways to improve it, though.
-dave
On 1/19/07, Charilaos Skiadas skiadas@hanover.edu wrote:
On Jan 19, 2007, at 8:24 PM, Dave Grijalva wrote:
ok. here's the updated version (sorry if nobody cares)
res=$(CocoaDialog inputbox --title "Open URL" \
You might want to google 'tm_dialog'. We are deprecating CocoaDialog.
Also, we have ruby wrappers for typical user interaction windows, that you can use instead of doing the call yourself, if you are willing to work in ruby that is. They are in Support/lib/dialog.rb. I am seeing dialog.py there also, so you might be able to do that from python if that is your preferred scripting language.
Haris
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