mirror of
https://github.com/cmderdev/cmder.git
synced 2025-02-22 21:30:23 +08:00
Merge branch 'master' into dev
Conflicts: vendor/init.bat
This commit is contained in:
commit
5cc318a461
@ -8,7 +8,7 @@ Cmder is a **software package** created out of pure frustration over absence of
|
||||
|
||||
## Why use it
|
||||
|
||||
The main advantage of Cmder is portability. It is designed to be totally self-contained with no external dependencies. That makes is great for **USB Sticks** or **Dropbox**. So you can carry your console, aliases and binaries (like wget, curl and git) with you anywhere.
|
||||
The main advantage of Cmder is portability. It is designed to be totally self-contained with no external dependencies. That makes it great for **USB Sticks** or **Dropbox**. So you can carry your console, aliases and binaries (like wget, curl and git) with you anywhere.
|
||||
|
||||
## Installation
|
||||
|
||||
@ -25,13 +25,14 @@ The main advantage of Cmder is portability. It is designed to be totally self-co
|
||||
|
||||
* `Ctrl + t` : new tab dialog (maybe you want to open cmd as admin?)
|
||||
* `Ctrl + w` : close tab
|
||||
* `Ctrl + d` : close tab (if pressed on empty command)
|
||||
* `Ctrl + alt + number` : fast new tab: `1` - CMD, `2` - Powershell `*` - More to come
|
||||
* `Alt + enter`: Fullscreen
|
||||
|
||||
### Shell
|
||||
|
||||
* `Shift + Up` : Traverse up in directory structure (lovely feature!)
|
||||
* `End, Home, ctrl` : Traversing text with as usual on Windows
|
||||
* `End, Home, Ctrl` : Traversing text with as usual on Windows
|
||||
* `Ctrl + r` : History search
|
||||
* `Shift + mouse` : Select and copy text from buffer
|
||||
|
||||
|
@ -13,8 +13,8 @@ if not ["%_temp%"] == ["%_temp2%"] (
|
||||
goto:eof
|
||||
)
|
||||
|
||||
echo %* >> %~dp0..\config\aliases
|
||||
doskey /macrofile=%~dp0..\config\aliases
|
||||
echo %* >> "%CMDER_ROOT%\config\aliases"
|
||||
doskey /macrofile="%CMDER_ROOT%\config\aliases"
|
||||
echo Alias created
|
||||
endlocal
|
||||
goto:eof
|
||||
|
@ -74,6 +74,14 @@ unless find_on_path('7z.exe')
|
||||
exit(1)
|
||||
end
|
||||
|
||||
build_exe = true
|
||||
unless find_on_path('msbuild.exe')
|
||||
puts 'msbuild.exe not found. We need that to build the executable.'
|
||||
puts 'Do you want to continue? [Y/n]'
|
||||
build_exe = false
|
||||
exit(1) unless gets.chomp.downcase == 'y'
|
||||
end
|
||||
|
||||
puts 'Cleanup'
|
||||
|
||||
if Dir.exists?('vendor')
|
||||
@ -84,8 +92,19 @@ Dir.chdir('vendor')
|
||||
|
||||
puts 'Getting files'
|
||||
|
||||
get_file('clink', 'label:Type-Archive label=Featured')
|
||||
get_file('conemu-maximus5', 'label:Type-Archive label=Preview label=Featured')
|
||||
get_file('clink', 'label:Type-Archive label:Featured')
|
||||
get_file('conemu-maximus5', 'label:Type-Archive label:Preview label:Featured')
|
||||
get_file('msysgit', 'label:Type-Archive label:Featured')
|
||||
|
||||
puts 'Creating executable'
|
||||
|
||||
if build_exe
|
||||
Dir.chdir('../launcher')
|
||||
status = system('msbuild /p:Configuration=Release')
|
||||
unless status
|
||||
puts 'Looks like the build failied'
|
||||
exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
puts 'Done, bye'
|
@ -77,7 +77,7 @@
|
||||
<value name="StartFarEditors" type="hex" data="00"/>
|
||||
<value name="StoreTaskbarkTasks" type="hex" data="00"/>
|
||||
<value name="StoreTaskbarCommands" type="hex" data="00"/>
|
||||
<value name="CmdLineHistory" type="multi"><line data=";C:\Users\bliker\Desktop\cmder\lib\ConEmu;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\"/></value>
|
||||
<value name="CmdLineHistory" type="multi"><line data=";C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\"/></value>
|
||||
<value name="SingleInstance" type="hex" data="00"/>
|
||||
<value name="ShowHelpTooltips" type="hex" data="01"/>
|
||||
<value name="Multi" type="hex" data="01"/>
|
||||
|
5
config/prompt.lua
Normal file
5
config/prompt.lua
Normal file
@ -0,0 +1,5 @@
|
||||
function lambda_prompt_filter()
|
||||
clink.prompt.value = string.gsub(clink.prompt.value, "{lamb}", "λ")
|
||||
end
|
||||
|
||||
clink.prompt.register_filter(lambda_prompt_filter, 40)
|
181
launcher/.gitignore
vendored
Normal file
181
launcher/.gitignore
vendored
Normal file
@ -0,0 +1,181 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
*.filters
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
x64/
|
||||
build/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
|
||||
!packages/*/build/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
#NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding addin-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
*.ncrunch*
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.Publish.xml
|
||||
*.azurePubxml
|
||||
|
||||
# NuGet Packages Directory
|
||||
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
|
||||
#packages/
|
||||
## TODO: If the tool you use requires repositories.config, also uncomment the next line
|
||||
#!packages/repositories.config
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.[Pp]ublish.xml
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file to a newer
|
||||
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
App_Data/*.mdf
|
||||
App_Data/*.ldf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# =========================
|
||||
# Windows detritus
|
||||
# =========================
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
22
launcher/CmderLauncher.sln
Normal file
22
launcher/CmderLauncher.sln
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.21005.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CmderLauncher", "CmderLauncher.vcxproj", "{4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
98
launcher/CmderLauncher.vcxproj
Normal file
98
launcher/CmderLauncher.vcxproj
Normal file
@ -0,0 +1,98 @@
|
||||
<?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>{4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>CmderLauncher</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</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</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>
|
||||
<TargetName>Cmder</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>Cmder</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy $(TargetPath) $(SolutionDir)..\$(TargetFileName)</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="src\Resource.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\CmderLauncher.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
231
launcher/src/CmderLauncher.cpp
Normal file
231
launcher/src/CmderLauncher.cpp
Normal file
@ -0,0 +1,231 @@
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <Shlwapi.h>
|
||||
#include "resource.h"
|
||||
#include <vector>
|
||||
|
||||
#pragma comment(lib, "Shlwapi.lib")
|
||||
|
||||
#ifndef UNICODE
|
||||
#error "Must be compiled with unicode support."
|
||||
#endif
|
||||
|
||||
#define USE_TASKBAR_API (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
|
||||
|
||||
#define MB_TITLE L"Cmder Launcher"
|
||||
#define SHELL_MENU_REGISTRY_PATH L"Directory\\Background\\shell\\Cmder"
|
||||
|
||||
#define streqi(a, b) (_wcsicmp((a), (b)) == 0)
|
||||
|
||||
#define WIDEN2(x) L ## x
|
||||
#define WIDEN(x) WIDEN2(x)
|
||||
#define __WFUNCTION__ WIDEN(__FUNCTION__)
|
||||
|
||||
#define FAIL_ON_ERROR(x) { DWORD ec; if ((ec = (x)) != ERROR_SUCCESS) { ShowErrorAndExit(ec, __WFUNCTION__, __LINE__); } }
|
||||
|
||||
void ShowErrorAndExit(DWORD ec, const wchar_t * func, int line)
|
||||
{
|
||||
wchar_t * buffer;
|
||||
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, ec, 0, (LPWSTR) &buffer, 0, NULL) == 0)
|
||||
{
|
||||
buffer = L"Unknown error. FormatMessage failed.";
|
||||
}
|
||||
|
||||
wchar_t message[1024];
|
||||
swprintf_s(message, L"%s\nFunction: %s\nLine: %d", buffer, func, line);
|
||||
LocalFree(buffer);
|
||||
|
||||
MessageBox(NULL, message, MB_TITLE, MB_OK | MB_ICONERROR);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
typedef struct _option
|
||||
{
|
||||
std::wstring name;
|
||||
bool hasVal;
|
||||
std::wstring value;
|
||||
bool set;
|
||||
} option;
|
||||
|
||||
typedef std::pair<std::wstring, std::wstring> optpair;
|
||||
|
||||
|
||||
optpair GetOption()
|
||||
{
|
||||
wchar_t * cmd = GetCommandLine();
|
||||
int argc;
|
||||
wchar_t ** argv = CommandLineToArgvW(cmd, &argc);
|
||||
optpair pair;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
pair = optpair(L"/START", L"");
|
||||
}
|
||||
else if (argc == 2 && argv[1][0] != L'/')
|
||||
{
|
||||
pair = optpair(L"/START", argv[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
pair = optpair(argv[1], argc > 2 ? argv[2] : L"");
|
||||
}
|
||||
|
||||
LocalFree(argv);
|
||||
|
||||
return pair;
|
||||
}
|
||||
|
||||
void StartCmder(std::wstring path)
|
||||
{
|
||||
#if USE_TASKBAR_API
|
||||
wchar_t appId[MAX_PATH] = { 0 };
|
||||
#endif
|
||||
wchar_t exeDir[MAX_PATH] = { 0 };
|
||||
wchar_t icoPath[MAX_PATH] = { 0 };
|
||||
wchar_t cfgPath[MAX_PATH] = { 0 };
|
||||
wchar_t conEmuPath[MAX_PATH] = { 0 };
|
||||
wchar_t args[MAX_PATH * 2 + 256] = { 0 };
|
||||
|
||||
GetModuleFileName(NULL, exeDir, sizeof(exeDir));
|
||||
|
||||
#if USE_TASKBAR_API
|
||||
wcscpy_s(appId, exeDir);
|
||||
#endif
|
||||
|
||||
PathRemoveFileSpec(exeDir);
|
||||
|
||||
PathCombine(icoPath, exeDir, L"icons\\cmder.ico");
|
||||
PathCombine(cfgPath, exeDir, L"config\\ConEmu.xml");
|
||||
PathCombine(conEmuPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.exe");
|
||||
|
||||
swprintf_s(args, L"/Icon \"%s\" /Title Cmder /LoadCfgFile \"%s\"", icoPath, cfgPath);
|
||||
|
||||
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
|
||||
SetEnvironmentVariable(L"CMDER_START", path.c_str());
|
||||
|
||||
STARTUPINFO si = { 0 };
|
||||
si.cb = sizeof(STARTUPINFO);
|
||||
#if USE_TASKBAR_API
|
||||
si.lpTitle = appId;
|
||||
si.dwFlags = STARTF_TITLEISAPPID;
|
||||
#endif
|
||||
|
||||
PROCESS_INFORMATION pi;
|
||||
|
||||
CreateProcess(conEmuPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi);
|
||||
}
|
||||
|
||||
bool IsUserOnly(std::wstring opt)
|
||||
{
|
||||
bool userOnly;
|
||||
|
||||
if (streqi(opt.c_str(), L"ALL"))
|
||||
{
|
||||
userOnly = false;
|
||||
}
|
||||
else if (streqi(opt.c_str(), L"USER"))
|
||||
{
|
||||
userOnly = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox(NULL, L"Unrecognized option for /REGISTER or /UNREGISTER. Must be either ALL or USER.", MB_TITLE, MB_OK);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return userOnly;
|
||||
}
|
||||
|
||||
HKEY GetRootKey(std::wstring opt)
|
||||
{
|
||||
HKEY root;
|
||||
|
||||
if (IsUserOnly(opt))
|
||||
{
|
||||
FAIL_ON_ERROR(RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\Classes", 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &root, NULL));
|
||||
}
|
||||
else
|
||||
{
|
||||
root = HKEY_CLASSES_ROOT;
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
void RegisterShellMenu(std::wstring opt)
|
||||
{
|
||||
HKEY root = GetRootKey(opt);
|
||||
|
||||
HKEY cmderKey;
|
||||
FAIL_ON_ERROR(
|
||||
RegCreateKeyEx(root, SHELL_MENU_REGISTRY_PATH, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &cmderKey, NULL));
|
||||
|
||||
FAIL_ON_ERROR(RegSetValue(cmderKey, L"", REG_SZ, L"Cmder Here", NULL));
|
||||
FAIL_ON_ERROR(RegSetValueEx(cmderKey, L"NoWorkingDirectory", 0, REG_SZ, (BYTE *)L"", 2));
|
||||
|
||||
HKEY command;
|
||||
FAIL_ON_ERROR(
|
||||
RegCreateKeyEx(cmderKey, L"command", 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &command, NULL));
|
||||
|
||||
wchar_t exePath[MAX_PATH] = { 0 };
|
||||
|
||||
GetModuleFileName(NULL, exePath, sizeof(exePath));
|
||||
|
||||
wchar_t commandStr[MAX_PATH + 20] = { 0 };
|
||||
swprintf_s(commandStr, L"\"%s\" \"%%V\"", exePath);
|
||||
|
||||
FAIL_ON_ERROR(RegSetValue(command, L"", REG_SZ, commandStr, NULL));
|
||||
|
||||
RegCloseKey(command);
|
||||
RegCloseKey(cmderKey);
|
||||
RegCloseKey(root);
|
||||
}
|
||||
|
||||
void UnregisterShellMenu(std::wstring opt)
|
||||
{
|
||||
HKEY root = GetRootKey(opt);
|
||||
HKEY cmderKey;
|
||||
FAIL_ON_ERROR(
|
||||
RegCreateKeyEx(root, SHELL_MENU_REGISTRY_PATH, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &cmderKey, NULL));
|
||||
FAIL_ON_ERROR(RegDeleteTree(cmderKey, NULL));
|
||||
FAIL_ON_ERROR(RegDeleteKey(root, SHELL_MENU_REGISTRY_PATH));
|
||||
RegCloseKey(cmderKey);
|
||||
RegCloseKey(root);
|
||||
}
|
||||
|
||||
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPTSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
UNREFERENCED_PARAMETER(nCmdShow);
|
||||
|
||||
optpair opt = GetOption();
|
||||
|
||||
if (streqi(opt.first.c_str(), L"/START"))
|
||||
{
|
||||
StartCmder(opt.second);
|
||||
}
|
||||
else if (streqi(opt.first.c_str(), L"/REGISTER"))
|
||||
{
|
||||
RegisterShellMenu(opt.second);
|
||||
}
|
||||
else if (streqi(opt.first.c_str(), L"/UNREGISTER"))
|
||||
{
|
||||
UnregisterShellMenu(opt.second);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n /START <path>\n /REGISTER [USER/ALL]\n /UNREGISTER [USER/ALL]", MB_TITLE, MB_OK);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
launcher/src/Resource.rc
Normal file
BIN
launcher/src/Resource.rc
Normal file
Binary file not shown.
BIN
launcher/src/resource.h
Normal file
BIN
launcher/src/resource.h
Normal file
Binary file not shown.
28
vendor/init.bat
vendored
28
vendor/init.bat
vendored
@ -2,16 +2,9 @@
|
||||
:: Sets some nice defaults
|
||||
:: Created as part of cmder project
|
||||
|
||||
|
||||
:: Setting prompt style
|
||||
@for /f "tokens=2 delims=:." %%x in ('chcp') do @set cp=%%x
|
||||
:: The slow part
|
||||
:: World without Unicode is a sad world
|
||||
@chcp 65001>nul
|
||||
:: It has to be lambda, I already made a logo
|
||||
@prompt $E[1;32;40m$P$S{git}$S$_$E[1;30;40mλ$S$E[0m
|
||||
@chcp %cp%>nul
|
||||
|
||||
:: Change the prompt style
|
||||
:: Mmm tasty lamb
|
||||
@prompt $E[1;32;40m$P$S{git}$S$_$E[1;30;40m{lamb}$S$E[0m
|
||||
|
||||
:: Pick right version of clink
|
||||
@if "%PROCESSOR_ARCHITECTURE%"=="x86" (
|
||||
@ -20,24 +13,23 @@
|
||||
set architecture=64
|
||||
)
|
||||
|
||||
@set rootDir="%~dp0\.."
|
||||
|
||||
:: Run clink
|
||||
@%rootDir%\vendor\clink\clink_x%architecture%.exe inject --quiet --profile %rootDir%\config
|
||||
@"%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_ROOT%\config"
|
||||
|
||||
:: Prepare for msysgit
|
||||
|
||||
:: I do not even know, copypasted from their .bat
|
||||
@set PLINK_PROTOCOL=ssh
|
||||
@if not defined TERM set TERM=msys
|
||||
@if not defined TERM set TERM=cygwin
|
||||
|
||||
:: Enhance Path
|
||||
@set git_install_root=%rootDir%\vendor\msysgit
|
||||
@set PATH=%PATH%;%rootDir%\bin;%git_install_root%\bin;%git_install_root%\mingw\bin;%git_install_root%\cmd;%git_install_root%\share\vim\vim73;
|
||||
@set git_install_root=%CMDER_ROOT%\vendor\msysgit
|
||||
@set PATH=%PATH%;%CMDER_ROOT%\bin;%git_install_root%\bin;%git_install_root%\mingw\bin;%git_install_root%\cmd;%git_install_root%\share\vim\vim73;
|
||||
|
||||
:: Add aliases
|
||||
@doskey /macrofile=%rootDir%\config\aliases
|
||||
@doskey /macrofile=%CMDER_ROOT%\config\aliases
|
||||
|
||||
:: Set home path
|
||||
@set HOME=%USERPROFILE%
|
||||
@echo Welcome to cmder!
|
||||
|
||||
@if defined CMDER_START cd /d "%CMDER_START%"
|
||||
|
Loading…
x
Reference in New Issue
Block a user