Merge pull request #723 from cmderdev/release-1.3

Release 1.3
This commit is contained in:
Martin Kemp 2016-03-20 11:54:28 +00:00
commit 73f9400aa8
23 changed files with 691 additions and 252 deletions

2
.gitignore vendored
View File

@ -8,6 +8,8 @@ vendor/*/*
config/.history
Thumbs.db
*.exe
*.dll
build/
Version v*
*.bak
config/user-*

View File

@ -1,3 +1,11 @@
@echo off
SET CMDER_ROOT=%~dp0
start %~dp0/vendor/conemu-maximus5/ConEmu.exe /Icon "%CMDER_ROOT%\icons\cmder.ico" /Title Cmder /LoadCfgFile "%CMDER_ROOT%\config\ConEmu.xml"
:: Remove trailing '\'
@if "%CMDER_ROOT:~-1%" == "\" SET CMDER_ROOT=%CMDER_ROOT:~0,-1%
if exist "%~1" (
start %~dp0/vendor/conemu-maximus5/ConEmu.exe /Icon "%CMDER_ROOT%\icons\cmder.ico" /Title Cmder /LoadCfgFile "%~1"
) else (
start %~dp0/vendor/conemu-maximus5/ConEmu.exe /Icon "%CMDER_ROOT%\icons\cmder.ico" /Title Cmder /LoadCfgFile "%CMDER_ROOT%\config\ConEmu.xml"
)

View File

@ -2,28 +2,26 @@
[![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)
Latest release is **[v1.2](https://github.com/bliker/cmder/releases/tag/v1.2)**
![Build Status](https://ci.appveyor.com/api/projects/status/32r7s2skrgm9ubva?retina=true)
Cmder is a **software package** created out of pure frustration over absence of usable console emulator on Windows. It is based on [ConEmu](https://github.com/Maximus5/ConEmu) with *major* config overhaul. Monokai color scheme, amazing [clink](https://github.com/mridgers/clink) and custom prompt layout.
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.
![Cmder Screenshot](http://i.imgur.com/g1nNf0I.png)
## Why use it
The main advantage of Cmder is portability. It is designed to be totally self-contained with no external dependencies, which makes it great for **USB Sticks** or **Dropbox** - 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, which makes it great for **USB Sticks** or **cloud storage**. So you can carry your console, aliases and binaries (like wget, curl and git) with you anywhere.
## Installation
1. Download the latest release
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
*(There will be a version with installer)*
4. Run Cmder
## Integration
So, you've experimented with cmder a little and want to give it a shot in a more permanent home:
So you've experimented with Cmder a little and want to give it a shot in a more permanent home;
### Shortcut to open Cmder in a chosen folder
@ -38,40 +36,90 @@ In a file explorer window right click in or on a directory to see "Cmder Here" i
### Tab manipulation
* `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)
* `Shift + alt + number` : fast new tab: `1` - CMD, `2` - Powershell `*` - More to come
* `Alt + enter`: Fullscreen
* <kbd>Ctrl</kbd> + <kbd>T</kbd> : New tab dialog (maybe you want to open cmd as admin?)
* <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>Alt</kbd> + <kbd>Enter</kbd>: Fullscreen
### Shell
* `Shift + Up` : Traverse up in directory structure (lovely feature!)
* `End, Home, Ctrl` : Traversing text with as usual on Windows
* `Ctrl + r` : History search
* `Shift + mouse` : Select and copy text from buffer
* <kbd>Shift</kbd> + <kbd>Up</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
(Some shortcuts are not yet documented, thought they exist - please document them here)
(Some shortcuts are not yet documented, though they exist - please document them here)
## Features
### Access to multiple shells in one window using tabs
You can open multiple tabs each containing one of the following shells:
|Task|Shell|Description|
|----|-----|-----------|
|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.|
|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.
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/).
An example of setting Cmder portable terminal colors for mintty:
From a bash/mintty shell:
```
cd $CMDER_ROOT/vendor
git clone https://github.com/karlin/mintty-colors-solarized.git
cd mintty-colors-solarized/
echo source \$CMDER_ROOT/vendor/mintty-colors-solarized/mintty-solarized-dark.sh>>$CMDER_ROOT/config/user-profile.sh
```
### Cmder Portable Shell User Config
User specific configuration is possible using the cmder specific shell config files. Edit the below files to add your own configuration:
|Shell|Cmder Portable User Config|
| ------------- |:-------------:|
|Cmder|%CMDER_ROOT%\config\user-profile.cmd|
|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'.
### Aliases
You can define simple aliases with command `alias name=command`.
#### Cmder(Cmd.exe) Aliases
You can define simple aliases for `cmd.exe` sessions with a command like `alias name=command`. Cmd.exe aliases support optional parameters through the `$1-9` or the `$*` special characters so the alias `vi=vim.exe $*` typed as `vi [filename]` will open `[filename]` in `vim.exe`.
For example there is one defined for you `alias e.=explorer .`
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'
All aliases will be saved in `/config/aliases` file
Aliases defined using the `alias.bat` command will automatically be saved in the `%CMDER_ROOT%\config\aliases` file
#### 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`.
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.
### SSH Agent
To start SSH agent simply call `agent`, which is in the `bin` folder.
To start SSH agent simply call `start-ssh-agent`, which is in the `vendor/git-for-windows/cmd` folder.
If you want to run SSH agent on startup, uncomment the line in `/vendor/init.bat`so it says `@call "%CMDER_ROOT%/bin/agent.cmd"`.
If you want to run SSH agent on startup, include the line `@call "%GIT_INSTALL_ROOT%/cmd/start-ssh-agent.cmd"` in `%CMDER_ROOT%/config/user-profile.cmd` (usually just uncomment it).
## Todo
1. Git Bash
2. Check for clink and git before injecting them (Sort of done)
1. Check for clink and git before injecting them (Sort of done)
## Current development branch

57
appveyor.yml Normal file
View File

@ -0,0 +1,57 @@
#---------------------------------#
# general configuration #
#---------------------------------#
version: 1.0.{build}-{branch}
# branches to build
branches:
# blacklist
except:
- gh-pages
#---------------------------------#
# environment configuration #
#---------------------------------#
# Operating system (build VM template)
os: Windows Server 2012 R2
#---------------------------------#
# build configuration #
#---------------------------------#
build_script:
- ps: cd scripts; .\build.ps1 -Compile -verbose
after_build:
- ps: .\pack.ps1 -verbose
# Disable test search, since we don't have any.
test: off
#---------------------------------#
# artifacts #
#---------------------------------#
artifacts:
- path: build\cmder.zip
name: cmderzip
- path: build\cmder.7z
name: cmder7z
- path: build\cmder_mini.zip
name: cmdermini
#---------------------------------#
# notifications #
#---------------------------------#
notifications:
# Webhook
- provider: Webhook
url: https://webhooks.gitter.im/e/d673abb1b2e659dcd625
on_build_success: true
on_build_failure: true
on_build_status_changed: true

View File

@ -1,46 +0,0 @@
@ECHO OFF
REM Set default sock file
SET SSH_AUTH_SOCK=/tmp/ssh-agent.sock
REM Check socket is available
IF NOT EXIST "%TMP%\ssh-agent.sock" GOTO:RUNAGENT
REM Check if an ssh-agent is running
FOR /f "tokens=*" %%I IN ('ps ^| grep ssh-agent ^| sed "s/^ *\([0-9]\+\) .*/\1/"') DO SET VAR=%%I
IF "%VAR%" == "" GOTO:RUNAGENT
REM Check if socket file is valid
ssh-add -l 1> NUL 2>&1
IF ERRORLEVEL 1 GOTO:RUNAGENT
GOTO:ADDKEYS
:RUNAGENT
REM Remove old socket file
rm -f /tmp/ssh-agent.sock
REM Run ssh-agent and save (last) PID in VAR
SET VAR=
FOR /f "tokens=*" %%J IN ('ssh-agent -a /tmp/ssh-agent.sock') DO FOR /f "tokens=*" %%K IN ('echo %%J ^| grep "SSH_AGENT_PID" ^| sed "s/^SSH_AGENT_PID=\([0-9]\+\); .*/\1/"') DO SET VAR=%%K
:ADDKEYS
SET SSH_AUTH_PID=%VAR%
REM Check if ssh keys are known
SET KEYS=
FOR /f "tokens=*" %%I IN ('DIR /B "%HOME%\.ssh\*_rsa"') DO CALL:CHECKKEY %%I
REM Add missing ssh keys at once
IF NOT "%KEYS%" == "" ssh-add %KEYS%
GOTO:END
REM Functions
REM Check if ssh key has to be added
:CHECKKEY
SET VAR=
FOR /f "tokens=*" %%J IN ('ssh-add -l ^| grep "%1"') DO SET VAR=%%J
IF "%VAR%" == "" SET KEYS='%HOME%\.ssh\%1' %KEYS%
GOTO:EOF
:END
@ECHO ON

