fix(aws): stop listing sso-session blocks as profiles

The fallback used when the aws binary is missing matched every bracketed
header, so 'aws_profiles' emitted '[sso-session name]' and
'[services name]' verbatim alongside real profile names.

Only match headers that hold a single unspaced name, optionally prefixed
with 'profile'.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Robby Russell
2026-09-05 16:13:08 -07:00
co-authored by Claude Opus 5
parent 756ce726f5
commit 01271d0ad6
+1 -1
View File
@@ -241,7 +241,7 @@ function aws_regions() {
function aws_profiles() {
aws --no-cli-pager configure list-profiles 2> /dev/null && return
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([^[:space:]]+)\][[:space:]]*$/\2/g'
grep --color=never -Eo '^\[[[:space:]]*(profile[[:space:]]+)?[^][:space:]]+[[:space:]]*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^\[[[:space:]]*(profile[[:space:]]+)?([^][:space:]]+)[[:space:]]*\]$/\2/'
}
function _aws_regions() {