-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaste_object.py
More file actions
28 lines (24 loc) · 1.08 KB
/
paste_object.py
File metadata and controls
28 lines (24 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import sublime, sublime_plugin, subprocess, os, shutil, functools
class paste_object(sublime_plugin.TextCommand):
def run(self, edit):
source_path = sublime.get_clipboard()
ObjPath, ObjBase = os.path.split(source_path)
view = self.view.window().show_input_panel("Paste as:", ObjBase, self.on_done, None, None)
def on_done(self, NewBaseName):
cur_file = self.view.file_name()
CurPath, CurBase = os.path.split(cur_file)
old_source_path = sublime.get_clipboard()
OldObjPath, OldObjBase = os.path.split(old_source_path)
new_source_path = os.path.join(OldObjPath, NewBaseName)
sublime.set_clipboard(new_source_path)
os.rename(old_source_path, new_source_path)
shutil.copy(new_source_path, CurPath)
self.view.window().run_command("paste_simple", {"string": "[[" + NewBaseName + "]]"})
self.window.run_command('hide_panel')
# command = "IfExist, %clipboard% \
# `n Dir =" + CurPath + "\
# `n FileCreateDir, %Dir% \
# `n FileCopy, %clipboard%, %Dir% \
# `n SplitPath, clipboard, OutFileName \
# `n clipboard = [[obj\\%OutFileName%]] \
# `n SendInput ^v"