Skip to content

Commit fb545c0

Browse files
committed
correctly support path wildcard and tilde expansion - single line
1 parent f31a2a2 commit fb545c0

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

gitprofiles.plugin.zsh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,22 @@ function __gitprofiles_hook() {
3535

3636
# Function to parse paths into an array and support tidle expansion
3737
function __parse_paths() {
38-
local raw_paths="${(j:\n:)@}" # join on newlines
39-
local paths=(${(f)${(s:,:)raw_paths}}) # split on commas & newlines
38+
local raw_paths="${(j:\n:)@}" # join args with newlines
39+
local temp=(${(s:,:)raw_paths}) # split on commas first
40+
# Now split each part by newlines
41+
local paths=()
42+
for part in $temp; do
43+
paths+=(${(f)part}) # split on newlines
44+
done
45+
46+
# Process each path
47+
paths=(${paths##[[:space:]]}) # Trim leading spaces
48+
paths=(${paths%%[[:space:]]}) # Trim trailing spaces
49+
paths=(${~paths}) # Expand tilde
50+
paths=(${paths:#}) # Remove empty elements
4051

41-
paths=(${paths##[[:space:]]}) # Trim leading spaces
42-
paths=(${paths%%[[:space:]]}) # Trim trailing spaces
43-
paths=(${~paths}) # Expand tilde
44-
paths=(${paths:#}) # Remove empty elements
4552
echo ${paths}
46-
}
53+
}
4754

4855
## Iterate over all profiles to get the name, email, signingkey and path
4956
for profile in ${profiles}; do

0 commit comments

Comments
 (0)