From fc1a555f0f194cc2c1d623a62a6b742aae5cb392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sat, 21 Nov 2015 15:28:44 +0100 Subject: [PATCH 1/2] echo aliased command before executing it to stderr. Could use some color, too. --- git-sh.bash | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/git-sh.bash b/git-sh.bash index 66f3101..fe8890e 100644 --- a/git-sh.bash +++ b/git-sh.bash @@ -75,10 +75,15 @@ 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 ">" "$@" 1>&2 + "$@" +} + # create aliases and configure bash completion for most porcelain commands _git_cmd_cfg=( @@ -159,7 +164,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 @@ -174,8 +179,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 )" From b08f4bc22c0139c722bbc79074139b9a27948855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 12 Jan 2016 15:39:00 +0100 Subject: [PATCH 2/2] reproduce quotes when echoing command --- git-sh.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/git-sh.bash b/git-sh.bash index fe8890e..83caf33 100644 --- a/git-sh.bash +++ b/git-sh.bash @@ -80,7 +80,9 @@ gitalias() { } _git_verbose_exec() { - echo ">" "$@" 1>&2 + echo -n ">" 1>&2 + printf " %q" "$@" 1>&2 + echo 1>&2 "$@" }