git을 터미널 환경에서 사용할 때, 텍스트 편집기를 사용하게 된다. 커밋 메시지를 입력하거나 rebase를 할 때 등 에디터를 이용해 뭔가를 많이 한다.
윈도우 환경에서 우분투 WSL을 사용하는데 평소에 쓰지 않던 처음보는 에디터 화면이 보였다.
평소에는 vim 에디터를 사용하는데 뭔가 사용법이 달라서 어버버했다. 알고보니 우분투의 경우 nano 에디터가 기본 에디터로 지정되어 있었다. 이미 vim 단축키들이 반사적으로 나오는 단계여서 너무 불편했다.
git 메시지 편집기 변경
git은 메시지 편집기를 지정해 사용할 수 있다. 익숙한 대로 vim이나 emacs 등의 에디터를 사용할 수 있다.
$ git config --global core.editor "vim"
참고로 우분투의 기본 에디터를 변경하는 방법은 다음과 같다.
$ sudo update-alternatives --config editor
There are 4 choices for the alternative editor (providing /usr/bin/editor).
Selection Path Priority Status
------------------------------------------------------------
* 0 /bin/nano 40 auto mode
1 /bin/ed -100 manual mode
2 /bin/nano 40 manual mode
3 /usr/bin/vim.basic 30 manual mode
4 /usr/bin/vim.tiny 15 manual mode
Press <enter> to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in manual mode
sudo update-alternatives --config editor 를 입력해서 vim.basic 혹은 vim.tiny를 선택하면 기본 에디터가 vim으로 설정된다.
그 밖에 쉘 설정 파일을 이용해 에디터를 바꿀 수도 있다. .bashrc 나 .bash_profile 같은 설정 파일에서 다음과 같이 설정하면 된다.
export EDITOR="/usr/bin/vim.bashc"
댓글