Skip to content

Commit

Permalink
do not alias shell keywords for now, and leave that to git
Browse files Browse the repository at this point in the history
  • Loading branch information
roeme committed Nov 25, 2018
1 parent d94633e commit 308c7ed
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions shgit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
}

echo "shgit starting up."
function in_array() {
local -n arr=$1
for item in "${arr[@]}"; do
[[ "${item}" = "${2}" ]] && return 0
done
return 1
}

# read user bashrc
[[ -r ~/.bashrc ]] && {
Expand Down Expand Up @@ -97,11 +104,17 @@ for cmd_alias_entry in "${_sh_cmd_aliases[@]}"; do
done
echo "Done setting up shell aliases." >&2
echo "Loading your pre-defined git aliases" >&2
shell_keywords=( $(compgen -k) )
eval "$(
git config --get-regexp 'alias\..*' |
sed 's/^alias\.//' |
while read key command
do
if in_array shell_keywords $key; then
echo "Warning: Your git alias '$key' is a shell keyword. This usually results in much funkiness, and hence is available as 'git $key'." >&2
# By simply skipping here, we offload the alias interpretation to git.
continue
fi
if expr -- "$command" : '!' >/dev/null
then echo "alias $key='git $key'"
else echo "alias $key=\"git $command\""
Expand Down

0 comments on commit 308c7ed

Please sign in to comment.