Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Echo aliased command before executing it #11

Merged
merged 2 commits into from
Jun 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions git-sh.bash
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,17 @@ gitalias() {
local alias="${1%%=*}" command="${1#*=}"
local prog="${command##git }"
prog="${prog%% *}"
alias $alias="$command"
alias $alias="_git_verbose_exec $command"
gitcomplete "$alias" "$prog"
}

_git_verbose_exec() {
echo -n ">" 1>&2
printf " %q" "$@" 1>&2
echo 1>&2
"$@"
}

# create aliases and configure bash completion for most porcelain commands

_git_cmd_cfg=(
Expand Down Expand Up @@ -159,7 +166,7 @@ for cfg in "${_git_cmd_cfg[@]}" ; do
read cmd opts <<< $cfg
for opt in $opts ; do
case $opt in
alias) alias $cmd="git $cmd" ;;
alias) gitalias "$cmd=git $cmd" ;;
stdcmpl) complete -o default -o nospace -F _git_${cmd//-/_} $cmd ;;
logcmpl) complete -o default -o nospace -F _git_log $cmd ;;
esac
Expand All @@ -174,8 +181,8 @@ _git_import_aliases () {
while read key command
do
if expr -- "$command" : '!' >/dev/null
then echo "alias $key='git $key'"
else echo "gitalias $key=\"git $command\""
then echo "gitalias $key='git $key'"
else echo "gitalias $key='git $command'"
fi
done
)"
Expand Down