View File

@ -1,8 +1,13 @@
@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 ["%*"] == [""] 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
@ -13,20 +18,18 @@ if ["%2"] == [""] (
echo Insufficient parameters. & goto:p_help
)
::validate alias
setlocal
for /f "delims== tokens=1" %%G in ("%*") do set _temp2=%%G
:: validate alias
for /f "delims== tokens=1" %%G in ("%_x%") do set alias=%%G
set _temp=%alias: =%
set _temp=%_temp2: =%
if not ["%_temp%"] == ["%_temp2%"] (
if not ["%_temp%"] == ["%alias%"] (
echo Your alias name can not contain a space
endlocal
goto:eof
)
:: replace already defined alias
findstr /b /v /i "%_temp%=" "%ALIASES%" >> "%ALIASES%.tmp"
findstr /b /v /i "%alias%=" "%ALIASES%" >> "%ALIASES%.tmp"
echo %* >> "%ALIASES%.tmp" && type "%ALIASES%.tmp" > "%ALIASES%" & @del /f /q "%ALIASES%.tmp"
doskey /macrofile="%ALIASES%"
endlocal

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<key name="Software">
<key name="ConEmu">
<key name=".Vanilla" modified="2015-05-17 22:10:27" build="150513">
<key name=".Vanilla" modified="2015-11-24 14:43:35" build="151119">
<value name="ColorTable00" type="dword" data="00222827"/>
<value name="ColorTable01" type="dword" data="009e5401"/>
<value name="ColorTable02" type="dword" data="0004aa74"/>
@ -72,12 +72,12 @@
<value name="StartType" type="hex" data="02"/>
<value name="CmdLine" type="string" data=""/>
<value name="StartTasksFile" type="string" data=""/>
<value name="StartTasksName" type="string" data="{PowerShell}"/>
<value name="StartTasksName" type="string" data="{cmd::Cmder}"/>
<value name="StartFarFolders" type="hex" data="00"/>
<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:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\"/></value>
<value name="CmdLineHistory" type="multi"></value>
<value name="SingleInstance" type="hex" data="00"/>
<value name="ShowHelpTooltips" type="hex" data="01"/>
<value name="Multi" type="hex" data="01"/>
@ -124,13 +124,13 @@
<value name="ColorKeyValue" type="dword" data="00010101"/>
<value name="UseCurrentSizePos" type="hex" data="01"/>
<value name="WindowMode" type="dword" data="0000051f"/>
<value name="ConWnd Width" type="dword" data="0000006f"/>
<value name="ConWnd Height" type="dword" data="0000001a"/>
<value name="ConWnd Width" type="dword" data="00000078"/>
<value name="ConWnd Height" type="dword" data="0000001e"/>
<value name="Cascaded" type="hex" data="01"/>
<value name="ConWnd X" type="dword" data="000003f8"/>
<value name="ConWnd Y" type="dword" data="00000143"/>
<value name="ConWnd X" type="dword" data="000001f4"/>
<value name="ConWnd Y" type="dword" data="000001f4"/>
<value name="16bit Height" type="dword" data="00000000"/>
<value name="AutoSaveSizePos" type="hex" data="00"/>
<value name="AutoSaveSizePos" type="hex" data="01"/>
<value name="IntegralSize" type="hex" data="00"/>
<value name="QuakeStyle" type="hex" data="00"/>
<value name="QuakeAnimation" type="dword" data="0000012c"/>
@ -483,51 +483,89 @@
<value name="DndLKey" type="hex" data="00"/>
<value name="DndRKey" type="hex" data="a2"/>
<value name="WndDragKey" type="dword" data="00121101"/>
<key name="Tasks" modified="2015-05-17 22:10:27" build="150513">
<value name="Count" type="dword" data="00000003"/>
<key name="Task1" modified="2015-05-17 22:10:27" build="150513">
<value name="Name" type="string" data="{cmd}"/>
<value name="GuiArgs" type="string" data="/icon &quot;%CMDER_ROOT%\cmder.exe&quot;"/>
<key name="Tasks" modified="2015-11-24 14:43:35" build="151119">
<value name="Count" type="dword" data="00000008"/>
<key name="Task1" modified="2015-11-24 14:49:10" build="151119">
<value name="Name" type="string" data="{cmd::Cmder as Admin}"/>
<value name="GuiArgs" type="string" data=" /icon &quot;%CMDER_ROOT%\icons\cmder.ico&quot;"/>
<value name="Cmd1" type="string" data="*cmd /k &quot;%ConEmuDir%\..\init.bat&quot; -new_console:d:%USERPROFILE%"/>
<value name="Active" type="dword" data="00000000"/>
<value name="Count" type="dword" data="00000001"/>
<value name="Hotkey" type="dword" data="00000000"/>
<value name="Flags" type="dword" data="00000000"/>
</key>
<key name="Task2" modified="2015-11-24 14:49:10" build="151119">
<value name="Name" type="string" data="{cmd::Cmder}"/>
<value name="GuiArgs" type="string" data=" /icon &quot;%CMDER_ROOT%\icons\cmder.ico&quot;"/>
<value name="Cmd1" type="string" data="cmd /k &quot;%ConEmuDir%\..\init.bat&quot; -new_console:d:%USERPROFILE%"/>
<value name="Active" type="dword" data="00000000"/>
<value name="Count" type="dword" data="00000001"/>
<value name="Hotkey" type="dword" data="00000000"/>
<value name="Flags" type="dword" data="00000000"/>
</key>
<key name="Task2" modified="2015-05-17 22:10:27" build="150513">
<value name="Name" type="string" data="{PowerShell}"/>
<value name="GuiArgs" type="string" data="/icon &quot;%CMDER_ROOT%\cmder.exe&quot;"/>
<value name="Cmd1" type="string" data="PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command &quot;Invoke-Expression '. ''%ConEmuDir%\..\profile.ps1'''&quot; -new_console:d:&quot;%USERPROFILE%&quot;"/>
<value name="Active" type="dword" data="00000000"/>
<value name="Count" type="dword" data="00000001"/>
<key name="Task3" modified="2015-11-24 14:49:10" build="151119">
<value name="Name" type="string" data="{Powershell::PowerShell as Admin}"/>
<value name="Hotkey" type="dword" data="00000000"/>
<value name="Flags" type="dword" data="00000000"/>
</key>
<key name="Task3" modified="2015-05-17 22:10:27" build="150513">
<value name="Name" type="string" data="{PowerShell as Admin}"/>
<value name="Hotkey" type="dword" data="00000000"/>
<value name="GuiArgs" type="string" data="/icon &quot;%CMDER_ROOT%\cmder.exe&quot;"/>
<value name="GuiArgs" type="string" data=" /icon &quot;%CMDER_ROOT%\icons\cmder.ico&quot;"/>
<value name="Cmd1" type="string" data="*PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command &quot;Invoke-Expression '. ''%ConEmuDir%\..\profile.ps1'''&quot; -new_console:d:&quot;%USERPROFILE%&quot;"/>
<value name="Active" type="dword" data="00000000"/>
<value name="Count" type="dword" data="00000001"/>
<value name="Flags" type="dword" data="00000000"/>
</key>
<key name="Task4" modified="2015-02-24 18:49:50" build="140707">
<value name="Name" type="string" data="{git sh}"/>
<key name="Task4" modified="2015-11-24 14:49:10" build="151119">
<value name="Name" type="string" data="{Powershell::Powershell}"/>
<value name="Hotkey" type="dword" data="00000000"/>
<value name="GuiArgs" type="string" data=" /icon &quot;%CMDER_ROOT%\cmder.exe&quot;"/>
<value name="Cmd1" type="string" data="cmd /k &quot;%ConEmuDir%\..\init.bat &amp; %CMDER_ROOT%\vendor\msysgit\bin\bash --login -i&quot; -new_console:d:%USERPROFILE%"/>
<value name="Cmd2" type="string" data="%CMDER_ROOT%\vendor\msysgit\git-bash.bat"/>
<value name="GuiArgs" type="string" data=" /icon &quot;%CMDER_ROOT%\icons\cmder.ico&quot;"/>
<value name="Cmd1" type="string" data="PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command &quot;Invoke-Expression '. ''%ConEmuDir%\..\profile.ps1'''&quot; -new_console:d:&quot;%USERPROFILE%&quot;"/>
<value name="Cmd2" type="string" data="%CMDER_ROOT%\vendor\git-for-windows\git-bash.exe"/>
<value name="Active" type="dword" data="00000000"/>
<value name="Count" type="dword" data="00000001"/>
<value name="Flags" type="dword" data="00000000"/>
</key>
<key name="Task5" modified="2015-11-24 14:49:10" build="151119">
<value name="Name" type="string" data="{bash::mintty as Admin}"/>
<value name="Flags" type="dword" data="00000000"/>
<value name="Hotkey" type="dword" data="00000000"/>
<value name="GuiArgs" type="string" data="/icon &quot;%ConEmuDir%\..\git-for-windows\usr\share\git\git-for-windows.ico&quot;"/>
<value name="Cmd1" type="string" data="*%ConEmuDir%\..\git-for-windows\usr\bin\mintty.exe /bin/bash -l -new_console:d:%USERPROFILE%"/>
<value name="Active" type="dword" data="00000000"/>
<value name="Count" type="dword" data="00000001"/>
</key>
<key name="Task6" modified="2015-11-24 14:49:10" build="151119">
<value name="Name" type="string" data="{bash::mintty}"/>
<value name="Flags" type="dword" data="00000000"/>
<value name="Hotkey" type="dword" data="00000000"/>
<value name="GuiArgs" type="string" data="/icon &quot;%ConEmuDir%\..\git-for-windows\usr\share\git\git-for-windows.ico&quot;"/>
<value name="Cmd1" type="string" data="%ConEmuDir%\..\git-for-windows\usr\bin\mintty.exe /bin/bash -l -new_console:d:%userProfile%"/>
<value name="Active" type="dword" data="00000000"/>
<value name="Count" type="dword" data="00000001"/>
<value name="Cmd2" type="string" data="%CMDER_ROOT%vendor\git-for-windows\usr\bin\mintty.exe /bin/bash -l -new_console:d:%userProfile%"/>
</key>
<key name="Task7" modified="2015-11-24 14:49:10" build="151119">
<value name="Name" type="string" data="{bash::bash as Admin}"/>
<value name="Flags" type="dword" data="00000000"/>
<value name="Hotkey" type="dword" data="00000000"/>
<value name="GuiArgs" type="string" data=" /icon &quot;%CMDER_ROOT%\icons\cmder.ico&quot;"/>
<value name="Active" type="dword" data="00000000"/>
<value name="Count" type="dword" data="00000001"/>
<value name="Cmd1" type="string" data="*cmd /c &quot;%ConEmuDir%\..\git-for-windows\bin\bash --login -i&quot; -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 &quot;%CMDER_ROOT%\icons\cmder.ico&quot;"/>
<value name="Cmd1" type="string" data="cmd /c &quot;%ConEmuDir%\..\git-for-windows\bin\bash --login -i&quot; -new_console:d:%USERPROFILE%"/>
<value name="Active" type="dword" data="00000000"/>
<value name="Count" type="dword" data="00000001"/>
</key>
</key>
<key name="Apps" modified="2015-05-17 22:10:27" build="150513">
<key name="Apps" modified="2015-11-24 14:49:10" build="151119">
<value name="Count" type="dword" data="00000000"/>
</key>
<key name="Colors" modified="2015-05-17 22:10:27" build="150513">
<key name="Palette1" modified="2015-05-17 22:10:27" build="150513">
<key name="Colors" modified="2015-11-24 14:49:10" build="151119">
<key name="Palette1" modified="2015-11-24 14:49:10" build="151119">
<value name="Name" type="string" data="Monokai"/>
<value name="ExtendColors" type="hex" data="00"/>
<value name="ExtendColorIdx" type="hex" data="0e"/>
@ -628,7 +666,7 @@
<value name="StatusBar.Hide.Dpi" type="hex" data="01"/>
<value name="TabFlashChanged" type="dword" data="00000008"/>
<value name="TabModifiedSuffix" type="string" data="[*]"/>
<key name="HotKeys" modified="2015-05-17 22:10:27" build="150513">
<key name="HotKeys" modified="2015-11-24 14:43:35" build="151119">
<value name="KeyMacroVersion" type="hex" data="02"/>
<value name="Multi.Modifier" type="dword" data="00000011"/>
<value name="Multi.ArrowsModifier" type="dword" data="0000005b"/>
@ -734,27 +772,27 @@
<value name="PastePathKey" type="dword" data="00101144"/>
<value name="PasteCygwinKey" type="dword" data="00005d2d"/>
<value name="KeyMacro01" type="dword" data="00a01231"/>
<value name="KeyMacro01.Text" type="string" data="Task(&quot;cmd&quot;)"/>
<value name="KeyMacro01.Text" type="string" data="Task(1)"/>
<value name="KeyMacro02" type="dword" data="00a01232"/>
<value name="KeyMacro02.Text" type="string" data="Task(&quot;PowerShell&quot;)"/>
<value name="KeyMacro02.Text" type="string" data="Task(2)"/>
<value name="KeyMacro03" type="dword" data="000011d0"/>
<value name="KeyMacro03.Text" type="string" data="FontSetSize(1,2)"/>
<value name="KeyMacro04" type="dword" data="000011d1"/>
<value name="KeyMacro04.Text" type="string" data="FontSetSize(1,-2)"/>
<value name="KeyMacro05" type="dword" data="00a01233"/>
<value name="KeyMacro05.Text" type="string" data="Task(&quot;PowerShell as Admin&quot;)"/>
<value name="KeyMacro06" type="dword" data="00000000"/>
<value name="KeyMacro06.Text" type="string" data=""/>
<value name="KeyMacro07" type="dword" data="00000000"/>
<value name="KeyMacro07.Text" type="string" data=""/>
<value name="KeyMacro08" type="dword" data="00000000"/>
<value name="KeyMacro08.Text" type="string" data=""/>
<value name="KeyMacro09" type="dword" data="00000000"/>
<value name="KeyMacro09.Text" type="string" data=""/>
<value name="KeyMacro10" type="dword" data="00000000"/>
<value name="KeyMacro10.Text" type="string" data=""/>
<value name="KeyMacro11" type="dword" data="00000000"/>
<value name="KeyMacro11.Text" type="string" data=""/>
<value name="KeyMacro05.Text" type="string" data="Task(3)"/>
<value name="KeyMacro06" type="dword" data="00a01234"/>
<value name="KeyMacro06.Text" type="string" data="Task(4)"/>
<value name="KeyMacro07" type="dword" data="00a01235"/>
<value name="KeyMacro07.Text" type="string" data="Task(5)"/>
<value name="KeyMacro08" type="dword" data="00a01236"/>
<value name="KeyMacro08.Text" type="string" data="Task(6)"/>
<value name="KeyMacro09" type="dword" data="00a01237"/>
<value name="KeyMacro09.Text" type="string" data="Task(7)"/>
<value name="KeyMacro10" type="dword" data="00a01238"/>
<value name="KeyMacro10.Text" type="string" data="Task(8)"/>
<value name="KeyMacro11" type="dword" data="00a01239"/>
<value name="KeyMacro11.Text" type="string" data="Task(9)"/>
<value name="KeyMacro12" type="dword" data="00000000"/>
<value name="KeyMacro12.Text" type="string" data=""/>
<value name="KeyMacro13" type="dword" data="00000000"/>
@ -805,7 +843,20 @@
<value name="DndLKey" type="hex" data="00"/>
<value name="DndRKey" type="hex" data="a2"/>
<value name="WndDragKey" type="dword" data="00121101"/>
<value name="Multi.Unfasten" type="dword" data="00000000"/>
<value name="Key.DebugProcess" type="dword" data="00105b44"/>
<value name="Key.DumpProcess" type="dword" data="00000000"/>
<value name="Key.DumpTree" type="dword" data="00000000"/>
</key>
<value name="StartCreateDelay" type="dword" data="00000064"/>
<value name="DefaultTerminalDebugLog" type="hex" data="00"/>
<value name="LastMonitor" type="string" data="0,0,1920,1020"/>
<value name="Restore2ActiveMon" type="hex" data="00"/>
<value name="DownShowExOnTopMessage" type="hex" data="00"/>
<value name="EnvironmentSet" type="multi"/>
<value name="Update.InetTool" type="hex" data="00"/>
<value name="Update.InetToolCmd" type="string" data=""/>
<value name="SuppressBells" type="hex" data="01"/>
</key>
</key>
</key>

View File

@ -1,3 +1,14 @@
## Config
All config files must be in this folder. If there is no option to create or read from this folder directly, it must be hardlinked.
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 completitions and prompt filters; called from vendor\cmder.lua after all
other prompt filter and clink completitons 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

View File

@ -1,43 +0,0 @@
# name: Ctrl-D exits
# type: bool
# Ctrl-D exits the process when it is pressed on an empty line.
ctrld_exits = 1
# name: Ctrl-C raises exception
# type: bool
# When Ctrl-C is pressed Clink will pass it thourgh to the parent by raising the
# appropriate exception.
passthrough_ctrlc = 1
# name: Esc clears line
# type: bool
# Clink clears the current line when Esc is pressed (unless Readline's Vi mode
# is enabled).
esc_clears_line = 1
# name: Match display colour
# type: int
# Colour to use when displaying matches. A value less than 0 will be the
# opposite brightness of the default colour.
match_colour = -1
# name: Executable match style
# type: enum
# Changes how Clink will match executables when there is no path separator on
# the line. 0 = PATH only, 1 = PATH and CWD, 2 = PATH, CWD, and directories. In
# all cases both executables and directories are matched when there is a path
# separator present.
exec_match_style = 2
# name: Prompt colour
# type: int
# Surrounds the prompt in ANSI escape codes to set the prompt's colour. Disabled
# when the value is less than 0.
prompt_colour = -1
# name: Auto-answer terminate prompt
# type: enum
# Automatically answers cmd.exe's 'Terminate batch job (Y/N)?' prompts. 0 =
# disabled, 1 = answer 'Y', 2 = answer 'N'.
terminate_autoanswer = 0

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22823.1
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CmderLauncher", "CmderLauncher.vcxproj", "{4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}"
EndProject

View File

@ -14,7 +14,6 @@
<ProjectGuid>{4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>CmderLauncher</RootNamespace>
<TargetPlatformVersion>8.1</TargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@ -73,6 +72,7 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -85,7 +85,9 @@
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ResourceCompile Include="src\Resource.rc" />
<ResourceCompile Include="src\Resource.rc">
<FileType>RC</FileType>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\resource.h" />

View File

@ -3,6 +3,8 @@
#include <Shlwapi.h>
#include "resource.h"
#include <vector>
#include <Shlobj.h>
#pragma comment(lib, "Shlwapi.lib")
@ -18,7 +20,7 @@
#define SHELL_MENU_REGISTRY_PATH_BACKGROUND L"Directory\\Background\\shell\\Cmder"
#define SHELL_MENU_REGISTRY_PATH_LISTITEM L"Directory\\shell\\Cmder"
#define streqi(a, b) (_wcsicmp((a), (b)) == 0)
#define streqi(a, b) (_wcsicmp((a), (b)) == 0)
#define WIDEN2(x) L ## x
#define WIDEN(x) WIDEN2(x)
@ -29,7 +31,7 @@
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,
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.";
@ -63,10 +65,12 @@ optpair GetOption()
if (argc == 1)
{
// no commandline argument...
pair = optpair(L"/START", L"");
}
else if (argc == 2 && argv[1][0] != L'/')
{
// only a single argument: this should be a path...
pair = optpair(L"/START", argv[1]);
}
else
@ -79,6 +83,19 @@ optpair GetOption()
return pair;
}
bool FileExists(const wchar_t * filePath)
{
HANDLE hFile = CreateFile(filePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if (hFile != INVALID_HANDLE_VALUE)
{
CloseHandle(hFile);
return true;
}
return false;
}
void StartCmder(std::wstring path, bool is_single_mode)
{
#if USE_TASKBAR_API
@ -87,6 +104,7 @@ void StartCmder(std::wstring path, bool is_single_mode)
wchar_t exeDir[MAX_PATH] = { 0 };
wchar_t icoPath[MAX_PATH] = { 0 };
wchar_t cfgPath[MAX_PATH] = { 0 };
wchar_t oldCfgPath[MAX_PATH] = { 0 };
wchar_t conEmuPath[MAX_PATH] = { 0 };
wchar_t args[MAX_PATH * 2 + 256] = { 0 };
@ -99,20 +117,63 @@ void StartCmder(std::wstring path, bool is_single_mode)
PathRemoveFileSpec(exeDir);
PathCombine(icoPath, exeDir, L"icons\\cmder.ico");
PathCombine(cfgPath, exeDir, L"config\\ConEmu.xml");
// Check for machine-specific config file.
PathCombine(oldCfgPath, exeDir, L"config\\ConEmu-%COMPUTERNAME%.xml");
ExpandEnvironmentStrings(oldCfgPath, oldCfgPath, sizeof(oldCfgPath) / sizeof(oldCfgPath[0]));
if (!PathFileExists(oldCfgPath)) {
PathCombine(oldCfgPath, exeDir, L"config\\ConEmu.xml");
}
// Check for machine-specific config file.
PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu-%COMPUTERNAME%.xml");
ExpandEnvironmentStrings(cfgPath, cfgPath, sizeof(cfgPath) / sizeof(cfgPath[0]));
if (!PathFileExists(cfgPath)) {
PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.xml");
}
PathCombine(conEmuPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.exe");
if (is_single_mode)
if (FileExists(oldCfgPath) && !FileExists(cfgPath))
{
swprintf_s(args, L"/single /Icon \"%s\" /Title Cmder /LoadCfgFile \"%s\"", icoPath, cfgPath);
if (!CopyFile(oldCfgPath, cfgPath, FALSE))
{
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
? L"Failed to copy ConEmu.xml file to new location! Restart cmder as administrator."
: L"Failed to copy ConEmu.xml file to new location!", MB_TITLE, MB_ICONSTOP);
exit(1);
}
}
else
if (is_single_mode)
{
swprintf_s(args, L"/Icon \"%s\" /Title Cmder /LoadCfgFile \"%s\"", icoPath, cfgPath);
swprintf_s(args, L"/single /Icon \"%s\" /Title Cmder", icoPath);
}
else
{
swprintf_s(args, L"/Icon \"%s\" /Title Cmder", icoPath);
}
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
SetEnvironmentVariable(L"CMDER_START", path.c_str());
if (streqi(path.c_str(), L""))
{
wchar_t* homeProfile = 0;
SHGetKnownFolderPath(FOLDERID_Profile, 0, NULL, &homeProfile);
if (!SetEnvironmentVariable(L"CMDER_START", homeProfile)) {
MessageBox(NULL, _T("Error trying to set CMDER_START to given path!"), _T("Error"), MB_OK);
}
CoTaskMemFree(static_cast<void*>(homeProfile));
}
else
{
if (!SetEnvironmentVariable(L"CMDER_START", path.c_str())) {
MessageBox(NULL, _T("Error trying to set CMDER_START to given path!"), _T("Error"), MB_OK);
}
}
// Ensure EnvironmentVariables are propagated.
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment", SMTO_ABORTIFHUNG, 5000, NULL);
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) L"Environment", SMTO_ABORTIFHUNG, 5000, NULL); // For Windows >= 8
STARTUPINFO si = { 0 };
si.cb = sizeof(STARTUPINFO);
@ -122,8 +183,10 @@ void StartCmder(std::wstring path, bool is_single_mode)
#endif
PROCESS_INFORMATION pi;
CreateProcess(conEmuPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi);
if (!CreateProcess(conEmuPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi)) {
MessageBox(NULL, _T("Unable to create the ConEmu Process!"), _T("Error"), MB_OK);
return;
}
}
bool IsUserOnly(std::wstring opt)

