tfv 6.1.0 → 6.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/modules/shell-init.js +29 -16
- package/package.json +1 -1
|
@@ -11,11 +11,20 @@ _tfv_auto_switch() {
|
|
|
11
11
|
fi
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
# Hook into directory changes without touching cd
|
|
15
|
+
if [ -n "\${ZSH_VERSION:-}" ]; then
|
|
16
|
+
autoload -Uz add-zsh-hook
|
|
17
|
+
add-zsh-hook chpwd _tfv_auto_switch
|
|
18
|
+
elif [ -n "\${BASH_VERSION:-}" ]; then
|
|
19
|
+
_tfv_prev_dir="\$PWD"
|
|
20
|
+
_tfv_dir_check() {
|
|
21
|
+
if [ "\$PWD" != "\$_tfv_prev_dir" ]; then
|
|
22
|
+
_tfv_prev_dir="\$PWD"
|
|
23
|
+
_tfv_auto_switch
|
|
24
|
+
fi
|
|
25
|
+
}
|
|
26
|
+
PROMPT_COMMAND="\${PROMPT_COMMAND:+\${PROMPT_COMMAND}; }_tfv_dir_check"
|
|
27
|
+
fi
|
|
19
28
|
|
|
20
29
|
# Run for the current directory on shell startup
|
|
21
30
|
_tfv_auto_switch
|
|
@@ -72,8 +81,7 @@ function _tfv_auto_switch
|
|
|
72
81
|
end
|
|
73
82
|
end
|
|
74
83
|
|
|
75
|
-
function
|
|
76
|
-
builtin cd $argv
|
|
84
|
+
function _tfv_on_pwd --on-variable PWD
|
|
77
85
|
_tfv_auto_switch
|
|
78
86
|
end
|
|
79
87
|
|
|
@@ -118,19 +126,24 @@ const POWERSHELL_HOOK = `
|
|
|
118
126
|
# Add to your PowerShell profile ($PROFILE):
|
|
119
127
|
# Invoke-Expression (tfv shell-init powershell | Out-String)
|
|
120
128
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
129
|
+
# Hook into directory changes without touching cd
|
|
130
|
+
$global:_TfvLastDir = $PWD.Path
|
|
131
|
+
$global:_TfvUserPrompt = if (Test-Path function:prompt) { $function:prompt } else { $null }
|
|
132
|
+
function global:prompt {
|
|
133
|
+
$currentPath = $PWD.Path
|
|
134
|
+
if ($currentPath -ne $global:_TfvLastDir) {
|
|
135
|
+
$global:_TfvLastDir = $currentPath
|
|
136
|
+
if ((Test-Path ".terraform-version") -or (Get-ChildItem -Filter "*.tf" -ErrorAction SilentlyContinue)) {
|
|
137
|
+
tfv auto-switch --silent 2>$null
|
|
138
|
+
}
|
|
126
139
|
}
|
|
140
|
+
if ($global:_TfvUserPrompt) { & $global:_TfvUserPrompt } else { "PS $($executionContext.SessionState.Path.CurrentLocation)> " }
|
|
127
141
|
}
|
|
128
142
|
|
|
129
|
-
Remove-Item -Path Alias:cd -Force -ErrorAction SilentlyContinue
|
|
130
|
-
Set-Alias -Name cd -Value Set-LocationWithTfv -Scope Global -Force
|
|
131
|
-
|
|
132
143
|
# Run for current directory on shell startup
|
|
133
|
-
|
|
144
|
+
if ((Test-Path ".terraform-version") -or (Get-ChildItem -Filter "*.tf" -ErrorAction SilentlyContinue)) {
|
|
145
|
+
tfv auto-switch --silent 2>$null
|
|
146
|
+
}
|
|
134
147
|
|
|
135
148
|
# ── Tab completions ────────────────────────────────────────────────────────
|
|
136
149
|
Register-ArgumentCompleter -Native -CommandName tfv -ScriptBlock {
|