I'm trying to make a setup that will use emacs as a command line tool to switch git branches.
The idea is to run some command in terminal, something like emacsclient -t -e "(magit-checkout)"
. This will run emacs window with (magit-checkout)
command executed in my terminal. I can then select a branch from the list, press enter, emacs will then checkout this branch, window will close and I'm back to my terminal.
I can't make it work though, running emacsclient -t -e "(magit-checkout)"
just flashes emacs window in my terminal and closes it immediately. It works almost as I want it to work with (magit-commit)
command (the only thing that doesn't work is that emacs window won't close after the operation is done). But it doesn't work with (magit-checkout)
. Is there any way to make it work the way I described?
magit-checkout
needs one argument, you can tryemacsclient -t -e "(call-interactively #'magit-checkout)"
instead. Personally, I use onlymagit-status
(something likeemacsclient -t -e '(magit-status)'
) and start various git operation from the status buffer.C-x 5 0
or useemacsclient -t -e "(call-interactively #'magit-checkout)" -e "(delete-frame)"
. However, I think you cam simply useemacsclient -e "(magit-status)"
then checkout/commit/diff/pull/etc from here. I prefer this way since I am not familiar with the git command line interface.