Created
August 22, 2014 16:04
-
-
Save voostindie/4d57d7b7729431026a32 to your computer and use it in GitHub Desktop.
TextMate 2 command to rename the current file in place, using a shortcut (Ctrl + Cmd + R)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>beforeRunningCommand</key> | |
<string>nop</string> | |
<key>command</key> | |
<string>#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -wKU | |
require "#{ENV['TM_SUPPORT_PATH']}/lib/ui" | |
require "#{ENV['TM_SUPPORT_PATH']}/lib/textmate" | |
filename = TextMate::UI.request_string( | |
:title => "Rename File", | |
:prompt => "To:", | |
:default => ENV["TM_FILENAME"] | |
) | |
exit if filename == nil | |
filepath = ENV["TM_FILEPATH"].gsub(ENV["TM_FILENAME"], filename) | |
File.rename(ENV["TM_FILEPATH"], filepath) | |
TextMate.rescan_project | |
TextMate.go_to :file => filepath</string> | |
<key>input</key> | |
<string>none</string> | |
<key>inputFormat</key> | |
<string>text</string> | |
<key>keyEquivalent</key> | |
<string>^@r</string> | |
<key>name</key> | |
<string>Rename file</string> | |
<key>outputCaret</key> | |
<string>afterOutput</string> | |
<key>outputFormat</key> | |
<string>text</string> | |
<key>outputLocation</key> | |
<string>discard</string> | |
<key>uuid</key> | |
<string>70EBE8F1-50FF-4C67-B379-9F5B71A2266E</string> | |
<key>version</key> | |
<integer>2</integer> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment