From 25d2d517da58257cfd63b9ecc671e402f95fd107 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Wed, 4 Nov 2009 03:14:44 +0100 Subject: [PATCH] Fix the window icon and title for "Git Bash" when launched via shell extension Windows sets the initial icon and title for command line windows to the icon and name of the shortcut that launched the program. So, in order to get a proper icon and title for "Git Bash Here", it needs to launch a shortcut. As the Regitry's "command" key cannot launch shortcuts directly, we need a wrapper in the form of a Visual Basic Script that uses the ShellExecute function to do so. That script also changes the current directory as needed and launches a special version of the "Git Bash" shortcut that does not set a working directory, so the current directory is not overridden. Signed-off-by: Sebastian Schuberth --- share/WinGit/Git Bash.vbs | 10 ++++++++++ share/WinGit/ReleaseNotes.rtf | 3 +-- share/WinGit/copy-files.sh | 1 + share/WinGit/install.iss | 6 ++++-- 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 share/WinGit/Git Bash.vbs diff --git a/share/WinGit/Git Bash.vbs b/share/WinGit/Git Bash.vbs new file mode 100644 index 00000000..365189b4 --- /dev/null +++ b/share/WinGit/Git Bash.vbs @@ -0,0 +1,10 @@ +' If there is an argument, use it as the directory to change to. +If WScript.Arguments.Length=1 Then + Set WshObj = CreateObject("WScript.Shell") + WshObj.CurrentDirectory = WScript.Arguments(0) +End If + +' Launch the shortcut in the current directory which has the same +' base name as this script. +Set AppObj = CreateObject("Shell.Application") +AppObj.ShellExecute(Replace(WScript.ScriptFullName, ".vbs", ".lnk")) diff --git a/share/WinGit/ReleaseNotes.rtf b/share/WinGit/ReleaseNotes.rtf index bb5173a4..47dbfbd0 100644 --- a/share/WinGit/ReleaseNotes.rtf +++ b/share/WinGit/ReleaseNotes.rtf @@ -1,6 +1,6 @@ {\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\fnil\fcharset0 Arial;}{\f2\fnil\fcharset2 Symbol;}} {\colortbl ;\red0\green0\blue0;} -{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\cf1\lang1033\b\f0\fs32 Git Release Notes (Git-1.6.5.1-preview20091022)\b0\fs20\par +{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\cf1\lang1033\b\f0\fs32 Git Release Notes (Git-1.6.5.1-preview20091022)\b0\fs20\par Last update: 22 October 2009\par \par \b\fs24 Introduction\b0\fs20\par @@ -12,7 +12,6 @@ General release notes covering the history of the core git commands are included \pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent0{\pntxtb\'B7}}\fi-288\li432\b0\fs20 Some commands are not yet supported on Windows and excluded from the installation; namely: git archimport, git cvsexportcommit, git cvsimport, git cvsserver, git instaweb, git shell.\par {\pntext\f2\'B7\tab}The Logitec QuickCam software can cause spurious crashes. See "Why does make often crash creating a sh.exe.stackdump file when I try to compile my source code?" on the MinGW Wiki (http://www.mingw.org/wiki/Environment_issues)\par {\pntext\f2\'B7\tab}The Quick Launch icon will only be installed for the user running setup (typically the Administrator). This is a technical restriction and will not change.\par -{\pntext\f2\'B7\tab}Git Bash launched through the Explorer shell extension does not have the git icon in its taskbar. This is a technical restriction and will not change.\par {\pntext\f2\'B7\tab}curl uses $HOME/_netrc instead of $HOME/.netrc.\par {\pntext\f2\'B7\tab}If you want to specify a different location for --upload-pack, you have to start the absolute path with two slashes. Otherwise MSys will mangle the path.\par {\pntext\f2\'B7\tab}git and bash have serious problems with non-ASCII file names (Issue 80, 159).\par diff --git a/share/WinGit/copy-files.sh b/share/WinGit/copy-files.sh index 438830ff..f591f322 100644 --- a/share/WinGit/copy-files.sh +++ b/share/WinGit/copy-files.sh @@ -80,6 +80,7 @@ cp /git/contrib/completion/git-completion.bash etc/ && cp /etc/termcap etc/ && cp /etc/inputrc etc/ && sed 's/ = \/mingw\// = \//' < /etc/gitconfig > etc/gitconfig && +cp /share/WinGit/Git\ Bash.vbs . && cp /share/WinGit/ReleaseNotes.rtf . && sed 's/^\. .*\(git-completion.bash\)/. \/etc\/\1/' \ < /etc/profile > etc/profile && diff --git a/share/WinGit/install.iss b/share/WinGit/install.iss index d8dd9920..0dd91f14 100644 --- a/share/WinGit/install.iss +++ b/share/WinGit/install.iss @@ -48,6 +48,9 @@ Name: {group}\Uninstall Git; Filename: {uninstallexe} Name: {userappdata}\Microsoft\Internet Explorer\Quick Launch\Git Bash; Filename: {syswow64}\cmd.exe; Parameters: "/c """"{app}\bin\sh.exe"" --login -i"""; WorkingDir: %HOMEDRIVE%%HOMEPATH%; IconFilename: {app}\etc\git.ico; Tasks: quicklaunchicon Name: {code:GetShellFolder|desktop}\Git Bash; Filename: {syswow64}\cmd.exe; Parameters: "/c """"{app}\bin\sh.exe"" --login -i"""; WorkingDir: %HOMEDRIVE%%HOMEPATH%; IconFilename: {app}\etc\git.ico; Tasks: desktopicon +; Create a special shortcut that does not set a working directory. This is used by "Git Bash.vbs", which in turn is run by the "Git Bash Here" shell extension. +Name: {app}\Git Bash; Filename: {syswow64}\cmd.exe; Parameters: "/c """"{app}\bin\sh.exe"" --login -i"""; IconFilename: {app}\etc\git.ico; Tasks: shellextension + [Messages] BeveledLabel={#emit APP_URL} SetupAppTitle={#emit APP_NAME} Setup @@ -849,9 +852,8 @@ begin end; if IsTaskSelected('shellextension') then begin - Cmd:=ExpandConstant('"{syswow64}\cmd.exe"'); if (not RegWriteStringValue(RootKey,'SOFTWARE\Classes\Directory\shell\git_shell','','Git Ba&sh Here')) or - (not RegWriteStringValue(RootKey,'SOFTWARE\Classes\Directory\shell\git_shell\command','',Cmd+' /c "pushd "%1" && "'+AppDir+'\bin\sh.exe" --login -i"')) then begin + (not RegWriteStringValue(RootKey,'SOFTWARE\Classes\Directory\shell\git_shell\command','','wscript "'+AppDir+'\Git Bash.vbs" "%1"')) then begin Msg:='Line {#emit __LINE__}: Unable to create "Git Bash Here" shell extension.'; MsgBox(Msg,mbError,MB_OK); Log(Msg); -- 2.11.4.GIT