View File

@ -4,6 +4,18 @@ launcher
.git
*.rb
build
scripts
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
Cmder.bat
vendor\tmp
appveyor.yml
vendor\cmder.sh
vendor\git-prompt.sh
config\user-*

View File

@ -11,11 +11,11 @@
.EXAMPLE
.\build.ps1
Executes the default build for cmder; Conemu, clink. This is equivalent to the "minimum" style package in the releases
Executes the default build for Cmder; Conemu, clink. This is equivalent to the "minimum" style package in the releases
.EXAMPLE
.\build.ps1 -Full
.\build.ps1 -Compile
Executes a full build for cmder, including git. This is equivalent to the "full" style package in the releases
Recompile the launcher executable if you have the requisite build tools for C++ installed.
.EXAMPLE
.\build -verbose
@ -29,7 +29,7 @@
Samuel Vasko, Jack Bennett
Part of the Cmder project.
.LINK
https://github.com/bliker/cmder - Project Home
http://cmder.net/ - Project Home
#>
[CmdletBinding(SupportsShouldProcess=$true)]
Param(
@ -46,11 +46,15 @@ Param(
# Launcher folder location
[string]$launcher = "..\launcher",
# Include git with the package build
[switch]$Full
# Config folder location
[string]$config = "..\config",
# New launcher if you have MSBuild tools installed
[switch]$Compile
)
. "$PSScriptRoot\utils.ps1"
# Dot source util functions into this scope
. ".\utils.ps1"
$ErrorActionPreference = "Stop"
Push-Location -Path $saveTo
@ -61,11 +65,18 @@ Ensure-Exists $sourcesPath
Ensure-Executable "7z"
New-Item -Type Directory -Path (Join-Path $saveTo "/tmp/") -ErrorAction SilentlyContinue >$null
foreach ($s in $sources) {
if($Full -eq $false -and $s.name -eq "msysgit"){
Continue
}
# Preserve modified (by user) ConEmu setting file
if ($config -ne "") {
$ConEmuXml = Join-Path $saveTo "conemu-maximus5\ConEmu.xml"
if (Test-Path $ConEmuXml -pathType leaf) {
$ConEmuXmlSave = Join-Path $config "ConEmu.xml"
Write-Verbose "Backup '$ConEmuXml' to '$ConEmuXmlSave'"
Copy-Item $ConEmuXml $ConEmuXmlSave
} else { $ConEmuXml = "" }
} else { $ConEmuXml = "" }
$vend = $pwd
foreach ($s in $sources) {
Write-Verbose "Getting $($s.name) from URL $($s.url)"
# We do not care about the extensions/type of archive
@ -73,7 +84,7 @@ foreach ($s in $sources) {
Delete-Existing $tempArchive
Delete-Existing $s.name
Invoke-WebRequest -Uri $s.url -OutFile $tempArchive -ErrorAction Stop
Download-File -Url $s.url -File $vend\$tempArchive -ErrorAction Stop
Extract-Archive $tempArchive $s.name
if ((Get-Childitem $s.name).Count -eq 1) {
@ -83,10 +94,37 @@ foreach ($s in $sources) {
"$($s.version)" | Out-File "$($s.name)/.cmderver"
}
# Restore user configuration
if ($ConEmuXml -ne "") {
Write-Verbose "Restore '$ConEmuXmlSave' to '$ConEmuXml'"
Copy-Item $ConEmuXmlSave $ConEmuXml
}
Pop-Location
Push-Location -Path $launcher
msbuild CmderLauncher.vcxproj /p:configuration=Release
Pop-Location
if($Compile) {
Push-Location -Path $launcher
msbuild CmderLauncher.vcxproj /p:configuration=Release
if ($LastExitCode -ne 0) {
throw "msbuild failed to build the executable."
}
Pop-Location
} else {
Write-Warning "You are not building a launcher, Use -Compile"
Write-Warning "This cannot be a release. Test build only!"
}
# Put vendor\cmder.sh in /etc/profile.d so it runs when we start bash or mintty
if ( (Test-Path $($SaveTo + "git-for-windows/etc/profile.d") ) ) {
write-verbose "Adding cmder.sh /etc/profile.d"
Copy-Item $($SaveTo + "cmder.sh") $($SaveTo + "git-for-windows/etc/profile.d/cmder.sh")
}
# Replace /etc/profile.d/git-prompt.sh with cmder lambda prompt so it runs when we start bash or mintty
if ( !(Test-Path $($SaveTo + "git-for-windows/etc/profile.d/git-prompt.sh.bak") ) ) {
write-verbose "Replacing /etc/profile.d/git-prompt.sh with our git-prompt.sh"
Move-Item $($SaveTo + "git-for-windows/etc/profile.d/git-prompt.sh") $($SaveTo + "git-for-windows/etc/profile.d/git-prompt.sh.bak")
Copy-Item $($SaveTo + "git-prompt.sh") $($SaveTo + "git-for-windows/etc/profile.d/git-prompt.sh")
}
Write-Verbose "All good and done!"

View File

@ -19,7 +19,7 @@
Samuel Vasko, Jack Bennett, Martin Kemp
Part of the Cmder project.
.LINK
https://github.com/bliker/cmder - Project Home
https://github.com/cmderdev/cmder - Project Home
#>
[CmdletBinding(SupportsShouldProcess=$true)]
@ -42,11 +42,11 @@ Ensure-Executable "7z"
$targets = @{
"cmder.zip" = $null;
"cmder.7z" = $null;
"cmder_mini.zip" = "-x!`"vendor\msysgit`"";
"cmder_mini.zip" = "-x!`"vendor\git-for-windows`"";
}
Delete-Existing "..\Version*"
Cleanup-Git
Delete-Existing "..\build\*"
$version = Invoke-Expression "git describe --abbrev=0 --tags"
(New-Item -ItemType file "$cmderRoot\Version $version") | Out-Null

View File

@ -61,11 +61,6 @@ function Digest-MD5 ($path) {
return Invoke-Expression "md5sum $path"
}
function Cleanup-Git () {
$gitdir = '../vendor/msysgit/libexec/git-core/'
Get-Childitem $gitdir -Exclude git.exe | Where-Object{!($_.PSIsContainer)} | Foreach-Object { Remove-Item $_.FullName }
}
function Register-Cmder(){
[CmdletBinding()]
Param
@ -94,3 +89,16 @@ function Register-Cmder(){
New-Item -Path "HKCR:\Directory\Shell\Cmder\Command" -Force -Value "`"$PathToExe`" `"$Command`" "
}
}
function Download-File {
param (
$Url,
$File
)
# I think this is the problem
$File = $File -Replace "/", "\"
Write-Verbose "Downloading from $Url to $File"
$wc = new-object System.Net.WebClient
$wc.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials;
$wc.DownloadFile($Url, $File)
}

View File

@ -5,3 +5,4 @@ pwd=cd
clear=cls
history=cat %CMDER_ROOT%\config\.history
unalias=alias /d $1
vi=vim $*

View File

@ -1,3 +1,17 @@
-- default script for clink, called by init.bat when injecting clink
-- !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED
-- !!! Use "%CMDER_ROOT%\config\<whatever>.lua" to add your lua startup scripts
-- At first, load the original clink.lua file
-- this is needed as we set the script path to this dir and therefore the original
-- clink.lua is not loaded.
local clink_lua_file = clink.get_env('CMDER_ROOT')..'\\vendor\\clink\\clink.lua'
dofile(clink_lua_file)
-- now add our own things...
function lambda_prompt_filter()
clink.prompt.value = string.gsub(clink.prompt.value, "{lamb}", "λ")
end
@ -57,8 +71,45 @@ local function get_hg_dir(path)
return get_dir_contains(path, '.hg')
end
-- adapted from from clink-completions' git.lua
local function get_git_dir(path)
return get_dir_contains(path, '.git')
-- return parent path for specified entry (either file or directory)
local function pathname(path)
local prefix = ""
local i = path:find("[\\/:][^\\/:]*$")
if i then
prefix = path:sub(1, i-1)
end
return prefix
end
-- Checks if provided directory contains git directory
local function has_git_dir(dir)
return #clink.find_dirs(dir..'/.git') > 0 and dir..'/.git'
end
local function has_git_file(dir)
local gitfile = io.open(dir..'/.git')
if not gitfile then return false end
local git_dir = gitfile:read():match('gitdir: (.*)')
gitfile:close()
return git_dir and dir..'/'..git_dir
end
-- Set default path to current directory
if not path or path == '.' then path = clink.get_cwd() end
-- Calculate parent path now otherwise we won't be
-- able to do that inside of logical operator
local parent_path = pathname(path)
return has_git_dir(path)
or has_git_file(path)
-- Otherwise go up one level and make a recursive call
or (parent_path ~= path and get_git_dir(parent_path) or nil)
end
---
@ -118,17 +169,23 @@ end
---
-- Find out current branch
-- @return {false|git branch name}
-- @return {nil|git branch name}
---
function get_git_branch()
for line in io.popen("git branch 2>nul"):lines() do
local m = line:match("%* (.+)$")
if m then
return m
end
end
function get_git_branch(git_dir)
local git_dir = git_dir or get_git_dir()
return false
-- If git directory not found then we're probably outside of repo
-- or something went wrong. The same is when head_file is nil
local head_file = git_dir and io.open(git_dir..'/HEAD')
if not head_file then return end
local HEAD = head_file:read()
head_file:close()
-- if HEAD matches branch expression, then we're on named branch
-- otherwise it is a detached commit
local branch_name = HEAD:match('ref: refs/heads/(.+)')
return branch_name or 'HEAD detached at '..HEAD:sub(1, 7)
end
---
@ -136,7 +193,7 @@ end
-- @return {bool}
---
function get_git_status()
return os.execute("git diff --quiet --ignore-submodules HEAD 2>nul")
return io.popen("git diff --quiet --ignore-submodules HEAD 2>nul")
end
function git_prompt_filter()
@ -147,9 +204,10 @@ function git_prompt_filter()
dirty = "\x1b[31;1m",
}
if get_git_dir() then
local git_dir = get_git_dir()
if git_dir then
-- if we're inside of git repo then try to detect current branch
local branch = get_git_branch()
local branch = get_git_branch(git_dir)
if branch then
-- Has branch => therefore it is a git folder, now figure out status
if get_git_status() then
@ -181,4 +239,5 @@ for _,lua_module in ipairs(clink.find_files(completions_dir..'*.lua')) do
-- so config reloading using Alt-Q won't reload updated modules.
dofile(filename)
end
end
end

53
vendor/cmder.sh vendored Normal file
View File

@ -0,0 +1,53 @@
# DO NOT EDIT THIS FILE IT WILL BE OVERWRITTEN ON UPDATE
#
# Add portable user customizations ${CMDER_ROOT}/config/user-profile.sh,
# these customizations will follow Cmder if $CMDER_ROOT is copied
# to another machine.
#
# Add system specific users customizations to $HOME/.bashrc, these
# customizations will not follow Cmder to another machine.
# We do this for bash as admin sessions since $CMDER_ROOT is not being set
if [ "$CMDER_ROOT" == "" ] ; then
case "$ConEmuDir" in *\\*) CMDER_ROOT=$( cd "$(cygpath -u "$ConEmuDir")/../.." ; pwd );; esac
else
case "$CMDER_ROOT" in *\\*) CMDER_ROOT="$(cygpath -u "$CMDER_ROOT")";; esac
fi
# Remove any trailing '/'
CMDER_ROOT=$(echo $CMDER_ROOT | sed 's:/*$::')
export CMDER_ROOT
if [ -d "/c/Program Files/Git" ] ; then
GIT_INSTALL_ROOT="/c/Program Files/Git"
elif [ -d "/c/Program Files(x86)/Git" ] ; then
GIT_INSTALL_ROOT="/c/Program Files(x86)/Git"
elif [ -d "${CMDER_ROOT}/vendor/git-for-windows" ] ; then
GIT_INSTALL_ROOT=${CMDER_ROOT}/vendor/git-for-windows
fi
if [[ ! "$PATH" =~ "${GIT_INSTALL_ROOT}/bin:" ]] ; then
PATH=${GIT_INSTALL_ROOT}/bin:$PATH
fi
PATH=${CMDER_ROOT}/bin:$PATH:${CMDER_ROOT}
export PATH
if [ -f ${CMDER_ROOT}/config/user-profile.sh ] ; then
. ${CMDER_ROOT}/config/user-profile.sh
else
echo Creating user startup file: "${CMDER_ROOT}/config/user-profile.sh"
cat <<-eof >"${CMDER_ROOT}/config/user-profile.sh"
# use this file to run your own startup commands for msys2 bash'
# To add a new vendor to the path, do something like:
# export PATH=\${CMDER_ROOT}/vendor/whatever:\${PATH}
eof
fi
# Source the users .bashrc file if it exists
if [ -f "${HOME}/.bashrc" ] ; then
. "${HOME}/.bashrc"
fi

22
vendor/git-prompt.sh vendored Normal file
View File

@ -0,0 +1,22 @@
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"
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 λ

67
vendor/init.bat vendored
View File

@ -1,12 +1,17 @@
:: Init Script for cmd.exe
:: Sets some nice defaults
:: Created as part of cmder project
:: !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED
:: !!! Use "%CMDER_ROOT%\config\user-profile.cmd" to add your own startup commands
:: Find root dir
@if not defined CMDER_ROOT (
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
@ -18,10 +23,16 @@
set architecture=64
)
:: Run clink
@"%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_ROOT%\config"
:: 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.
)
:: Prepare for msysgit
:: Run clink
@"%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_ROOT%\config" --scripts "%CMDER_ROOT%\vendor"
:: Prepare for git-for-windows
:: I do not even know, copypasted from their .bat
@set PLINK_PROTOCOL=ssh
@ -32,32 +43,62 @@
set "GIT_INSTALL_ROOT=%ProgramFiles%\Git"
) else if exist "%ProgramFiles(x86)%\Git" (
set "GIT_INSTALL_ROOT=%ProgramFiles(x86)%\Git"
) else if exist "%CMDER_ROOT%\vendor" (
set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\msysgit"
) 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"
)
:: Add git to the path
@if defined GIT_INSTALL_ROOT (
set "PATH=%GIT_INSTALL_ROOT%\bin;%GIT_INSTALL_ROOT%\share\vim\vim74;%PATH%"
set "PATH=%GIT_INSTALL_ROOT%\bin;%GIT_INSTALL_ROOT%\usr\bin;%GIT_INSTALL_ROOT%\usr\share\vim\vim74;%PATH%"
:: 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"
)
:: Enhance Path
@set PATH=%CMDER_ROOT%\bin;%PATH%;%CMDER_ROOT%
@set "PATH=%CMDER_ROOT%\bin;%PATH%;%CMDER_ROOT%\"
:: 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
)
:: Add aliases
@doskey /macrofile="%CMDER_ROOT%\config\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....
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%
:: 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%"
) else (
@if "%CD%\" == "%CMDER_ROOT%" (
@cd /d "%HOME%"
)
)
:: @call "%CMDER_ROOT%/bin/agent.cmd"
@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"
) else (
@echo Creating user startup file: "%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.
) > "%CMDER_ROOT%\config\user-profile.cmd"
)

