Andrey Bushman
Andrey Bushman

Reputation: 12476

How can I set the portable text editor as default text editor of Git portable?

Windows, Git v2.11 portable

On the current computer my USB-flash drive has E: name. But on other computer it can to have other letter (for example F: or G:)...

My portable Git (v2.11) is located on the <My USB-drive>:\apps\PortableGit-2.11\ folder. My portable text editor (Sublime Text 3) is located on the <My USB-drive>:\apps\Sublime-Text-3\ folder.

If I write the core.editor value with E then it works fine on my current computer (when I launch the git commit command):

git config --system core.editor "'E:/apps/Sublime-Text-3/sublime_text.exe' -n -w"

But it will not work on other computers where my USB-drive's name uses other letter.

How can I set the portable text editor as default text editor of Git portable without that problem? Is it possible to point the path relatively of portable Git location?

Upvotes: 0

Views: 389

Answers (2)

Vifier Lockla
Vifier Lockla

Reputation: 570

For windows, to open Notepad++ by example, insert line below in file C:\users<user account>.gitconfig :

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

controls it : $ git config --global --list

user.name=<firstName LastName>
user.email=<your email>
merge.tool=kdiff3
diff.guitool=kdiff3
core.editor="C:/Program Files/Notepad++/notepad++.exe" -multiInst -notabbar -nosession -noPlugin
core.rebase=false
fetch.prune=false
rebase.autostash=false

Upvotes: 0

Chananel P
Chananel P

Reputation: 1814

There are 2 enviroment variables that you can use: HOMEDRIVE and EXEPATH.

HOMEDRIVE - the drive that you ran from (eg: C:)

EXEPATH - the full path of where the git ran from (eg: "C:\\MyApps\\GitPortable")

So you can use those 2 in your gitconfig:

editor = "$HOMEDRIVE/apps/Sublime-Text-3/sublime_text.exe"

You need to make sure that the $HOMEDRIVE appears in the gitconfig file (and not manipulated by the shell, so run git config --system --edit and add it directly to there (under [core] section). Also make sure the variables are not inside single quotes ''

Upvotes: 0

Related Questions