From e8a5f775d1300714d026affffe28bd0c508ed416 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 1 Sep 2018 00:22:33 +0700 Subject: [PATCH] Use "^M" on Zsh and "\n" on Bash --- lib/git/keybindings.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/git/keybindings.sh b/lib/git/keybindings.sh index 8ec4066..b286075 100644 --- a/lib/git/keybindings.sh +++ b/lib/git/keybindings.sh @@ -24,16 +24,22 @@ _bind(){ if [[ "$git_keyboard_shortcuts_enabled" = "true" ]]; then case "$-" in *i*) + if [ -n "$ZSH_VERSION" ]; then + RETURN_CHAR="^M" + else + RETURN_CHAR="\n" + fi + # Uses emacs style keybindings, so vi mode is not supported for now if ! set -o | grep -q '^vi .*on$'; then if [[ $shell == "zsh" ]]; then - _bind "$git_commit_all_keys" " git_commit_all""\n" - _bind "$git_add_and_commit_keys" " \033[1~ git_add_and_commit ""\n" - _bind "$git_commit_all_with_ci_skip_keys" " \033[1~ APPEND='[ci skip]' git_commit_all ""\n" + _bind "$git_commit_all_keys" " git_commit_all""$RETURN_CHAR" + _bind "$git_add_and_commit_keys" " \033[1~ git_add_and_commit ""$RETURN_CHAR" + _bind "$git_commit_all_with_ci_skip_keys" " \033[1~ APPEND='[ci skip]' git_commit_all ""$RETURN_CHAR" else - _bind "$git_commit_all_keys" "\" git_commit_all\n\"" - _bind "$git_add_and_commit_keys" "\"\C-A git_add_and_commit \n\"" - _bind "$git_commit_all_with_ci_skip_keys" "\"\C-A APPEND='[ci skip]' git_commit_all \n\"" + _bind "$git_commit_all_keys" "\" git_commit_all$RETURN_CHAR\"" + _bind "$git_add_and_commit_keys" "\"\C-A git_add_and_commit $RETURN_CHAR\"" + _bind "$git_commit_all_with_ci_skip_keys" "\"\C-A APPEND='[ci skip]' git_commit_all $RETURN_CHAR\"" fi fi