MichaelAquilina / zsh-you-should-use

📎 ZSH plugin that reminds you to use existing aliases for commands you just typed
GNU General Public License v3.0
1.49k stars 44 forks source link

Minor optimization #135

Closed p1r473 closed 3 months ago

p1r473 commented 4 months ago

Summary of Changes

Benefits of Optimization

alias -g | sort: This remains the same, listing all global aliases and sorting them.

while IFS="=" read -r key value; do: This reads each line of the sorted aliases into the variables key and value directly, using the equal sign (=) as the delimiter. IFS (Internal Field Separator) is set to = to split the line into key and value.

key="${key## }" and key="${key%% }": These lines remove leading and trailing spaces from key respectively. ${key## } removes leading spaces, and ${key%% } removes trailing spaces.

value="${(Q)value}": This remains the same as in the original lines, removing quotes from the value using the (Q) parameter expansion modifier.

MichaelAquilina commented 3 months ago

Tested it out and works well. Thanks :)