TextMate Command – Duplicate current selected file

How to configure in TextMate Bundle Editor:

How to configure TextMate Duplicate plugin

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

Advertisements