Command to open file with git

后端 未结 18 1288
滥情空心
滥情空心 2021-01-30 04:05
  • I have sublime text as the default editor in git (and it works)
  • git config --edit opens the config file in sublime text (Awesome)
18条回答
  •  后悔当初
    2021-01-30 04:55

    Maybe could be useful to open an editor from a script shared in a git repository, without assuming which editor could have anyone will use that script, but only that they have git.

    Here you can test if editor is set in git config, and also open files not associated with that editor:

    alias editor="$(git config core.editor)"
    if [ "$(alias editor | sed -r "s/.*='(.*)'/\1/")" != "" ]; then
        editor 
    else
        start 
    fi
    

    Works great with my .gitconfig on windows:

    [core]
        editor = 'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin
    

提交回复
热议问题