63
vendor/profile.ps1 vendored
View File

@ -1,4 +1,23 @@
# Add Cmder modules directory to the autoload path.
# Init Script for PowerShell
# Created as part of cmder project
# !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED
# !!! Use "%CMDER_ROOT%\config\user-profile.ps1" to add your own startup commands
# We do this for Powershell as Admin Sessions because CMDER_ROOT is not beng set.
if (! $ENV:CMDER_ROOT ) {
$ENV:CMDER_ROOT = resolve-path( $ENV:ConEmuDir + "\..\.." )
}
# Remove trailing '\'
$ENV:CMDER_ROOT = (($ENV:CMDER_ROOT).trimend("\"))
# Compatibility with PS major versions <= 2
if(!$PSScriptRoot) {
$PSScriptRoot = Split-Path $Script:MyInvocation.MyCommand.Path
}
# Add Cmder modules directory to the autoload path.
$CmderModulePath = Join-path $PSScriptRoot "psmodules/"
if( -not $env:PSModulePath.Contains($CmderModulePath) ){
@ -6,7 +25,26 @@ if( -not $env:PSModulePath.Contains($CmderModulePath) ){
}
try {
Get-command -Name "vim" -ErrorAction Stop >$null
} catch {
# # You could do this but it may be a little drastic and introduce a lot of
# # unix tool overlap with powershel unix like aliases
# $env:Path += $(";" + $env:CMDER_ROOT + "\vendor\git-for-windows\usr\bin")
# set-alias -name "vi" -value "vim"
# # I think the below is safer.
new-alias -name "vim" -value $($ENV:CMDER_ROOT + "\vendor\git-for-windows\usr\bin\vim.exe")
new-alias -name "vi" -value vim
}
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\bin")
}
try {
Import-Module -Name "posh-git" -ErrorAction Stop >$null
$gitStatus = $true
} catch {
@ -15,7 +53,7 @@ try {
}
function checkGit($Path) {
if (Test-Path -Path (Join-Path $Path '.git/') ) {
if (Test-Path -Path (Join-Path $Path '.git') ) {
Write-VcsStatus
return
}
@ -40,13 +78,24 @@ function global:prompt {
# Load special features come from posh-git
if ($gitStatus) {
Enable-GitColors
Start-SshAgent -Quiet
}
# Move to the wanted location
if (Test-Path Env:\CMDER_START) {
Set-Location -Path $Env:CMDER_START
} elseif ($Env:CMDER_ROOT -and $Env:CMDER_ROOT.StartsWith($pwd)) {
Set-Location -Path $Env: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 ( $ENV:CMDER_START ) {
Set-Location -Path "$ENV:CMDER_START"
}
# Enhance Path
$env:Path = "$Env:CMDER_ROOT\bin;$env:Path;$Env:CMDER_ROOT"
$CmderUserProfilePath = Join-Path $env:CMDER_ROOT "config\user-profile.ps1"
if(Test-Path $CmderUserProfilePath) {
# Create this file and place your own command in there.
. "$CmderUserProfilePath"
} else {
Write-Host "Creating user startup file: $CmderUserProfilePath"
"# Use this file to run your own startup commands" | Out-File $CmderUserProfilePath
}

18
vendor/sources.json vendored
View File

@ -1,22 +1,22 @@
[
{
"name": "msysgit",
"version": "1.9.5-preview20150319",
"url": "https://github.com/msysgit/msysgit/releases/download/Git-1.9.5-preview20150319/PortableGit-1.9.5-preview20150319.7z"
"name": "git-for-windows",
"version": "v2.7.1.windows.1",
"url": "https://github.com/git-for-windows/git/releases/download/v2.7.1.windows.1/PortableGit-2.7.1-32-bit.7z.exe"
},
{
"name": "clink",
"version": "0.4.4",
"url": "https://github.com/mridgers/clink/releases/download/0.4.4/clink_0.4.4.zip"
"version": "0.4.7",
"url": "https://github.com/mridgers/clink/releases/download/0.4.7/clink_0.4.7.zip"
},
{
"name": "conemu-maximus5",
"version": "150513",
"url": "https://github.com/Maximus5/ConEmu/releases/download/v15.05.13/ConEmuPack.150513.7z"
"version": "160207",
"url": "https://github.com/Maximus5/ConEmu/releases/download/v16.02.07/ConEmuPack.160207.7z"
},
{
"name": "clink-completions",
"version": "0.1.0",
"url": "https://github.com/vladimir-kotikov/clink-completions/archive/0.1.0.zip"
"version": "0.2.2",
"url": "https://github.com/vladimir-kotikov/clink-completions/archive/0.2.2.zip"
}
]