Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #aegisub on
- alias aegisub_get_lasteditfile {
- var %fi $findfile($1-,*.*,0)
- var %latestfile_name none
- var %latestfile_time 0
- while (%fi > 0) {
- var %fn $findfile($1-,*.*,%fi)
- if ($_filetime(%fn) > %latestfile_time) {
- var %latestfile_name %fn
- var %latestfile_time $file(%fn).mtime
- }
- dec %fi
- }
- return %latestfile_name
- }
- alias -l _expandenv {
- if (!$com(WSH)) .comopen WSH WScript.Shell
- .timer 0 60 if ($com(WSH)) .comclose WSH
- if (!$comerr) {
- if ($com(WSH,ExpandEnvironmentStrings,1,bstr*,$1-)) {
- return $com(WSH).result
- }
- }
- }
- alias -l _filetime {
- if (!$exists($1-)) return 0
- var %mt $file($1-).mtime
- var %ct $file($1-).ctime
- if (%mt >= %ct) return %mt
- return %ct
- }
- alias aegisub_get_currentfile {
- var %appdata $+(%,appdata,%)
- var %cand1 $aegisub_get_lasteditfile($_expandenv(%appdata $+ \Aegisub\autoback))
- var %cand2 $aegisub_get_lasteditfile($_expandenv(%appdata $+ \Aegisub\autosave))
- if (%cand1 && %cand2) {
- var %mtime1 $_filetime(%cand1)
- var %mtime2 $_filetime(%cand2)
- var %cand $iif(%mtime1 > %mtime2,%cand1,%cand2)
- }
- elseif (%cand1) {
- var %cand %cand1
- }
- elseif (%vand2) {
- var %cand %cand2
- }
- else {
- return
- }
- if ($calc($ctime - $_filetime(%cand)) < 600) return %cand
- }
- alias aegisub_undecorate_filename {
- if (!$exists($1-)) return
- var %fn $nopath($1-)
- var %fn $replace(%fn,.AUTOSAVE.,.,.ORIGINAL.,.)
- return %fn
- }
- alias aegisub_nowediting {
- var %fn $aegisub_get_currentfile
- if (!%fn) {
- /me has not worked on something with Aegisub in the past 10 minutes
- }
- else {
- var %fn $aegisub_undecorate_filename(%fn)
- /me was just (and may still be) using Aegisub to edit $+(",%fn,")
- }
- }
- #aegisub end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement