@@ -17,6 +17,7 @@ export type AddingPosition = 'start' | 'end'
1717
1818export interface AddDirToPosixEnvPathOpts {
1919 proxyVarName ?: string
20+ proxyVarSubDir ?: string
2021 overwrite ?: boolean
2122 position ?: AddingPosition
2223 configSectionName : string
@@ -93,10 +94,11 @@ async function setupShell (
9394 let newSettings ! : string
9495 const _createPathValue = createPathValue . bind ( null , opts . position ?? 'start' )
9596 if ( opts . proxyVarName ) {
97+ const pathRef = opts . proxyVarSubDir ? `$${ opts . proxyVarName } /${ opts . proxyVarSubDir } ` : `$${ opts . proxyVarName } `
9698 newSettings = `export ${ opts . proxyVarName } ="${ dir } "
9799case ":$PATH:" in
98- *":$${ opts . proxyVarName } :"*) ;;
99- *) export PATH="${ _createPathValue ( `$ ${ opts . proxyVarName } ` ) } " ;;
100+ *":${ pathRef } :"*) ;;
101+ *) export PATH="${ _createPathValue ( pathRef ) } " ;;
100102esac`
101103 } else {
102104 newSettings = `case ":$PATH:" in
@@ -141,9 +143,10 @@ async function setupFishShell (dir: string, opts: AddDirToPosixEnvPathOpts): Pro
141143 let newSettings ! : string
142144 const _createPathValue = createFishPathValue . bind ( null , opts . position ?? 'start' )
143145 if ( opts . proxyVarName ) {
146+ const pathRef = opts . proxyVarSubDir ? `$${ opts . proxyVarName } /${ opts . proxyVarSubDir } ` : `$${ opts . proxyVarName } `
144147 newSettings = `set -gx ${ opts . proxyVarName } "${ dir } "
145- if not string match -q -- $${ opts . proxyVarName } $PATH
146- set -gx PATH ${ _createPathValue ( `$ ${ opts . proxyVarName } ` ) }
148+ if not string match -q -- ${ pathRef } $PATH
149+ set -gx PATH ${ _createPathValue ( pathRef ) }
147150end`
148151 } else {
149152 newSettings = `if not string match -q -- "${ dir } " $PATH
@@ -167,8 +170,11 @@ async function setupNuShell (dir: string, opts: AddDirToPosixEnvPathOpts): Promi
167170 let newSettings ! : string
168171 const addingCommand = ( opts . position ?? "start" ) === "start" ? "prepend" : "append"
169172 if ( opts . proxyVarName ) {
173+ const pathRef = opts . proxyVarSubDir
174+ ? `($env.${ opts . proxyVarName } | path join "${ opts . proxyVarSubDir } ")`
175+ : `$env.${ opts . proxyVarName } `
170176 newSettings = `$env.${ opts . proxyVarName } = "${ dir } "
171- $env.PATH = ($env.PATH | split row (char esep) | ${ addingCommand } $env. ${ opts . proxyVarName } )`
177+ $env.PATH = ($env.PATH | split row (char esep) | ${ addingCommand } ${ pathRef } )`
172178 } else {
173179 newSettings = `$env.PATH = ($env.PATH | split row (char esep) | ${ addingCommand } ${ dir } )`
174180 }
0 commit comments