防止magit`:`切换到另一个窗口
在 shell 中使用 git 几个小时后,我切换到 magit。
它非常简洁和高效:我不再需要输入“git”来调用 git 命令!
但与 shell 命令行相比,我仍然发现了一个缺点。
每次我输入 : 来调用 git 命令时,输出都会在另一个窗口中弹出。我必须输入 Cx o 才能切换回来,然后再次输入 git 命令。
除了 Emacs 中的 shell-mode
之外,还有更好的方法可以同时保持输入和观察输出吗?
我应该将输出重新绑定到其他模式吗?哪一个?或者更优雅的解决方案?
After several hours of using git
in the shell, I switched to magit.
It's pretty neat and efficient: I don't need to type "git" to invoke a git command anymore!
But I still found one drawback comparing to the shell command line.
Every time I typed : to invoke a git command, the output popped out in the other window. I had to type C-x o to switch back then type the git command again.
Is there a better way to keep typing and watching on the output at the same time other than shell-mode
in Emacs?
Should I rebind the output to some other mode? Which one? or a more elegant solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我同意布莱恩的观点,你想做什么是魔法师通过简单的按键触发器无法做到的?可能已经有一个键绑定了。如果不是,我只需
Cz
进入 shell 并运行命令,然后输入fg
将 emacs 返回到前台。编辑:我的流程是这样的。
emacs file1 file2
中打开未提交的文件,要么打开一些我要处理的文件。Cc i
打开 Magit 状态窗口。s
暂存这些更改,也可以按u
取消暂存这些更改。s
和u
来暂存和取消暂存代码部分。如果我在某处有一些调试代码并且想要杀死它,这很有用。c
打开 magit-edit-log。我输入提交消息,然后输入Cc Cc
进行提交。然后P
来推送它。完毕!请注意,这听起来像是很多步骤,但它很快就会变得自然,整个过程实际上需要 30 秒,我才能比较我的整个更改集,暂存它们,并通过消息提交它们。一直在 Emacs 中进行。比直接进入命令行要容易得多。
有时,当我通过 Magit 进行推送时会返回错误,通常是由于远程存储库中的新代码导致我必须在推送之前拉取。在这种情况下,
F
会拉取更改,然后再次P
会推送。老实说,出于某种原因,在这种情况下,我通常只是Ctrl-z
,下拉到 shell、git pull
和git Push<,而不是通过 Magit 拉取。 /代码>。
编辑:我想我记得 Magit 的默认差异颜色非常糟糕。我在我的 .emacs 中使用了以下内容,我确信我是从某个地方偷来的:
I agree with Brian, what are you trying to do that magit can't do via a simple key trigger? There's probably a key-binding for it already. If not I just
C-z
to drop to shell and run the command, then typefg
to bring emacs back in foreground.Edit: My flow goes like this.
git diff
in command line just to see if I have any uncommitted changes from the previous day (don't forget to enabled colors!) The reason I do this in command line as apposed to magit is because I'm not in emacs yet.emacs file1 file2
or I open some files I'm about to work on.C-c i
to open up the Magit status window.s
to stage those changes oru
to unstage those changes.s
andu
to stage and unstage sections of the code. Useful if I had some debug code somewhere and want to kill it.c
to open the magit-edit-log. I type my commit message and then typeC-c C-c
to commit it. ThenP
to push it. Done!Note that this sounds like a lot of steps but it becomes quickly natural and the whole process literally takes 30 seconds for me to diff my entire set of changes, stage them, and commit them with a message. All while staying in Emacs. So much easier than dropping down to command line.
Sometimes an error is returned when I do a push via Magit usually caused by new code in the remote repo that I have to pull before I push. In this case
F
to pull changes thenP
again to push. Honestly for some reason, instead of pulling through magit, I generally justCtrl-z
in this situation, drop down to shell,git pull
, andgit push
.Edit: I think I remember Magit's default diff colors being pretty atrocious. I use the following in my .emacs I'm sure I stole from somewhere:
当我使用 Magit 时,我通常使用 Magit 的内置命令来完成大部分工作,而当我需要执行 Magit 内置命令无法完成的操作时,只需使用常规终端即可。 Magit 有内置命令几乎可以满足我的日常使用;你经常使用哪些 Magit 不提供的功能,而且你无论如何也不会在成熟的终端中使用?
I usually use Magit's built in commands for most of my work when I'm using Magit, and just use a regular terminal when I need to do things that I can't do from Magit's built in commands. Magit has built in commands for almost all of my day to day usage; what are you using regularly that Magit doesn't supply and you wouldn't be doing in a full-fledged terminal anyhow?
关于
magit-run*
的建议解决了这个问题。可能会中断对magit-run*
的其他调用,我没有进一步测试......An advice on
magit-run*
solves this. Might disrupts other calls tomagit-run*
, I didn't test this further...