Skip to content

Commit

Permalink
Merge pull request #11 from vkaylee/improvement_set_other_aliases_to_…
Browse files Browse the repository at this point in the history
…the_first_alias

Set other aliases to the first alias
  • Loading branch information
vkaylee authored Oct 29, 2023
2 parents b1469f9 + 0f2a72e commit b070647
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,21 @@ myenv_lib_983459816_set_command_aliases(){
local noOkAliasesStr=()
local delimiter=','

for command in ${aliasCommands[@]}; do
local commandTextStyle="$(myenv_lib_983459816_set_color "${command}" '1;92')"
if myenv_lib_983459816_set_alias_command "${command}" "${realCommand}" > /dev/null 2>&1; then
# the first array index is different among shell
local firstArrayIndex
# default first index is zero
firstArrayIndex=0
# For zsh: first index is 1
test "$ZSH_VERSION" && firstArrayIndex=1

for ((i=${firstArrayIndex}; i < ${#aliasCommands[@]} + ${firstArrayIndex}; i++)); do
# Just set real command to the first alias, the first alias will be set to aliases from the second if have
if (( i > ${firstArrayIndex} )); then
realCommand="${aliasCommands[firstArrayIndex]}"
fi

local commandTextStyle="$(myenv_lib_983459816_set_color "${aliasCommands[i]}" '1;92')"
if myenv_lib_983459816_set_alias_command "${aliasCommands[i]}" "${realCommand}" > /dev/null 2>&1; then
if [[ -n "${okAliasesStr}" ]]; then
okAliasesStr="${okAliasesStr}${delimiter}${commandTextStyle}"
else
Expand Down

0 comments on commit b070647

Please sign in to comment.