mirror of
https://github.com/cmderdev/cmder.git
synced 2025-07-17 04:59:09 +08:00
Compare commits
62 Commits
Author | SHA1 | Date | |
---|---|---|---|
a95cd140ef | |||
e90966c5c2 | |||
e104f20c5d | |||
6883ba3b84 | |||
1c1c08bb68 | |||
a5eb4d7b4f | |||
d88f1b0a97 | |||
8d74184d30 | |||
3ea6d51ba4 | |||
22d27afed5 | |||
e9a78a30d1 | |||
e92f7fbb55 | |||
a34e17f2bd | |||
1f9e743ef2 | |||
f687281be0 | |||
4c270699a1 | |||
b45e3adc67 | |||
8077c1a612 | |||
d9fcf06e0f | |||
815b99b98b | |||
bcb60f8f59 | |||
0877a6d995 | |||
71f5b446da | |||
512787f391 | |||
262d92265e | |||
409b92aac2 | |||
aea1a977bf | |||
74d79ea628 | |||
89c014bb05 | |||
c19237085d | |||
9c4e77b498 | |||
c2cf56cc48 | |||
6e2d88d466 | |||
cd3efdf382 | |||
53c7ec5886 | |||
e63368fe96 | |||
aa2eaa6886 | |||
bee82d00e8 | |||
02366fdc7e | |||
399999d7f7 | |||
8eea2baaa5 | |||
4d3950174f | |||
24a110ddb7 | |||
1dd0e600ac | |||
e49b978b9a | |||
9182c89a14 | |||
00622254a7 | |||
9977c0563d | |||
b604bf0b6c | |||
3b0a51d7b8 | |||
018cc9ceda | |||
ad0f8fe049 | |||
7f4a4d34d6 | |||
963a5a8be6 | |||
f04a4e4846 | |||
50ed66894f | |||
2bb5ce0986 | |||
3b7a24b20a | |||
81d83d4c6d | |||
61849dc7fd | |||
9f2c0e4001 | |||
4195b5b0ed |
1
.gitignore
vendored
1
.gitignore
vendored
@ -16,3 +16,4 @@ config/user-*
|
||||
config/aliases
|
||||
config/profile.d
|
||||
.github_changelog_generator
|
||||
launcher/.vs
|
||||
|
38
README.md
38
README.md
@ -1,6 +1,6 @@
|
||||
# Cmder
|
||||
|
||||
[](https://gitter.im/cmderdev/cmder?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://ci.appveyor.com/project/MartiUK/cmder)
|
||||
[](https://gitter.im/cmderdev/cmder?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://ci.appveyor.com/project/MartiUK/cmder)
|
||||
|
||||
Cmder is a **software package** created out of pure frustration over absence of usable console emulator on Windows. It is based on [ConEmu](https://conemu.github.io/) with *major* config overhaul, comes with a Monokai color scheme, amazing [clink](https://github.com/mridgers/clink) (further enhanced by [clink-completions](https://github.com/vladimir-kotikov/clink-completions)) and a custom prompt layout.
|
||||
|
||||
@ -14,7 +14,7 @@ The main advantage of Cmder is portability. It is designed to be totally self-co
|
||||
|
||||
1. Download the [latest release](https://github.com/cmderdev/cmder/releases/)
|
||||
2. Extract the archive
|
||||
3. (optional) Place your own executable files into the `bin` folder to be injected into your PATH
|
||||
3. (optional) Place your own executable files into the `bin` folder to be injected into your PATH. (nb: This path should not be `C:\Program Files` or anywhere else that would require Administrator access for modifying configuration files)
|
||||
4. Run Cmder.exe
|
||||
|
||||
## Integration
|
||||
@ -38,6 +38,9 @@ In a file explorer window right click in or on a directory to see "Cmder Here" i
|
||||
* <kbd>Ctrl</kbd> + <kbd>W</kbd> : Close tab
|
||||
* <kbd>Ctrl</kbd> + <kbd>D</kbd> : Close tab (if pressed on empty command)
|
||||
* <kbd>Shift</kbd> + <kbd>Alt</kbd> + <kbd>#Number</kbd> : Fast new tab: <kbd>1</kbd> - CMD, <kbd>2</kbd> - PowerShell
|
||||
* <kbd>Ctrl</kbd> + <kbd>Tab</kbd> : Switch to next tab
|
||||
* <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Tab</kbd> : Switch to previous tab
|
||||
* <kbd>Ctrl</kbd> + <kbd>#Number</kbd> : Switch to tab #Number
|
||||
* <kbd>Alt</kbd> + <kbd>Enter</kbd>: Fullscreen
|
||||
|
||||
### Shell
|
||||
@ -109,16 +112,39 @@ You can define simple aliases for `cmd.exe` sessions with a command like `alias
|
||||
|
||||
Cmd.exe aliases can also be more complex. See: [DOSKEY.EXE documentation](http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/doskey.mspx?mfr=true) for additional details on complex aliases/macros for 'cmd.exe'
|
||||
|
||||
Aliases defined using the `alias.bat` command will automatically be saved in the `%CMDER_ROOT%\config\aliases` file
|
||||
Aliases defined using the `alias.bat` command will automatically be saved in the `%CMDER_ROOT%\config\user-aliases.cmd` file
|
||||
|
||||
To make an alias and/or any other profile settings permanent add it to one of the following:
|
||||
|
||||
Note: These are loaded in this order by '$CMDER_ROOT/vendor/init.bat'. Anyhing stored in '%CMDER_ROOT%' will be a portable setting and will follow cmder to another machine.
|
||||
|
||||
* '%CMDER_ROOT%\\config\\profile.d\\\*.cmd and \*.bat'
|
||||
* '%CMDER_ROOT%\\config\\user-aliases.cmd'
|
||||
* '%CMDER_ROOT%\\config\\user-profile.cmd'
|
||||
|
||||
#### Bash.exe|Mintty.exe Aliases
|
||||
Bash shells support simple and complex aliases with optional parameters natively so they work a little different. Typing `alias name=command` will create an alias only for the current running session. To make an alias permanent add it to either your `$CMDER_ROOT/config/user-profile.sh` or your `$HOME/.bashrc`.
|
||||
Bash shells support simple and complex aliases with optional parameters natively so they work a little different. Typing `alias name=command` will create an alias only for the current running session.
|
||||
|
||||
To make an alias and/or any other profile settings permanent add it to one of the following:
|
||||
|
||||
Note: These are loaded in this order by '$CMDER_ROOT/vendor/git-for-windows/etc/profile.d/cmder.sh'. Anyhing stored in '$CMDER_ROOT' will be a portable setting and will follow cmder to another machine.
|
||||
|
||||
* '$CMDER_ROOT/config/profile.d/*.sh'
|
||||
* '$CMDER_ROOT/config/user-profile.sh'
|
||||
* '$HOME/.bashrc'
|
||||
|
||||
If you add bash aliases to `$CMDER_ROOT/config/user-profile.sh` they will be portable and follow your Cmder folder if you copy it to another machine. `$HOME/.bashrc` defined aliases are not portable.
|
||||
|
||||
#### PowerShell.exe Aliases
|
||||
PowerShell has native simple alias support, for example `[new-alias | set-alias] alias command`, so complex aliases with optional parameters are not supported in PowerShell sessions. Type `get-help [new-alias|set-alias] -full` for help on PowerShell aliases.
|
||||
|
||||
To make an alias and/or any other profile settings permanent add it to one of the following:
|
||||
|
||||
Note: These are loaded in this order by '$ENV:CMDER_ROOT\\vendor\\user-profile.ps1'. Anyhing stored in '$ENV:CMDER_ROOT' will be a portable setting and will follow cmder to another machine.
|
||||
|
||||
* '$ENV:CMDER_ROOT\\config\\profile.d\\\*.ps1'
|
||||
* '$ENV:CMDER_ROOT\\config\\user-profile.ps1'
|
||||
|
||||
### SSH Agent
|
||||
|
||||
To start SSH agent simply call `start-ssh-agent`, which is in the `vendor/git-for-windows/cmd` folder.
|
||||
@ -150,11 +176,11 @@ Uncomment and edit the below line in the script to use Cmder config even when la
|
||||
# CMDER_ROOT=${USERPROFILE}/cmder # This is not required if launched from Cmder.
|
||||
```
|
||||
|
||||
## Current development branch
|
||||
## Current development builds
|
||||
|
||||
You can download builds of the current development branch by going to AppVeyor via the following link:
|
||||
|
||||
[](https://ci.appveyor.com/project/MartiUK/cmder/branch/development/artifacts)
|
||||
[](https://ci.appveyor.com/project/MartiUK/cmder/branch/master/artifacts)
|
||||
|
||||
## License
|
||||
|
||||
|
@ -15,7 +15,7 @@ branches:
|
||||
#---------------------------------#
|
||||
|
||||
# Operating system (build VM template)
|
||||
os: Windows Server 2012 R2
|
||||
os: Visual Studio 2017
|
||||
|
||||
#---------------------------------#
|
||||
# build configuration #
|
||||
|
@ -64,7 +64,7 @@ if "%aliases%" neq "%CMDER_ROOT%\config\user-aliases.cmd" (
|
||||
)
|
||||
|
||||
:: validate alias
|
||||
for /f "delims== tokens=1,2 usebackq" %%G in (`echo "%_x%"`) do (
|
||||
for /f "delims== tokens=1,* usebackq" %%G in (`echo "%_x%"`) do (
|
||||
set alias_name=%%G
|
||||
set alias_value=%%H
|
||||
)
|
||||
@ -96,7 +96,7 @@ set del_alias=%~1
|
||||
findstr /b /v /i "%del_alias%=" "%ALIASES%" >> "%ALIASES%.tmp"
|
||||
type "%ALIASES%".tmp > "%ALIASES%" & @del /f /q "%ALIASES%.tmp"
|
||||
doskey %del_alias%=
|
||||
doskey /macrofile=%ALIASES%
|
||||
doskey /macrofile="%ALIASES%"
|
||||
goto:eof
|
||||
|
||||
:p_reload
|
||||
|
@ -153,7 +153,7 @@
|
||||
<value name="ComSpec.UpdateEnv" type="hex" data="00"/>
|
||||
<value name="ComSpec.EnvAddPath" type="hex" data="01"/>
|
||||
<value name="ComSpec.EnvAddExePath" type="hex" data="01"/>
|
||||
<value name="ComSpec.UncPaths" type="hex" data="00"/>
|
||||
<value name="ComSpec.UncPaths" type="hex" data="01"/>
|
||||
<value name="ComSpec.Path" type="string" data=""/>
|
||||
<value name="ConsoleTextSelection" type="hex" data="01"/>
|
||||
<value name="CTS.AutoCopy" type="hex" data="01"/>
|
||||
@ -548,14 +548,14 @@
|
||||
<value name="GuiArgs" type="string" data=" /icon "%CMDER_ROOT%\icons\cmder.ico""/>
|
||||
<value name="Active" type="dword" data="00000000"/>
|
||||
<value name="Count" type="dword" data="00000001"/>
|
||||
<value name="Cmd1" type="string" data="*cmd /c "%ConEmuDir%\..\git-for-windows\bin\bash --login -i" -new_console:d:%USERPROFILE%"/>
|
||||
<value name="Cmd1" type="string" data="*cmd /c "%ConEmuDir%\..\git-for-windows\bin\bash" --login -i -new_console:d:%USERPROFILE%"/>
|
||||
</key>
|
||||
<key name="Task8" modified="2015-11-24 14:49:10" build="151119">
|
||||
<value name="Name" type="string" data="{bash::bash}"/>
|
||||
<value name="Flags" type="dword" data="00000000"/>
|
||||
<value name="Hotkey" type="dword" data="00000000"/>
|
||||
<value name="GuiArgs" type="string" data=" /icon "%CMDER_ROOT%\icons\cmder.ico""/>
|
||||
<value name="Cmd1" type="string" data="cmd /c "%ConEmuDir%\..\git-for-windows\bin\bash --login -i" -new_console:d:%USERPROFILE%"/>
|
||||
<value name="Cmd1" type="string" data="cmd /c "%ConEmuDir%\..\git-for-windows\bin\bash" --login -i -new_console:d:%USERPROFILE%"/>
|
||||
<value name="Active" type="dword" data="00000000"/>
|
||||
<value name="Count" type="dword" data="00000001"/>
|
||||
</key>
|
||||
|
@ -3,12 +3,12 @@
|
||||
All config files must be in this folder. If there is no option to set this folder
|
||||
directly, it has to be hardlinked.
|
||||
|
||||
* `aliases`: aliases in cmd; called form vendor\init.bat; autocreated from
|
||||
`vendor\aliases.example`.
|
||||
* `*.lua`: clink completions and prompt filters; called from vendor\cmder.lua after all
|
||||
other prompt filter and clink completions are initialized; add your own.
|
||||
* `user_profile.{sh|bat|ps1}`: startup files for bash|cmd|powershell tasks; called from their
|
||||
respective startup scripts in `vendor\`; autocreated on first start of such a task
|
||||
* `.history`: the current commandline history; autoupdated on close
|
||||
* `settings`: settings for readline; overwritten on update
|
||||
* `ConEmu.xml`: settings from ConEmu (=the UI of cmder -> Preferences); overwritten on update
|
||||
* `user-aliases.cmd`: aliases in cmd; called from vendor\init.bat; autocreated from
|
||||
`vendor\user-aliases.cmd.example`.
|
||||
* `*.lua`: clink completions and prompt filters; autoloaded after all
|
||||
prompt filter and clink completions are initialized; add your own.
|
||||
* `user-profile.{sh|cmd|ps1}`: startup files for bash|cmd|powershell tasks; called from their
|
||||
respective startup scripts in `vendor\`; autocreated on first start of such a task.
|
||||
* `.history`: the current commandline history; autoupdated on close.
|
||||
* `settings`: settings for readline; overwritten on update.
|
||||
* `ConEmu.xml`: settings from ConEmu (=the UI of cmder -> Preferences); overwritten on update.
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
@ -19,13 +19,13 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
|
@ -95,7 +95,7 @@ bool FileExists(const wchar_t * filePath)
|
||||
return false;
|
||||
}
|
||||
|
||||
void StartCmder(std::wstring path, bool is_single_mode)
|
||||
void StartCmder(std::wstring path, bool is_single_mode, std::wstring taskName = L"")
|
||||
{
|
||||
#if USE_TASKBAR_API
|
||||
wchar_t appId[MAX_PATH] = { 0 };
|
||||
@ -180,6 +180,10 @@ void StartCmder(std::wstring path, bool is_single_mode)
|
||||
swprintf_s(args, L"/Icon \"%s\" /Title Cmder", icoPath);
|
||||
}
|
||||
|
||||
if (!taskName.empty()) {
|
||||
swprintf_s(args, L"%s /run {%s}", args, taskName.c_str());
|
||||
}
|
||||
|
||||
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
|
||||
if (!streqi(path.c_str(), L""))
|
||||
{
|
||||
@ -323,6 +327,10 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
{
|
||||
StartCmder(opt.second, true);
|
||||
}
|
||||
else if (streqi(opt.first.c_str(), L"/TASK"))
|
||||
{
|
||||
StartCmder(L"", false, opt.second);
|
||||
}
|
||||
else if (streqi(opt.first.c_str(), L"/REGISTER"))
|
||||
{
|
||||
RegisterShellMenu(opt.second, SHELL_MENU_REGISTRY_PATH_BACKGROUND);
|
||||
@ -335,7 +343,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n /START <path>\n /SINGLE <path>\n /REGISTER [USER/ALL]\n /UNREGISTER [USER/ALL]", MB_TITLE, MB_OK);
|
||||
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n /START <path>\n /SINGLE <path>\n /TASK <name>\n /REGISTER [USER/ALL]\n /UNREGISTER [USER/ALL]", MB_TITLE, MB_OK);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -19,3 +19,4 @@ appveyor.yml
|
||||
vendor\cmder.sh
|
||||
vendor\git-prompt.sh
|
||||
config\user-*
|
||||
.github_changelog_generator
|
@ -53,6 +53,6 @@ $version = Invoke-Expression "git describe --abbrev=0 --tags"
|
||||
|
||||
foreach ($t in $targets.GetEnumerator()) {
|
||||
Create-Archive $cmderRoot "$saveTo\$($t.Name)" $t.Value
|
||||
$hash = (Digest-MD5 "$saveTo\$($t.Name)")
|
||||
Add-Content "$saveTo\hashes.txt" $hash
|
||||
$hash = (Digest-Hash "$saveTo\$($t.Name)")
|
||||
Add-Content -path "$saveTo\hashes.txt" -value ($t.Name + ' ' + $hash)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
function Ensure-Exists ($path) {
|
||||
function Ensure-Exists($path) {
|
||||
if (-not (Test-Path $path)) {
|
||||
Write-Error "Missing required $path! Ensure it is installed"
|
||||
exit 1
|
||||
@ -6,7 +6,7 @@ function Ensure-Exists ($path) {
|
||||
return $true > $null
|
||||
}
|
||||
|
||||
function Ensure-Executable ($command) {
|
||||
function Ensure-Executable($command) {
|
||||
try { Get-Command $command -ErrorAction Stop > $null }
|
||||
catch {
|
||||
If( ($command -eq "7z") -and (Test-Path "$env:programfiles\7-zip\7z.exe") ){
|
||||
@ -22,12 +22,12 @@ function Ensure-Executable ($command) {
|
||||
}
|
||||
}
|
||||
|
||||
function Delete-Existing ($path) {
|
||||
function Delete-Existing($path) {
|
||||
Write-Verbose "Remove $path"
|
||||
Remove-Item -Recurse -force $path -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
function Extract-Archive ($source, $target) {
|
||||
function Extract-Archive($source, $target) {
|
||||
Write-Verbose $("Extracting Archive '$cmder_root\vendor\" + $source.replace('/','\') + " to '$cmder_root\vendor\$target'")
|
||||
Invoke-Expression "7z x -y -o`"$($target)`" `"$source`" > `$null"
|
||||
if ($lastexitcode -ne 0) {
|
||||
@ -36,7 +36,7 @@ function Extract-Archive ($source, $target) {
|
||||
Remove-Item $source
|
||||
}
|
||||
|
||||
function Create-Archive ($source, $target, $params) {
|
||||
function Create-Archive($source, $target, $params) {
|
||||
$command = "7z a -x@`"$source\packignore`" $params $target $source > `$null"
|
||||
Write-Verbose "Running: $command"
|
||||
Invoke-Expression $command
|
||||
@ -47,22 +47,22 @@ function Create-Archive ($source, $target, $params) {
|
||||
|
||||
# If directory contains only one child directory
|
||||
# Flatten it instead
|
||||
function Flatten-Directory ($name) {
|
||||
function Flatten-Directory($name) {
|
||||
$child = (Get-Childitem $name)[0]
|
||||
Rename-Item $name -NewName "$($name)_moving"
|
||||
Move-Item -Path "$($name)_moving\$child" -Destination $name
|
||||
Remove-Item -Recurse "$($name)_moving"
|
||||
}
|
||||
|
||||
function Digest-MD5 ($path) {
|
||||
function Digest-Hash($path) {
|
||||
if(Get-Command Get-FileHash -ErrorAction SilentlyContinue){
|
||||
return (Get-FileHash -Algorithm MD5 -Path $path).Hash
|
||||
return (Get-FileHash -Algorithm SHA256 -Path $path).Hash
|
||||
}
|
||||
|
||||
return Invoke-Expression "md5sum $path"
|
||||
}
|
||||
|
||||
function Register-Cmder(){
|
||||
function Register-Cmder() {
|
||||
[CmdletBinding()]
|
||||
Param
|
||||
(
|
||||
@ -76,7 +76,7 @@ function Register-Cmder(){
|
||||
$Command = "%V"
|
||||
|
||||
, # Defaults to the icons folder in the cmder package.
|
||||
$icon = (Split-Path $PathToExe | join-path -ChildPath 'icons/cmder.ico')
|
||||
$icon = (Split-Path $PathToExe | Join-Path -ChildPath 'icons/cmder.ico')
|
||||
)
|
||||
Begin
|
||||
{
|
||||
@ -100,7 +100,7 @@ function Register-Cmder(){
|
||||
}
|
||||
}
|
||||
|
||||
function Unregister-Cmder{
|
||||
function Unregister-Cmder {
|
||||
Begin
|
||||
{
|
||||
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT > $null
|
||||
@ -124,9 +124,9 @@ function Download-File {
|
||||
# I think this is the problem
|
||||
$File = $File -Replace "/", "\"
|
||||
Write-Verbose "Downloading from $Url to $File"
|
||||
$wc = new-object System.Net.WebClient
|
||||
$wc = New-Object System.Net.WebClient
|
||||
if ($env:https_proxy) {
|
||||
$wc.proxy = (new-object System.Net.WebProxy($env:https_proxy))
|
||||
$wc.proxy = (New-Object System.Net.WebProxy($env:https_proxy))
|
||||
}
|
||||
$wc.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials;
|
||||
$wc.DownloadFile($Url, $File)
|
||||
|
52
vendor/clink.lua
vendored
52
vendor/clink.lua
vendored
@ -38,7 +38,7 @@ function set_prompt_filter()
|
||||
-- build our own prompt
|
||||
-- orig: $E[1;32;40m$P$S{git}{hg}$S$_$E[1;30;40m{lamb}$S$E[0m
|
||||
-- color codes: "\x1b[1;37;40m"
|
||||
local cmder_prompt = "\x1b[1;32;40m{cwd} {git}{hg} \n\x1b[1;30;40m{lamb} \x1b[0m"
|
||||
local cmder_prompt = "\x1b[1;32;40m{cwd} {git}{hg}{svn} \n\x1b[1;30;40m{lamb} \x1b[0m"
|
||||
cmder_prompt = string.gsub(cmder_prompt, "{cwd}", cwd)
|
||||
if env == nil then
|
||||
lambda = "λ"
|
||||
@ -103,6 +103,20 @@ local function get_hg_dir(path)
|
||||
return get_dir_contains(path, '.hg')
|
||||
end
|
||||
|
||||
local function get_svn_dir(path)
|
||||
return get_dir_contains(path, '.svn')
|
||||
end
|
||||
function get_svn_branch(svn_dir)
|
||||
for line in io.popen("svn info 2>nul"):lines() do
|
||||
local m = line:match("^Relative URL:")
|
||||
if m then
|
||||
return line:sub(line:find("/")+1,line:len())
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
-- adapted from from clink-completions' git.lua
|
||||
local function get_git_dir(path)
|
||||
|
||||
@ -118,7 +132,7 @@ local function get_git_dir(path)
|
||||
|
||||
-- Checks if provided directory contains git directory
|
||||
local function has_git_dir(dir)
|
||||
return #clink.find_dirs(dir..'/.git') > 0 and dir..'/.git'
|
||||
return clink.is_dir(dir..'/.git') and dir..'/.git'
|
||||
end
|
||||
|
||||
local function has_git_file(dir)
|
||||
@ -170,6 +184,13 @@ function get_hg_status()
|
||||
return true
|
||||
end
|
||||
|
||||
function get_svn_status()
|
||||
for line in io.popen("svn status -q"):lines() do
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function hg_prompt_filter()
|
||||
|
||||
-- Colors for mercurial status
|
||||
@ -264,10 +285,37 @@ function git_prompt_filter()
|
||||
return false
|
||||
end
|
||||
|
||||
function svn_prompt_filter()
|
||||
-- Colors for svn status
|
||||
local colors = {
|
||||
clean = "\x1b[1;37;40m",
|
||||
dirty = "\x1b[31;1m",
|
||||
}
|
||||
|
||||
if get_svn_dir() then
|
||||
-- if we're inside of svn repo then try to detect current branch
|
||||
local branch = get_svn_branch()
|
||||
if branch then
|
||||
if get_svn_status() then
|
||||
color = colors.clean
|
||||
else
|
||||
color = colors.dirty
|
||||
end
|
||||
|
||||
clink.prompt.value = string.gsub(clink.prompt.value, "{svn}", color.."("..branch..")")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- No mercurial present or not in mercurial file
|
||||
clink.prompt.value = string.gsub(clink.prompt.value, "{svn}", "")
|
||||
return false
|
||||
end
|
||||
-- insert the set_prompt at the very beginning so that it runs first
|
||||
clink.prompt.register_filter(set_prompt_filter, 1)
|
||||
clink.prompt.register_filter(hg_prompt_filter, 50)
|
||||
clink.prompt.register_filter(git_prompt_filter, 50)
|
||||
clink.prompt.register_filter(svn_prompt_filter, 50)
|
||||
|
||||
local completions_dir = clink.get_env('CMDER_ROOT')..'/vendor/clink-completions/'
|
||||
for _,lua_module in ipairs(clink.find_files(completions_dir..'*.lua')) do
|
||||
|
57
vendor/git-prompt.sh
vendored
57
vendor/git-prompt.sh
vendored
@ -1,22 +1,39 @@
|
||||
PS1='\[\033]0;$MSYSTEM:${PWD//[^[:ascii:]]/?}\007\]' # set window title
|
||||
PS1="$PS1"'\[\033[32m\]' # change to green
|
||||
PS1="$PS1"'\u@\h ' # user@host<space>
|
||||
PS1="$PS1"'\[\033[33m\]' # change to brownish yellow
|
||||
PS1="$PS1"'\w' # current working directory
|
||||
if test -z "$WINELOADERNOEXEC"
|
||||
if test -f /etc/profile.d/git-sdk.sh
|
||||
then
|
||||
GIT_EXEC_PATH="$(git --exec-path 2>/dev/null)"
|
||||
COMPLETION_PATH="${GIT_EXEC_PATH%/libexec/git-core}"
|
||||
COMPLETION_PATH="${COMPLETION_PATH%/lib/git-core}"
|
||||
COMPLETION_PATH="$COMPLETION_PATH/share/git/completion"
|
||||
if test -f "$COMPLETION_PATH/git-prompt.sh"
|
||||
then
|
||||
. "$COMPLETION_PATH/git-completion.bash"
|
||||
. "$COMPLETION_PATH/git-prompt.sh"
|
||||
PS1="$PS1"'\[\033[36m\]' # change color to cyan
|
||||
PS1="$PS1"'`__git_ps1`' # bash function
|
||||
fi
|
||||
TITLEPREFIX=SDK-${MSYSTEM#MINGW}
|
||||
else
|
||||
TITLEPREFIX=$MSYSTEM
|
||||
fi
|
||||
PS1="$PS1"'\[\033[0m\]' # change color
|
||||
PS1="$PS1"'\n' # new line
|
||||
PS1="$PS1"'λ ' # prompt: always λ
|
||||
|
||||
if test -f ~/.config/git/git-prompt.sh
|
||||
then
|
||||
. ~/.config/git/git-prompt.sh
|
||||
else
|
||||
PS1='\[\033]0;$MSYSTEM:${PWD//[^[:ascii:]]/?}\007\]' # set window title
|
||||
# PS1="$PS1"'\n' # new line
|
||||
PS1="$PS1"'\[\033[32m\]' # change to green
|
||||
PS1="$PS1"'\u@\h ' # user@host<space>
|
||||
# PS1="$PS1"'\[\033[35m\]' # change to purple
|
||||
# PS1="$PS1"'$MSYSTEM ' # show MSYSTEM
|
||||
PS1="$PS1"'\[\033[33m\]' # change to brownish yellow
|
||||
PS1="$PS1"'\w' # current working directory
|
||||
if test -z "$WINELOADERNOEXEC"
|
||||
then
|
||||
GIT_EXEC_PATH="$(git --exec-path 2>/dev/null)"
|
||||
COMPLETION_PATH="${GIT_EXEC_PATH%/libexec/git-core}"
|
||||
COMPLETION_PATH="${COMPLETION_PATH%/lib/git-core}"
|
||||
COMPLETION_PATH="$COMPLETION_PATH/share/git/completion"
|
||||
if test -f "$COMPLETION_PATH/git-prompt.sh"
|
||||
then
|
||||
. "$COMPLETION_PATH/git-completion.bash"
|
||||
. "$COMPLETION_PATH/git-prompt.sh"
|
||||
PS1="$PS1"'\[\033[36m\]' # change color to cyan
|
||||
PS1="$PS1"'`__git_ps1`' # bash function
|
||||
fi
|
||||
fi
|
||||
PS1="$PS1"'\[\033[0m\]' # change color
|
||||
PS1="$PS1"'\n' # new line
|
||||
PS1="$PS1"'λ ' # prompt: always λ
|
||||
fi
|
||||
|
||||
MSYS2_PS1="$PS1" # for detection by MSYS2 SDK's bash.basrc
|
||||
|
14
vendor/init.bat
vendored
14
vendor/init.bat
vendored
@ -149,9 +149,9 @@ call "%user-aliases%"
|
||||
:: manually extracting the archive rather than executing the 7z sfx
|
||||
if exist "%CMDER_ROOT%\vendor\git-for-windows\post-install.bat" (
|
||||
call :verbose-output Running Git for Windows one time Post Install....
|
||||
cd /d "%CMDER_ROOT%\vendor\git-for-windows\"
|
||||
pushd "%CMDER_ROOT%\vendor\git-for-windows\"
|
||||
"%CMDER_ROOT%\vendor\git-for-windows\git-bash.exe" --no-needs-console --hide --no-cd --command=post-install.bat
|
||||
cd /d %USERPROFILE%
|
||||
pushd "%USERPROFILE%"
|
||||
)
|
||||
|
||||
:: Set home path
|
||||
@ -160,10 +160,9 @@ if not defined HOME set "HOME=%USERPROFILE%"
|
||||
:: This is either a env variable set by the user or the result of
|
||||
:: cmder.exe setting this variable due to a commandline argument or a "cmder here"
|
||||
if defined CMDER_START (
|
||||
cd /d "%CMDER_START%"
|
||||
pushd "%CMDER_START%"
|
||||
)
|
||||
|
||||
|
||||
if exist "%CMDER_ROOT%\config\user-profile.cmd" (
|
||||
REM Create this file and place your own command in there
|
||||
call "%CMDER_ROOT%\config\user-profile.cmd"
|
||||
@ -173,7 +172,14 @@ if exist "%CMDER_ROOT%\config\user-profile.cmd" (
|
||||
echo :: use this file to run your own startup commands
|
||||
echo :: use in front of the command to prevent printing the command
|
||||
echo.
|
||||
echo :: uncomment this to have the ssh agent load when cmder starts
|
||||
echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-agent.cmd"
|
||||
echo.
|
||||
echo :: uncomment this next two lines to use pageant as the ssh authentication agent
|
||||
echo :: SET SSH_AUTH_SOCK=/tmp/.ssh-pageant-auth-sock
|
||||
echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-pageant.cmd"
|
||||
echo.
|
||||
echo :: you can add your plugins to the cmder path like so
|
||||
echo :: set "PATH=%%CMDER_ROOT%%\vendor\whatever;%%PATH%%"
|
||||
echo.
|
||||
) > "%CMDER_ROOT%\config\user-profile.cmd"
|
||||
|
64
vendor/profile.ps1
vendored
64
vendor/profile.ps1
vendored
@ -17,10 +17,14 @@ if(!$PSScriptRoot) {
|
||||
$PSScriptRoot = Split-Path $Script:MyInvocation.MyCommand.Path
|
||||
}
|
||||
|
||||
# do not load bundled psget if a module installer is already available
|
||||
# -> recent PowerShell versions include PowerShellGet out of the box
|
||||
$moduleInstallerAvailable = [bool](Get-Command -Name 'Install-Module' -ErrorAction SilentlyContinue | Out-Null)
|
||||
|
||||
# Add Cmder modules directory to the autoload path.
|
||||
$CmderModulePath = Join-path $PSScriptRoot "psmodules/"
|
||||
|
||||
if( -not $env:PSModulePath.Contains($CmderModulePath) ){
|
||||
if(-not $moduleInstallerAvailable -and -not $env:PSModulePath.Contains($CmderModulePath) ){
|
||||
$env:PSModulePath = $env:PSModulePath.Insert(0, "$CmderModulePath;")
|
||||
}
|
||||
|
||||
@ -86,19 +90,6 @@ if (Get-Module PSReadline -ErrorAction "SilentlyContinue") {
|
||||
# Enhance Path
|
||||
$env:Path = "$Env:CMDER_ROOT\bin;$env:Path;$Env:CMDER_ROOT"
|
||||
|
||||
# Drop *.ps1 files into "$ENV:CMDER_ROOT\config\profile.d"
|
||||
# to source them at startup.
|
||||
if (-not (test-path "$ENV:CMDER_ROOT\config\profile.d")) {
|
||||
mkdir "$ENV:CMDER_ROOT\config\profile.d"
|
||||
}
|
||||
|
||||
pushd $ENV:CMDER_ROOT\config\profile.d
|
||||
foreach ($x in ls *.ps1) {
|
||||
# write-host write-host Sourcing $x
|
||||
. $x
|
||||
}
|
||||
popd
|
||||
|
||||
#
|
||||
# Prompt Section
|
||||
# Users should modify their user-profile.ps1 as it will be safe from updates.
|
||||
@ -113,6 +104,35 @@ popd
|
||||
checkGit($pwd.ProviderPath)
|
||||
}
|
||||
|
||||
<#
|
||||
This scriptblock runs every time the prompt is returned.
|
||||
Explicitly use functions from MS namespace to protect from being overridden in the user session.
|
||||
Custom prompt functions are loaded in as constants to get the same behaviour
|
||||
#>
|
||||
[ScriptBlock]$Prompt = {
|
||||
$realLASTEXITCODE = $LASTEXITCODE
|
||||
$host.UI.RawUI.WindowTitle = Microsoft.PowerShell.Management\Split-Path $pwd.ProviderPath -Leaf
|
||||
PrePrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
|
||||
CmderPrompt
|
||||
Microsoft.PowerShell.Utility\Write-Host "`nλ " -NoNewLine -ForegroundColor "DarkGray"
|
||||
PostPrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
|
||||
$global:LASTEXITCODE = $realLASTEXITCODE
|
||||
return " "
|
||||
}
|
||||
|
||||
# Drop *.ps1 files into "$ENV:CMDER_ROOT\config\profile.d"
|
||||
# to source them at startup.
|
||||
if (-not (test-path "$ENV:CMDER_ROOT\config\profile.d")) {
|
||||
mkdir "$ENV:CMDER_ROOT\config\profile.d"
|
||||
}
|
||||
|
||||
pushd $ENV:CMDER_ROOT\config\profile.d
|
||||
foreach ($x in ls *.ps1) {
|
||||
# write-host write-host Sourcing $x
|
||||
. $x
|
||||
}
|
||||
popd
|
||||
|
||||
$CmderUserProfilePath = Join-Path $env:CMDER_ROOT "config\user-profile.ps1"
|
||||
if(Test-Path $CmderUserProfilePath) {
|
||||
# Create this file and place your own command in there.
|
||||
@ -160,22 +180,6 @@ Set-Item -Path function:\PrePrompt -Value $PrePrompt -Options Constant
|
||||
Set-Item -Path function:\CmderPrompt -Value $CmderPrompt -Options Constant
|
||||
Set-Item -Path function:\PostPrompt -Value $PostPrompt -Options Constant
|
||||
|
||||
<#
|
||||
This scriptblock runs every time the prompt is returned.
|
||||
Explicitly use functions from MS namespace to protect from being overridden in the user session.
|
||||
Custom prompt functions are loaded in as constants to get the same behaviour
|
||||
#>
|
||||
[ScriptBlock]$Prompt = {
|
||||
$realLASTEXITCODE = $LASTEXITCODE
|
||||
$host.UI.RawUI.WindowTitle = Microsoft.PowerShell.Management\Split-Path $pwd.ProviderPath -Leaf
|
||||
PrePrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
|
||||
CmderPrompt
|
||||
Microsoft.PowerShell.Utility\Write-Host "`nλ " -NoNewLine -ForegroundColor "DarkGray"
|
||||
PostPrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
|
||||
$global:LASTEXITCODE = $realLASTEXITCODE
|
||||
return " "
|
||||
}
|
||||
|
||||
# Functions can be made constant only at creation time
|
||||
# ReadOnly at least requires `-force` to be overwritten
|
||||
Set-Item -Path function:\prompt -Value $Prompt -Options ReadOnly
|
||||
|
16
vendor/sources.json
vendored
16
vendor/sources.json
vendored
@ -1,22 +1,22 @@
|
||||
[
|
||||
{
|
||||
"name": "git-for-windows",
|
||||
"version": "v2.11.0.windows.1",
|
||||
"url": "https://github.com/git-for-windows/git/releases/download/v2.11.0.windows.1/PortableGit-2.11.0-32-bit.7z.exe"
|
||||
"version": "v2.14.3.windows.1",
|
||||
"url": "https://github.com/git-for-windows/git/releases/download/v2.14.3.windows.1/PortableGit-2.14.3-32-bit.7z.exe"
|
||||
},
|
||||
{
|
||||
"name": "clink",
|
||||
"version": "0.4.8",
|
||||
"url": "https://github.com/mridgers/clink/releases/download/0.4.8/clink_0.4.8.zip"
|
||||
"version": "0.4.9",
|
||||
"url": "https://github.com/Stanzilla/clink/releases/download/0.4.9/clink_DEV.zip"
|
||||
},
|
||||
{
|
||||
"name": "conemu-maximus5",
|
||||
"version": "161022",
|
||||
"url": "https://github.com/Maximus5/ConEmu/releases/download/v16.10.22/ConEmuPack.161022.7z"
|
||||
"version": "171025",
|
||||
"url": "https://github.com/Maximus5/ConEmu/releases/download/v17.10.25/ConEmuPack.171025.7z"
|
||||
},
|
||||
{
|
||||
"name": "clink-completions",
|
||||
"version": "0.3.2",
|
||||
"url": "https://github.com/vladimir-kotikov/clink-completions/archive/0.3.2.zip"
|
||||
"version": "0.3.3",
|
||||
"url": "https://github.com/vladimir-kotikov/clink-completions/archive/0.3.3.zip"
|
||||
}
|
||||
]
|
||||
|
Reference in New Issue
Block a user