Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FarRun. Helper for starting Far Manager as git's core.editor
- Loading branch information
Showing
8 changed files
with
283 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/_Arc | ||
/_Build | ||
/Debug | ||
*.pdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2013 | ||
VisualStudioVersion = 12.0.30723.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FarRun", "src/FarRun.vcxproj", "{E77FFB0F-B68F-41DA-8A5B-8BF8C37E11EA}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Win32 = Debug|Win32 | ||
Release|Win32 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{E77FFB0F-B68F-41DA-8A5B-8BF8C37E11EA}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
{E77FFB0F-B68F-41DA-8A5B-8BF8C37E11EA}.Debug|Win32.Build.0 = Debug|Win32 | ||
{E77FFB0F-B68F-41DA-8A5B-8BF8C37E11EA}.Release|Win32.ActiveCfg = Release|Win32 | ||
{E77FFB0F-B68F-41DA-8A5B-8BF8C37E11EA}.Release|Win32.Build.0 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Useful for running Far as git editor. | ||
|
||
It's unfriendly to run something long from command line (and from git's core.editor). | ||
For example, my Far Manager instance is started like this: | ||
|
||
%ConEmuDrive%\Far30.Latest\far-bis\Far.exe /w /x /p%ConEmuDrive%\Far3\Plugins\ConEmu;%ConEmuDrive%\Far30.Latest\far-bis\Plugins;%ConEmuDrive%\Far30.Latest\Plugins;%ConEmuDrive%\Far30.Latest\Plugins.My | ||
|
||
So, now the life will be easier. | ||
1) Just copy FarRun.exe to any folder in %PATH%. | ||
2) Create text file FarRun.ini with following | ||
|
||
[Run] | ||
Cmd=%ConEmuDrive%\Far30.Latest\far-bis\Far.exe /w /x /p%ConEmuDrive%\Far3\Plugins\ConEmu;%ConEmuDrive%\Far30.Latest\far-bis\Plugins;%ConEmuDrive%\Far30.Latest\Plugins;%ConEmuDrive%\Far30.Latest\Plugins.My | ||
|
||
3) Update your core.editor | ||
|
||
git config core.editor "farrun -e1:1" | ||
|
||
4) Enjoy the power and flexibility :P |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[Run] | ||
;Cmd=%ConEmuDrive%\Far30.Latest\far-bis\Far.exe /w /x /p%ConEmuDrive%\Far3\Plugins\ConEmu;%ConEmuDrive%\Far30.Latest\far-bis\Plugins;%ConEmuDrive%\Far30.Latest\Plugins;%ConEmuDrive%\Far30.Latest\Plugins.My | ||
Cmd=%FARHOME%\Far.exe /w |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
|
||
/* | ||
Copyright (c) 2014 Maximus5 | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
3. The name of the authors may not be used to endorse or promote products | ||
derived from this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR | ||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#define _CRT_SECURE_NO_WARNINGS | ||
|
||
#include <Windows.h> | ||
#include <tchar.h> | ||
#include <stdio.h> | ||
|
||
int _tmain(int argc, _TCHAR* argv[]) | ||
{ | ||
#ifdef _DEBUG | ||
SetEnvironmentVariable(_T("ConEmuDrive"), _T("T:")); | ||
#endif | ||
|
||
TCHAR szIniFile[MAX_PATH] = _T(""); | ||
GetModuleFileName(NULL, szIniFile, ARRAYSIZE(szIniFile)); | ||
TCHAR* pszDot = _tcsrchr(szIniFile, _T('.')); | ||
if (!pszDot) | ||
{ | ||
printf("GetModuleFileName failed, no extension\n"); | ||
return 100; | ||
} | ||
_tcscpy(pszDot, _T(".ini")); | ||
|
||
TCHAR szIniCmd[0x800] = _T(""); | ||
GetPrivateProfileString(_T("Run"), _T("Cmd"), _T(""), szIniCmd, ARRAYSIZE(szIniCmd), szIniFile); | ||
|
||
if (!*szIniCmd) | ||
{ | ||
_tprintf(_T("Invalid initialization file:\n%s\nRequired: [Run] Cmd = ...\n"), szIniFile); | ||
return 101; | ||
} | ||
|
||
size_t cchAddLen = 0; | ||
for (int i = 1; i < argc; i++) | ||
{ | ||
cchAddLen += _tcslen(argv[i]) + 3; // Space + two quotes | ||
} | ||
|
||
size_t cchMax = 0; | ||
TCHAR* pszExpand = NULL; | ||
if (_tcschr(szIniCmd, _T('%'))) | ||
{ | ||
DWORD nSize = ExpandEnvironmentStrings(szIniCmd, NULL, 0); | ||
if (nSize) | ||
{ | ||
cchMax = max(_tcslen(szIniCmd),nSize) + 1 + cchAddLen; | ||
pszExpand = (TCHAR*)calloc(cchMax, sizeof(*pszExpand)); | ||
DWORD nExp = ExpandEnvironmentStrings(szIniCmd, pszExpand, nSize+1); | ||
if (!nExp || nExp > nSize) | ||
{ | ||
*pszExpand = 0; | ||
} | ||
} | ||
} | ||
|
||
if (!pszExpand) | ||
{ | ||
cchMax = _tcslen(szIniCmd) + 1 + cchAddLen; | ||
pszExpand = (TCHAR*)calloc(cchMax, sizeof(*pszExpand)); | ||
} | ||
|
||
if (!*pszExpand) | ||
{ | ||
_tcscpy(pszExpand, szIniCmd); | ||
} | ||
|
||
for (int i = 1; i < argc; i++) | ||
{ | ||
bool bQuot = (_tcschr(argv[i], _T(' ')) != NULL); | ||
_tcscat(pszExpand, bQuot ? _T(" \"") : _T(" ")); | ||
_tcscat(pszExpand, argv[i]); | ||
if (bQuot) _tcscat(pszExpand, _T("\"")); | ||
} | ||
|
||
STARTUPINFO si = {sizeof(si)}; | ||
PROCESS_INFORMATION pi = {}; | ||
|
||
if (!CreateProcess(NULL, pszExpand, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) | ||
{ | ||
DWORD nErr = GetLastError(); | ||
_tprintf(_T("Failed to run process, command:\n%s\nError code=%u\n"), pszExpand, nErr); | ||
return 102; | ||
} | ||
|
||
WaitForSingleObject(pi.hProcess, INFINITE); | ||
DWORD nRc = 200; | ||
GetExitCodeProcess(pi.hProcess, &nRc); | ||
|
||
return nRc; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|Win32"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|Win32"> | ||
<Configuration>Release</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>{E77FFB0F-B68F-41DA-8A5B-8BF8C37E11EA}</ProjectGuid> | ||
<Keyword>Win32Proj</Keyword> | ||
<RootNamespace>FarRun</RootNamespace> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v120_xp</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v120_xp</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<LinkIncremental>true</LinkIncremental> | ||
<OutDir>$(SolutionDir)Debug\</OutDir> | ||
<IntDir>$(SolutionDir)_Build\$(Configuration).$(Platform)\</IntDir> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<LinkIncremental>false</LinkIncremental> | ||
<OutDir>$(SolutionDir)Release\</OutDir> | ||
<IntDir>$(SolutionDir)_Build\$(Configuration).$(Platform)\</IntDir> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<ClCompile> | ||
<PrecompiledHeader> | ||
</PrecompiledHeader> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>Disabled</Optimization> | ||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<PrecompiledHeader> | ||
</PrecompiledHeader> | ||
<Optimization>MaxSpeed</Optimization> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClCompile Include="FarRun.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Text Include="..\ReadMe.txt" /> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="Source Files"> | ||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
<Filter Include="Header Files"> | ||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> | ||
</Filter> | ||
<Filter Include="Resource Files"> | ||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | ||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | ||
</Filter> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="FarRun.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Text Include="..\ReadMe.txt" /> | ||
</ItemGroup> | ||
</Project> |