Merge pull request #1037 from cmderdev/development

Development into Master
This commit is contained in:
Benjamin Staneck 2016-07-14 07:54:42 +02:00 committed by GitHub
commit 0379dc1d0d
42 changed files with 303 additions and 113 deletions

View File

@ -1,8 +1,6 @@
# Cmder
[![Join the chat at https://gitter.im/cmderdev/cmder](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cmderdev/cmder?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![Build Status](https://ci.appveyor.com/api/projects/status/32r7s2skrgm9ubva?retina=true)
[![Join the chat at https://gitter.im/cmderdev/cmder](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cmderdev/cmder?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://ci.appveyor.com/api/projects/status/32r7s2skrgm9ubva/branch/master?svg=true)](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.
@ -15,9 +13,9 @@ The main advantage of Cmder is portability. It is designed to be totally self-co
## Installation
1. Download the [latest release](https://github.com/cmderdev/cmder/releases/)
2. Extract
3. (optional) Place your own executable files into the `bin` folder to be injected into your PATH.
4. Run Cmder
2. Extract the archive
3. (optional) Place your own executable files into the `bin` folder to be injected into your PATH
4. Run Cmder.exe
## Integration
@ -44,7 +42,7 @@ In a file explorer window right click in or on a directory to see "Cmder Here" i
### Shell
* <kbd>Shift</kbd> + <kbd>Up</kbd> : Traverse up in directory structure (lovely feature!)
* <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>U</kbd> : Traverse up in directory structure (lovely feature!)
* <kbd>End</kbd>, <kbd>Home</kbd>, <kbd>Ctrl</kbd> : Traversing text with as usual on Windows
* <kbd>Ctrl</kbd> + <kbd>R</kbd> : History search
* <kbd>Shift</kbd> + Mouse : Select and copy text from buffer
@ -60,18 +58,18 @@ You can open multiple tabs each containing one of the following shells:
|----|-----|-----------|
|Cmder|cmd.exe|Windows 'cmd.exe' shell enhanced with Git, Git aware prompt, Clink(GNU Readline), and Aliases.|
|Cmder as Admin|cmd.exe|Administrative Windows 'cmd.exe' Cmder shell.|
|Powershell|powershell.exe|Windows Powershell enhanced with Git and Git aware prompt .|
|Powershell as Admin|powershell.exe|Administrative Windows 'powerhell.exe' Cmder shell.|
|PowerShell|powershell.exe|Windows PowerShell enhanced with Git and Git aware prompt .|
|PowerShell as Admin|powershell.exe|Administrative Windows 'powerhell.exe' Cmder shell.|
|Bash|bash.exe|Unix/Linux like bash shell running on Windows.|
|Bash as Admin|bash.exe|Administrative Unix/Linux like bash shell running on Windows.|
|Mintty|bash.exe|Unix/Linux like bash shell running on Windows. See below for Mintty configuration differences|
|Mintty as Admin|bash.exe|Administrative Unix/Linux like bash shell running on Windows. See below for Mintty configuration differences|
Cmder, Powershell, and Bash tabs all run on top of the Windows Console API and work as you might expect in Cmder with access to use ConEmu's color schemes, key bindings and other settings defined in the ConEmu Settings dialog.
Cmder, PowerShell, and Bash tabs all run on top of the Windows Console API and work as you might expect in Cmder with access to use ConEmu's color schemes, key bindings and other settings defined in the ConEmu Settings dialog.
Mintty tabs use a program called 'mintty' as the terminal that is not based on the Windows Console API so some differences in functionality are normal, as a result mintty specific config is done via the '[%USERPROFILE%|$HOME]/.minttyrc' file.
Mintty differs from the other tabs in that it supports xterm/xterm-256color TERM types, and does not work with ConEmu settings like color schemes and key bindings. For more on Mintty and its config click [here](https://code.google.com/p/mintty/).
Mintty differs from the other tabs in that it supports xterm/xterm-256color TERM types, and does not work with ConEmu settings like color schemes and key bindings. For more on Mintty and its config click [here](https://github.com/mintty/mintty).
An example of setting Cmder portable terminal colors for mintty:
@ -90,7 +88,7 @@ User specific configuration is possible using the cmder specific shell config fi
|Shell|Cmder Portable User Config|
| ------------- |:-------------:|
|Cmder|%CMDER_ROOT%\config\user-profile.cmd|
|Powershell|$ENV:CMDER_ROOT\config\user-profile.ps1|
|PowerShell|$ENV:CMDER_ROOT\config\user-profile.ps1|
|Bash/Mintty|$CMDER_ROOT/config/user-profile.sh|
Note: Bash and Mintty sessions will also source the '$HOME/.bashrc' file it it exists after it sources '$CMDER_ROOT/config/user-profile.sh'.
@ -101,7 +99,7 @@ You can write *.cmd|*.bat, *.ps1, and *.sh scripts and just drop them in the %CM
|Shell|Cmder 'Profile.d' Scripts|
| ------------- |:-------------:|
|Cmder|%CMDER_ROOT%\config\profile.d\\*.bat and *.cmd|
|Powershell|$ENV:CMDER_ROOT\config\profile.d\\*.ps1|
|PowerShell|$ENV:CMDER_ROOT\config\profile.d\\*.ps1|
|Bash/Mintty|$CMDER_ROOT/config/profile.d/*.sh|
@ -118,8 +116,8 @@ Bash shells support simple and complex aliases with optional parameters natively
If you add bash aliases to `$CMDER_ROOT/config/user-profile.sh` they will 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.
#### 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.
### SSH Agent
@ -129,11 +127,11 @@ If you want to run SSH agent on startup, include the line `@call "%GIT_INSTALL_R
### Using external Cygwin/Babun, MSys2, or Git for Windows SDK with Cmder.
1. Setup a new task by pressing '<kbd>Win</kbd> +<kbd>Alt</kbd> + <kbd>T</kbd>'
1. Setup a new task by pressing '<kbd>Win</kbd> +<kbd>Alt</kbd> + <kbd>T</kbd>'.
1. Click the '+' button to add a task.
1. Name the new task in the top text box.
1. Provide task parameters, this is optional.
1. Add ```cmd /c "[path_to_external_env]\bin\bash --login -i" -new_console:d:%USERPROFILE%``` to the Commands text box.
1. Add ```cmd /c "[path_to_external_env]\bin\bash --login -i" -new_console:d:%USERPROFILE%``` to the `Commands` text box.
Recommended Optional Steps:
@ -152,13 +150,9 @@ 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.
```
## Todo
1. Check for clink and git before injecting them (Sort of done)
## Current development branch
You can download builds of the current development branch by going to Appveyor via the following link:
You can download builds of the current development branch by going to AppVeyor via the following link:
[![AppVeyor](https://ci.appveyor.com/api/projects/status/github/cmderdev/cmder?svg=True)](https://ci.appveyor.com/project/MartiUK/cmder/branch/development/artifacts)
@ -168,7 +162,7 @@ All software included is bundled with own license
The MIT License (MIT)
Copyright (c) 2015 Samuel Vasko
Copyright (c) 2016 Samuel Vasko
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,64 +1,131 @@
@echo off
set ALIASES=%CMDER_ROOT%\config\aliases
setlocal
:: handle quotes within command definition, e.g. quoted long file names
set _x="%*"
set _x=%_x:"=%
if "%aliases%" == "" (
set ALIASES=%CMDER_ROOT%\config\user-aliases.cmd
)
setlocal enabledelayedexpansion
if "%~1" == "" echo Use /? for help & echo. & goto :p_show
:: check command usage
if ["%_x%"] == [""] echo Use /? for help & echo. & goto :p_show
if ["%1"] == ["/?"] goto:p_help
if ["%1"] == ["/reload"] goto:p_reload
:: /d flag for delete existing alias
if ["%1"] == ["/d"] goto:p_del %*
:: if arg is an existing alias, display it
if ["%2"] == [""] (
doskey /macros | findstr /b %1= && goto:eof
echo Insufficient parameters. & goto:p_help
rem #region parseargument
goto parseargument
:do_shift
shift
:parseargument
set currentarg=%~1
if /i "%currentarg%" equ "/f" (
set aliases=%~2
shift
goto :do_shift
) else if /i "%currentarg%" == "/reload" (
goto :p_reload
) else if "%currentarg%" equ "/?" (
goto :p_help
) else if /i "%currentarg%" equ "/d" (
if "%~2" neq "" (
if "%~3" equ "" (
:: /d flag for delete existing alias
call :p_del %~2
shift
goto :eof
)
)
) else if "%currentarg%" neq "" (
if "%~2" equ "" (
:: Show the specified alias
doskey /macros | findstr /b %currentarg%= && exit /b
echo insufficient parameters.
goto :p_help
) else (
:: handle quotes within command definition, e.g. quoted long file names
set _x=%*
)
)
rem #endregion parseargument
if "%aliases%" neq "%CMDER_ROOT%\config\user-aliases.cmd" (
set _x=!_x:/f %aliases% =!
if not exist "%aliases%" (
echo ;= @echo off>"%aliases%"
echo ;= rem Call DOSKEY and use this file as the macrofile>>"%aliases%"
echo ;= %%SystemRoot%%\system32\doskey /listsize=1000 /macrofile=%%0%%>>"%aliases%"
echo ;= rem In batch mode, jump to the end of the file>>"%aliases%"
echo ;= goto:eof>>"%aliases%"
echo ;= Add aliases below here>>"%aliases%"
)
)
:: validate alias
for /f "delims== tokens=1" %%G in ("%_x%") do set alias=%%G
set _temp=%alias: =%
for /f "delims== tokens=1,2 usebackq" %%G in (`echo "%_x%"`) do (
set alias_name=%%G
set alias_value=%%H
)
if not ["%_temp%"] == ["%alias%"] (
:: leading quotes added while validating
set alias_name=%alias_name:~1%
:: trailing quotes added while validating
set alias_value=%alias_value:~0,-1%
::remove spaces
set _temp=%alias_name: =%
if not ["%_temp%"] == ["%alias_name%"] (
echo Your alias name can not contain a space
endlocal
goto:eof
exit /b
)
:: replace already defined alias
findstr /b /v /i "%alias%=" "%ALIASES%" >> "%ALIASES%.tmp"
echo %* >> "%ALIASES%.tmp" && type "%ALIASES%.tmp" > "%ALIASES%" & @del /f /q "%ALIASES%.tmp"
findstr /b /v /i "%alias_name%=" "%ALIASES%" >> "%ALIASES%.tmp"
echo %alias_name%=%alias_value% >> "%ALIASES%.tmp" && type "%ALIASES%.tmp" > "%ALIASES%" & @del /f /q "%ALIASES%.tmp"
doskey /macrofile="%ALIASES%"
endlocal
goto:eof
exit /b
:p_del
findstr /b /v /i "%2=" "%ALIASES%" >> "%ALIASES%.tmp"
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%
goto:eof
:p_reload
doskey /macrofile="%ALIASES%"
echo Aliases reloaded
goto:eof
exit /b
:p_show
type "%ALIASES%" || echo No aliases found at "%ALIASES%"
goto :eof
doskey /macros|findstr /v /r "^;=" | sort
exit /b
:p_help
echo.Usage:
echo. alias [/reload] [/d] [name=full command]
echo. /reload Reload the aliases file
echo. /d Delete an alias (must be followed by the alias name)
echo.
echo. alias [options] [alias=full command]
echo.
echo.Options:
echo.
echo. /d [alias] Delete an [alias].
echo. /f [macrofile] Path to the [macrofile] you want to store the new alias in.
echo. Default: %cmder_root%\config\user-aliases.cmd
echo. /reload Reload the aliases file. Can be used with /f argument.
echo. Default: %cmder_root%\config\user-aliases.cmd
echo.
echo. If alias is called with no parameters, it will display the list of existing aliases.
echo.
echo. If alias is called with any parameters, it will display the list of existing aliases.
echo. In the command, you can use the following notations:
echo. $* allows the alias to assume all the parameters of the supplied command.
echo. $1-$9 Allows you to seperate parameter by number, much like %%1 in batch.
echo. $T is the command seperator, allowing you to string several commands together into one alias.
echo. For more information, read DOSKEY/?
exit /b

BIN
icons/cmder_blue.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
icons/cmder_green.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

BIN
icons/cmder_orange.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
icons/cmder_purple.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
icons/cmder_red.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
icons/cmder_yellow.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
icons/icon_16_blue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

BIN
icons/icon_16_green.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

BIN
icons/icon_16_orange.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

BIN
icons/icon_16_purple.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

BIN
icons/icon_16_red.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

BIN
icons/icon_16_yellow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

BIN
icons/icon_256_blue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
icons/icon_256_green.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
icons/icon_256_orange.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
icons/icon_256_purple.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
icons/icon_256_red.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
icons/icon_256_yellow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
icons/icon_32_blue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

BIN
icons/icon_32_green.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

BIN
icons/icon_32_orange.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

BIN
icons/icon_32_purple.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 B

BIN
icons/icon_32_red.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

BIN
icons/icon_32_yellow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

BIN
icons/icon_48_blue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

BIN
icons/icon_48_green.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

BIN
icons/icon_48_orange.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

BIN
icons/icon_48_purple.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

BIN
icons/icon_48_red.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 B

BIN
icons/icon_48_yellow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

View File

@ -131,7 +131,14 @@ void StartCmder(std::wstring path, bool is_single_mode)
PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.xml");
}
PathCombine(conEmuPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.exe");
SYSTEM_INFO sysInfo;
GetNativeSystemInfo(&sysInfo);
if (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
PathCombine(conEmuPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu64.exe");
}
else {
PathCombine(conEmuPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.exe");
}
if (FileExists(oldCfgPath) && !FileExists(cfgPath))
{

View File

@ -9,10 +9,10 @@ config\.history
packignore
icons\Thumbs.db
icons\cmder_icon.psd
icons\icon_16.png
icons\icon_32.png
icons\icon_48.png
icons\icon_256.png
icons\icon_16*.png
icons\icon_32*.png
icons\icon_48*.png
icons\icon_256*.png
Cmder.bat
vendor\tmp
appveyor.yml

View File

@ -28,7 +28,7 @@ function Delete-Existing ($path) {
}
function Extract-Archive ($source, $target) {
Invoke-Expression "7z x -y -o$($target) '$source' > `$null"
Invoke-Expression "7z x -y -o`"$($target)`" `"$source`" > `$null"
if ($lastexitcode -ne 0) {
Write-Error "Extracting of $source failied"
}
@ -79,14 +79,39 @@ function Register-Cmder(){
)
Begin
{
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT > $null
}
Process
{
New-Item -Path "HKCR:\Directory\Shell\Cmder" -Force -Value $MenuText
New-Item -Path "HKCR:\Directory\Shell\Cmder" -Force -Value $MenuText
New-ItemProperty -Path "HKCR:\Directory\Shell\Cmder" -Force -Name "Icon" -Value `"$icon`"
New-ItemProperty -Path "HKCR:\Directory\Shell\Cmder" -Force -Name "NoWorkingDirectory"
New-Item -Path "HKCR:\Directory\Shell\Cmder\Command" -Force -Value "`"$PathToExe`" `"$Command`" "
New-Item -Path "HKCR:\Directory\Shell\Cmder\Command" -Force -Value "`"$PathToExe`" `"$Command`" "
New-Item -Path "HKCR:\Directory\Background\Shell\Cmder" -Force -Value $MenuText
New-ItemProperty -Path "HKCR:\Directory\Background\Shell\Cmder" -Force -Name "Icon" -Value `"$icon`"
New-ItemProperty -Path "HKCR:\Directory\Background\Shell\Cmder" -Force -Name "NoWorkingDirectory"
New-Item -Path "HKCR:\Directory\Background\Shell\Cmder\Command" -Force -Value "`"$PathToExe`" `"$Command`" "
}
End
{
Remove-PSDrive -Name HKCR
}
}
function Unregister-Cmder{
Begin
{
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT > $null
}
Process
{
Remove-Item -Path "HKCR:\Directory\Shell\Cmder" -Recurse
Remove-Item -Path "HKCR:\Directory\Background\Shell\Cmder" -Recurse
}
End
{
Remove-PSDrive -Name HKCR
}
}
@ -99,6 +124,9 @@ function Download-File {
$File = $File -Replace "/", "\"
Write-Verbose "Downloading from $Url to $File"
$wc = new-object System.Net.WebClient
$wc.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials;
if ($env:https_proxy) {
$wc.proxy = (new-object System.Net.WebProxy($env:https_proxy))
}
$wc.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials;
$wc.DownloadFile($Url, $File)
}

View File

@ -1,8 +0,0 @@
e.=explorer .
gl=git log --oneline --all --graph --decorate $*
ls=ls --show-control-chars -F --color $*
pwd=cd
clear=cls
history=cat %CMDER_ROOT%\config\.history
unalias=alias /d $1
vi=vim $*

22
vendor/clink.lua vendored
View File

@ -12,8 +12,18 @@ dofile(clink_lua_file)
-- now add our own things...
function lambda_prompt_filter()
clink.prompt.value = string.gsub(clink.prompt.value, "{lamb}", "λ")
---
-- Setting the prompt in clink means that commands which rewrite the prompt do
-- not destroy our own prompt. It also means that started cmds (or batch files
-- which echo) don't get the ugly '{lamb}' shown.
---
function set_prompt_filter()
-- orig: $E[1;32;40m$P$S{git}{hg}$S$_$E[1;30;40m{lamb}$S$E[0m
-- color codes: "\x1b[1;37;40m"
cwd = clink.get_cwd()
prompt = "\x1b[1;32;40m{cwd} {git}{hg} \n\x1b[1;30;40m{lamb} \x1b[0m"
new_value = string.gsub(prompt, "{cwd}", cwd)
clink.prompt.value = string.gsub(new_value, "{lamb}", "λ")
end
---
@ -193,7 +203,10 @@ end
-- @return {bool}
---
function get_git_status()
return io.popen("git diff --quiet --ignore-submodules HEAD 2>nul")
for line in io.popen("git status --porcelain 2>nul"):lines() do
return false
end
return true
end
function git_prompt_filter()
@ -226,7 +239,8 @@ function git_prompt_filter()
return false
end
clink.prompt.register_filter(lambda_prompt_filter, 40)
-- 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)

133
vendor/init.bat vendored
View File

@ -6,17 +6,16 @@
:: !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED
:: !!! Use "%CMDER_ROOT%\config\user-profile.cmd" to add your own startup commands
:: Set to > 0 for verbose output to aid in debugging.
if not defined verbose-output ( set verbose-output=0 )
:: Find root dir
if not defined CMDER_ROOT (
for /f "delims=" %%i in ("%ConEmuDir%\..\..") do set CMDER_ROOT=%%~fi
for /f "delims=" %%i in ("%ConEmuDir%\..\..") do set "CMDER_ROOT=%%~fi"
)
:: Remove trailing '\'
if "%CMDER_ROOT:~-1%" == "\" SET CMDER_ROOT=%CMDER_ROOT:~0,-1%
:: Change the prompt style
:: Mmm tasty lamb
prompt $E[1;32;40m$P$S{git}{hg}$S$_$E[1;30;40m{lamb}$S$E[0m
if "%CMDER_ROOT:~-1%" == "\" SET "CMDER_ROOT=%CMDER_ROOT:~0,-1%"
:: Pick right version of clink
if "%PROCESSOR_ARCHITECTURE%"=="x86" (
@ -27,9 +26,9 @@ if "%PROCESSOR_ARCHITECTURE%"=="x86" (
:: Tell the user about the clink config files...
if not exist "%CMDER_ROOT%\config\settings" (
echo Generating clink initial settings in %CMDER_ROOT%\config\settings
echo Additional *.lua files in %CMDER_ROOT%\config are loaded on startup.
)
echo Generating clink initial settings in "%CMDER_ROOT%\config\settings"
echo Additional *.lua files in "%CMDER_ROOT%\config" are loaded on startup.
)
:: Run clink
"%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_ROOT%\config" --scripts "%CMDER_ROOT%\vendor"
@ -40,24 +39,55 @@ if not exist "%CMDER_ROOT%\config\settings" (
set PLINK_PROTOCOL=ssh
if not defined TERM set TERM=cygwin
:: Check if msysgit is installed
if exist "%ProgramFiles%\Git" (
set "GIT_INSTALL_ROOT=%ProgramFiles%\Git"
) else if exist "%ProgramFiles(x86)%\Git" (
set "GIT_INSTALL_ROOT=%ProgramFiles(x86)%\Git"
) else if exist "%USERPROFILE%\AppData\Local\Programs\Git" (
set "GIT_INSTALL_ROOT=%USERPROFILE%\AppData\Local\Programs\Git"
) else if exist "%CMDER_ROOT%\vendor\git-for-windows" (
set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows"
:: The idea:
:: * if the users points as to a specific git, use that
:: * test if a git is in path and if yes, use that
:: * last, use our vendored git
:: also check that we have a recent enough version of git (e.g. test for GIT\cmd\git.exe)
if defined GIT_INSTALL_ROOT (
if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" (goto :FOUND_GIT)
)
:: check if git is in path...
setlocal enabledelayedexpansion
for /F "delims=" %%F in ('where git.exe 2^>nul') do @(
pushd %%~dpF
cd ..
set "test_dir=!CD!"
popd
if exist "!test_dir!\cmd\git.exe" (
set "GIT_INSTALL_ROOT=!test_dir!"
set test_dir=
goto :FOUND_GIT
) else (
echo Found old git version in "!test_dir!", but not using...
set test_dir=
)
)
:: our last hope: our own git...
:VENDORED_GIT
if exist "%CMDER_ROOT%\vendor\git-for-windows" (
set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows"
call :verbose-output Add the minimal git commands to the front of the path
set "PATH=!GIT_INSTALL_ROOT!\cmd;%PATH%"
) else (
goto :NO_GIT
)
:FOUND_GIT
:: Add git to the path
if defined GIT_INSTALL_ROOT (
set "PATH=%GIT_INSTALL_ROOT%\bin;%GIT_INSTALL_ROOT%\usr\bin;%GIT_INSTALL_ROOT%\usr\share\vim\vim74;%PATH%"
rem add the unix commands at the end to not shadow windows commands like more
call :verbose-output Enhancing PATH with unix commands from git in "%GIT_INSTALL_ROOT%\usr\bin"
set "PATH=%PATH%;%GIT_INSTALL_ROOT%\usr\bin;%GIT_INSTALL_ROOT%\usr\share\vim\vim74"
:: define SVN_SSH so we can use git svn with ssh svn repositories
if not defined SVN_SSH set "SVN_SSH=%GIT_INSTALL_ROOT:\=\\%\\bin\\ssh.exe"
)
:NO_GIT
endlocal & set "PATH=%PATH%" & set "SVN_SSH=%SVN_SSH%" & set "GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"
:: Enhance Path
set "PATH=%CMDER_ROOT%\bin;%PATH%;%CMDER_ROOT%\"
@ -69,32 +99,63 @@ if not exist "%CMDER_ROOT%\config\profile.d" (
pushd "%CMDER_ROOT%\config\profile.d"
for /f "usebackq" %%x in ( `dir /b *.bat *.cmd 2^>nul` ) do (
REM echo Calling %CMDER_ROOT%\config\profile.d\%%x...
call :verbose-output Calling "%CMDER_ROOT%\config\profile.d\%%x"...
call "%CMDER_ROOT%\config\profile.d\%%x"
)
popd
:: make sure we have an example file
if not exist "%CMDER_ROOT%\config\aliases" (
echo Creating intial aliases in %CMDER_ROOT%\config\aliases
copy "%CMDER_ROOT%\vendor\aliases.example" "%CMDER_ROOT%\config\aliases" > null
:: Allows user to override default aliases store using profile.d
:: scripts run above by setting the 'aliases' env variable.
::
:: Note: If overriding default aliases store file the aliases
:: must also be self executing, see '.\user-aliases.cmd.example',
:: and be in profile.d folder.
set "user-aliases=%CMDER_ROOT%\config\user-aliases.cmd"
:: The aliases environment variable is used by alias.bat to id
:: the default file to store new aliases in.
if not defined aliases (
set "aliases=%user-aliases%"
)
:: Add aliases
doskey /macrofile="%CMDER_ROOT%\config\aliases"
:: Make sure we have a self-extracting user-aliases.cmd file
setlocal enabledelayedexpansion
if not exist "%user-aliases%" (
echo Creating intial user-aliases store in "%user-aliases%"...
copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%"
) else (
type "%user-aliases%" | findstr /i ";= Add aliases below here" >nul
if "!errorlevel!" == "1" (
echo Creating intial user-aliases store in "%user-aliases%"...
copy "%CMDER_ROOT%\%user-aliases%" "%user-aliases%.old_format"
copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%"
)
)
:: Update old 'user-aliases' to new self executing 'user-aliases.cmd'
if exist "%CMDER_ROOT%\config\aliases" (
echo Updating old "%CMDER_ROOT%\config\aliases" to new format...
type "%CMDER_ROOT%\config\aliases" >> "%user-aliases%" && del "%CMDER_ROOT%\config\aliases"
) else if exist "%user-aliases%.old_format" (
echo Updating old "%user-aliases%" to new format...
type "%user-aliases%.old_format" >> "%user-aliases%" && del "%user-aliases%.old_format"
)
endlocal
:: Add aliases to the environment
call "%user-aliases%"
:: See vendor\git-for-windows\README.portable for why we do this
:: Basically we need to execute this post-install.bat because we are
:: manually extracting the archive rather than executing the 7z sfx
if exist "%CMDER_ROOT%\vendor\git-for-windows\post-install.bat" (
echo Running Git for Windows one time Post Install....
call :verbose-output Running Git for Windows one time Post Install....
cd /d "%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%
)
:: Set home path
if not defined HOME set HOME=%USERPROFILE%
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"
@ -102,8 +163,9 @@ if defined CMDER_START (
cd /d "%CMDER_START%"
)
if exist "%CMDER_ROOT%\config\user-profile.cmd" (
rem create this file and place your own command in there
REM Create this file and place your own command in there
call "%CMDER_ROOT%\config\user-profile.cmd"
) else (
echo Creating user startup file: "%CMDER_ROOT%\config\user-profile.cmd"
@ -111,8 +173,17 @@ 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 :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-agent.cmd
echo :: set PATH=%%CMDER_ROOT%%\vendor\whatever;%%PATH%%
echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-agent.cmd"
echo :: set "PATH=%%CMDER_ROOT%%\vendor\whatever;%%PATH%%"
echo.
) > "%CMDER_ROOT%\config\user-profile.cmd"
)
exit /b
::
:: sub-routines below here
::
:verbose-output
if %verbose-output% gtr 0 echo %*
exit /b

2
vendor/profile.ps1 vendored
View File

@ -41,6 +41,8 @@ try {
# Check if git is on PATH, i.e. Git already installed on system
Get-command -Name "git" -ErrorAction Stop >$null
} catch {
$env:Path += $(";" + $env:CMDER_ROOT + "\vendor\git-for-windows\cmd")
# for bash.exe, which in the cmd version is found as <GIT>\usr\bin\bash.exe
$env:Path += $(";" + $env:CMDER_ROOT + "\vendor\git-for-windows\bin")
}

16
vendor/sources.json vendored
View File

@ -1,22 +1,22 @@
[
{
"name": "git-for-windows",
"version": "v2.7.4.windows.1",
"url": "https://github.com/git-for-windows/git/releases/download/v2.7.4.windows.1/PortableGit-2.7.4-32-bit.7z.exe"
"version": "v2.9.0.windows.1",
"url": "https://github.com/git-for-windows/git/releases/download/v2.9.0.windows.1/PortableGit-2.9.0-32-bit.7z.exe"
},
{
"name": "clink",
"version": "0.4.7",
"url": "https://github.com/mridgers/clink/releases/download/0.4.7/clink_0.4.7.zip"
"version": "0.4.8",
"url": "https://github.com/mridgers/clink/releases/download/0.4.8/clink_0.4.8.zip"
},
{
"name": "conemu-maximus5",
"version": "160207",
"url": "https://github.com/Maximus5/ConEmu/releases/download/v16.02.07/ConEmuPack.160207.7z"
"version": "160612",
"url": "https://github.com/Maximus5/ConEmu/releases/download/v16.06.12/ConEmuPack.160612.7z"
},
{
"name": "clink-completions",
"version": "0.2.2",
"url": "https://github.com/vladimir-kotikov/clink-completions/archive/0.2.2.zip"
"version": "0.3.1",
"url": "https://github.com/vladimir-kotikov/clink-completions/archive/0.3.1.zip"
}
]

15
vendor/user-aliases.cmd.example vendored Normal file
View File

@ -0,0 +1,15 @@
;= @echo off
;= rem Call DOSKEY and use this file as the macrofile
;= %SystemRoot%\system32\doskey /listsize=1000 /macrofile=%0%
;= rem In batch mode, jump to the end of the file
;= goto:eof
;= Add aliases below here
e.=explorer .
gl=git log --oneline --all --graph --decorate $*
ls=ls --show-control-chars -F --color $*
pwd=cd
clear=cls
history=cat %CMDER_ROOT%\config\.history
unalias=alias /d $1
vi=vim $*
cmderr=cd /d "%CMDER_ROOT%"