Skip to content

Instantly share code, notes, and snippets.

@jugyo
Created March 31, 2011 08:08
Show Gist options
  • Save jugyo/896013 to your computer and use it in GitHub Desktop.
Save jugyo/896013 to your computer and use it in GitHub Desktop.
The TextMate command to rename file
#!/usr/bin/env ruby
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"]
)
filepath = ENV["TM_FILEPATH"].gsub(ENV["TM_FILENAME"], filename)
File.rename(ENV["TM_FILEPATH"], filepath)
TextMate.rescan_project
TextMate.go_to :file => filepath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment