|
1 | 1 | import sublime, sublime_plugin |
2 | | -import os, platform, shutil, tempfile, json, re, sys |
| 2 | +import os, platform, shutil, tempfile, json, re, sys, shellenv |
3 | 3 | from subprocess import Popen, PIPE |
4 | 4 | from .src.libs.global_vars import * |
5 | 5 | from .src.libs import util |
@@ -111,32 +111,8 @@ def start(): |
111 | 111 | fixPathSettings = None |
112 | 112 | fixPathOriginalEnv = {} |
113 | 113 |
|
114 | | -def getSysPath(): |
115 | | - command = "" |
116 | | - if platform.system() == "Darwin": |
117 | | - command = "env TERM=ansi CLICOLOR=\"\" SUBLIME=1 /usr/bin/login -fqpl $USER $SHELL -l -c 'TERM=ansi CLICOLOR=\"\" SUBLIME=1 printf \"%s\" \"$PATH\"'" |
118 | | - elif platform.system() == "Linux": |
119 | | - command = "env TERM=ansi CLICOLOR=\"\" SUBLIME=1 $SHELL --login -c 'TERM=ansi CLICOLOR=\"\" printf \"%s\" $PATH'" |
120 | | - else: |
121 | | - return "" |
122 | | - |
123 | | - # Execute command with original environ. Otherwise, our changes to the PATH propogate down to |
124 | | - # the shell we spawn, which re-adds the system path & returns it, leading to duplicate values. |
125 | | - sysPath = Popen(command, stdout=PIPE, shell=True, env=fixPathOriginalEnv).stdout.read() |
126 | | - |
127 | | - # this line fixes problems of users having an "echo" command in the .bash_profile file or in other similar files. |
128 | | - sysPath = sysPath.splitlines()[-1] |
129 | | - |
130 | | - sysPathString = sysPath.decode("utf-8") |
131 | | - # Remove ANSI control characters (see: http://www.commandlinefu.com/commands/view/3584/remove-color-codes-special-characters-with-sed ) |
132 | | - sysPathString = re.sub(r'\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]', '', sysPathString) |
133 | | - sysPathString = sysPathString.strip().rstrip(':') |
134 | | - |
135 | | - # Decode the byte array into a string, remove trailing whitespace, remove trailing ':' |
136 | | - return sysPathString |
137 | | - |
138 | 114 | def fixPath(): |
139 | | - currSysPath = getSysPath() |
| 115 | + currSysPath = ':'.join(shellenv.get_path()[1]) |
140 | 116 | # Basic sanity check to make sure our new path is not empty |
141 | 117 | if len(currSysPath) < 1: |
142 | 118 | return False |
|
0 commit comments