sublime_terminal icon indicating copy to clipboard operation
sublime_terminal copied to clipboard

PS.ps1 doesn't launch with portable version of Sublime

Open richardfleming opened this issue 13 years ago • 3 comments

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.

richardfleming avatar Feb 06 '12 21:02 richardfleming

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,

qlayer avatar May 05 '12 16:05 qlayer

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"

rjkip avatar Jun 15 '12 12:06 rjkip

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):

  1. Adding os.putenv("sublime", os.getcwd().replace(' ', ' ')) #escape the spaces as the author didbeforesubprocess.Popen(args, cwd=dir.encode(encoding))` in Terminal.py
  2. and changes start powershell -noexit -ExecutionPolicy RemoteSigned "%APPDATA%\Sublime Text 2\Packages\Terminal\PS.ps1" into start 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.

pjw91 avatar Apr 15 '13 18:04 pjw91