scmbreeze / scm_breeze

Adds numbered shortcuts to the output git status, and much more
https://madebynathan.com/2011/10/19/git-shortcuts-like-youve-never-seen-before/
MIT License
2.82k stars 192 forks source link

Use ^M instead of for newlines #246

Closed michaelmior closed 6 years ago

michaelmior commented 6 years ago

Consider adding keybindings to make multiline editing easier such as the following:

if [[ "$MC_SID" != "" || "$MC_CONTROL_PID" != "" ]]; then
    bindkey "^J" accept-line
else
    bindkey "^J" self-insert
fi

When this is done \n no longer submits the command but ^M will work in both cases.

ghthor commented 6 years ago

I don't think I use this area of the library. What type of workflow does this support? Is this patch changing how I commit my message if I use gca or does it only apply to the cases where I use the direct keybindings to open the git_commit_all dialog?

michaelmior commented 6 years ago

Everything still works exactly the same except in the case where remappings such as the one I posted above exist. In those cases, assume I have git_commit_all_keys="\C-x ". After pressing CTRL+x SPACE I would still have to press enter before git_commit_all is executed. This patch fixes this behaviour. In the case where such bindings are not set, nothing changes.

michaelmior commented 6 years ago

Thanks!

ghthor commented 6 years ago

You are welcome! =)

ndbroadbent commented 5 years ago

@michaelmior I'm also seeing $ git_commit_all^M in iTerm2 on Mac, where ^M should be simulating the "return" key to submit the command.

Was your PR meant to include the following code somewhere?

if [[ "$MC_SID" != "" || "$MC_CONTROL_PID" != "" ]]; then
    bindkey "^J" accept-line
else
    bindkey "^J" self-insert
fi

It looks like bindkey is also only available in zsh. Maybe we could use ^M for zsh, and stick with \n on bash. I'm going to revert this for now because I use the Ctrl + x + space shortcut very frequently, but would like to hear more about the advantage of switching to ^M

michaelmior commented 5 years ago

My PR did exactly what I was intending it to do on Linux. Unfortunately, I did not have a macOS machine to test on at the time. I use the Ctrl + x + space shortcut frequently myself and it was not correctly working for me on Linux before this PR.

ndbroadbent commented 5 years ago

Ah interesting, are you using Zsh or Bash? Maybe we can check for the OS with something like:


unameOut="$(uname -s)"case "${unameOut}" in
    Linux*)     machine=Linux;;
    Darwin*)    machine=Mac;;
    CYGWIN*)    machine=Cygwin;;
    MINGW*)     machine=MinGw;;
    *)          machine="UNKNOWN:${unameOut}"esac
echo ${machine}

On Sat, Sep 1, 2018 at 12:06 AM Michael Mior notifications@github.com wrote:

My PR did exactly what I was intending it to do on Linux. Unfortunately, I did not have a macOS machine to test on at the time. I use the Ctrl + x + space shortcut frequently myself and it was not correctly working for me on Linux before this PR.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/scmbreeze/scm_breeze/pull/246#issuecomment-417730341, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIhEAo6HBSoPte3_jCVqtDR_UrU3ciWks5uWW0egaJpZM4TTZYo .

ndbroadbent commented 5 years ago

Your initial comment had some code that referred to bindkey, so I'm assuming that you're on Zsh (because there is no bindkey command in bash.)

So please let me know if e8a5f775d1300714d026affffe28bd0c508ed416 works for you

michaelmior commented 5 years ago

@ndbroadbent Sorry for the delayed response. That does indeed work for me!