Add support for pre/post alias evaluation
This commit is contained in:
parent
2d6f7ff2ab
commit
17e66a1126
1 changed files with 6 additions and 0 deletions
|
|
@ -125,6 +125,10 @@ _try_abbrev_internal () {
|
||||||
# Strip special flags (or space) from the beginning of the replacement
|
# Strip special flags (or space) from the beginning of the replacement
|
||||||
replacement=${replacement#[*$ -]}
|
replacement=${replacement#[*$ -]}
|
||||||
|
|
||||||
|
[[ ${replacement: -1} = "!" ]] && declare -r eval_expansion=true || declare -r eval_expansion=false
|
||||||
|
|
||||||
|
[[ ${replacement: -1} = "$" ]] && replacement=$(eval "${replacement%$}")
|
||||||
|
|
||||||
# Recursively expand replacement if we haven't expanded it already
|
# Recursively expand replacement if we haven't expanded it already
|
||||||
declare tmp=" $replacement"
|
declare tmp=" $replacement"
|
||||||
[[ $tmp =~ ^([[:space:]]*$is_first_word_prefix) ]] && tmp=${tmp#"${BASH_REMATCH[1]}"}
|
[[ $tmp =~ ^([[:space:]]*$is_first_word_prefix) ]] && tmp=${tmp#"${BASH_REMATCH[1]}"}
|
||||||
|
|
@ -136,6 +140,8 @@ _try_abbrev_internal () {
|
||||||
_try_abbrev_internal " $replacement" "$point_for_replacement" "" "ret_$level" "_" "_" ""
|
_try_abbrev_internal " $replacement" "$point_for_replacement" "" "ret_$level" "_" "_" ""
|
||||||
replacement=${recursively_expanded_replacement# }
|
replacement=${recursively_expanded_replacement# }
|
||||||
fi
|
fi
|
||||||
|
# Eval if it has a trailing exclamation point and strip trailing \n and \r
|
||||||
|
[[ $eval_expansion = true ]] && replacement=$(eval "${replacement%!}")
|
||||||
|
|
||||||
# Calculate point and mark offset.
|
# Calculate point and mark offset.
|
||||||
declare -ir offset=${#replacement}-${#word_at_point}+${#self_insertion}
|
declare -ir offset=${#replacement}-${#word_at_point}+${#self_insertion}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue