Prine’s Blog

Archiv für August 2009

TextMate Command – Duplicate current selected file

Verfasst von: fedoraswiss in: August 28, 2009

How to configure in TextMate Bundle Editor:

Here the code:

#!/usr/bin/env ruby -w
require „ftools“
require „#{ENV['TM_SUPPORT_PATH']}/lib/textmate“
selected_file = ENV['TM_SELECTED_FILE']
splitted_filename = selected_file.split(„.“)
extension = splitted_filename[splitted_filename.length-1];
new_filename = selected_file.dup
pos = selected_file.length-(extension.length+1)
new_filename.insert(pos, „_copied“)
File.copy(selected_file, new_filename)
if(File.file?(new_filename))
puts „Successfully copied the file: ‘${selected_file}’“
else
puts „FAIL!“
end
TextMate.rescan_project