Created
May 19, 2012 10:18
-
-
Save mcasimir/2730364 to your computer and use it in GitHub Desktop.
Create and open file bundle for Textmate 2
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
#!/usr/bin/env ruby -wKU | |
# Create and open file bundle for Textmate 2 | |
# Key equivalent: @N | |
$: << ENV['TM_SUPPORT_PATH'] + '/lib' | |
require "ui" | |
filename = TextMate::UI.request_string(:title => "Create and open file", | |
:prompt => "Enter the file name", | |
:button1 => "Create") | |
if filename | |
selected_file, project_dir = ENV.values_at('TM_SELECTED_FILE', 'TM_PROJECT_DIRECTORY') | |
base_dir = selected_file ? (File.directory?(selected_file) ? selected_file : File.dirname(selected_file)) : project_dir | |
target = File.join(base_dir, filename) | |
`touch #{target}` | |
`mate #{target}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment