sublime_terminal
sublime_terminal copied to clipboard
PS.ps1 doesn't launch with portable version of Sublime
Using the portable version of Sublime, PS.bat incorrectly references the location of the packages directory with the hard coded value of %APPDATA%...
With sublime being a portable edition I can't reliably hard code a different path as drive letters change, or in my instance, the Dropbox folder may reside in different physical directories.
I fixed this issue by passing a parametar with the package path to the ps.bat file. I dont know how good of a fix is this, but here is how i did it : add this line to 107 in Terminal.py file
parameters.insert(0, os.path.join(sublime.packages_path(), __name__))
just after:
args = [TerminalSelector.get()]
then change the source of ps.bat to :
IF '%1' == '' goto just_run
GOTO pretify
:just_run
::just run powershell
start powershell
:pretify
::get the first parametar as the scripts location
start powershell -noexit -ExecutionPolicy RemoteSigned -command "& '%1%\ps.ps1'"
its not error prone but it works for me. I hope it works for you too,
In PS.bat, just change
start powershell -noexit -ExecutionPolicy RemoteSigned "%APPDATA%\Sublime` Text` 2\Packages\Terminal\PS.ps1"
into
start powershell -noexit -ExecutionPolicy RemoteSigned "%~dp0\PS.ps1"
I ran into another problem using rjkip's patch: the white-space character in the path. The default directory name of ST2Portable is "Sublime Text 2.0.1", which contains two spaces, causing mistake.
So I work out another approach(two steps):
- Adding
os.putenv("sublime", os.getcwd().replace(' ', '
')) #escape the spaces as the author didbefore
subprocess.Popen(args, cwd=dir.encode(encoding))` in Terminal.py - and changes
start powershell -noexit -ExecutionPolicy RemoteSigned "%APPDATA%\Sublime
Text2\Packages\Terminal\PS.ps1"
intostart powershell -noexit -ExecutionPolicy RemoteSigned "%sublime%\PS.ps1"
This technique is setting the environment variable, and it'll work as long as the ST3 isn't changes a lot in directory structure.
I'll raise a pull request later.