diff --git a/CHANGELOG.md b/CHANGELOG.md index a66ff3b..34ae8ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Change Log +## [Unreleased] + +### Fixes + +* Pull Request: [#2002](https://github.com/cmderdev/cmder/pull/2002) + * Updated the HG prompt code to use the '-ib' option to 'hg id' so the branch name is always available, regardless of the state of the working copy + +### Changes + +* Pull Request: [#2055](https://github.com/cmderdev/cmder/pull/2055) + * Upgrade git to 2.21.0 + * Provide default settings for Clink that updates the history file in real time + * Turn this on in existing Cmder using `clink set history_io 1` + * Allow clink disable by setting CMDER_CLINK=0 before starting task + ## [1.3.11](https://github.com/cmderdev/cmder/tree/v1.3.11) (2018-12-22) ### Fixes diff --git a/README.md b/README.md index 3a91106..d624972 100644 --- a/README.md +++ b/README.md @@ -312,11 +312,11 @@ For instructions on how to integrate Cmder with your IDE, please read our [Wiki The process of upgrading Cmder depends on the version/build you are currently running. -If you have a `[cmder_root]/config/user-conemu.xml`, you are running a newer version of Cmder, follow the below process: +If you have a `[cmder_root]/config/user[-|_]conemu.xml`, you are running a newer version of Cmder, follow the below process: -1. Exit all Cmder sessions and relaunch `[cmder_root]/cmder.exe`, this backs up your existing `[cmder_root]/vendor/conemu-maximus5/conemu.xml` to `[cmder_root]/config/user-conemu.xml`. +1. Exit all Cmder sessions and relaunch `[cmder_root]/cmder.exe`, this backs up your existing `[cmder_root]/vendor/conemu-maximus5/conemu.xml` to `[cmder_root]/config/user[-|_]conemu.xml`. - * The `[cmder_root]/config/user-conemu.xml` contains any custom settings you have made using the 'Setup Tasks' settings dialog. + * The `[cmder_root]/config/user[-|_]conemu.xml` contains any custom settings you have made using the 'Setup Tasks' settings dialog. 2. Exit all Cmder sessions and backup any files you have manually edited under `[cmder_root]/vendor`. @@ -325,9 +325,9 @@ If you have a `[cmder_root]/config/user-conemu.xml`, you are running a newer ver 3. Delete the `[cmder_root]/vendor` folder. 4. Extract the new `cmder.zip` or `cmder_mini.zip` into `[cmder_root]/` overwriting all files when prompted. -If you do not have a `[cmder_root]/config/user-conemu.xml`, you are running an older version of cmder, follow the below process: +If you do not have a `[cmder_root]/config/user[-|_]conemu.xml`, you are running an older version of cmder, follow the below process: -1. Exit all Cmder sessions and backup `[cmder_root]/vendor/conemu-maximus5/conemu.xml` to `[cmder_root]/config/user-conemu.xml`. +1. Exit all Cmder sessions and backup `[cmder_root]/vendor/conemu-maximus5/conemu.xml` to `[cmder_root]/config/user[-|_]conemu.xml`. 2. Backup any files you have manually edited under `[cmder_root]/vendor`. diff --git a/vendor/clink.lua b/vendor/clink.lua index 2530510..d5f6876 100644 --- a/vendor/clink.lua +++ b/vendor/clink.lua @@ -324,26 +324,26 @@ local function hg_prompt_filter() dirty = "\x1b[31;1m", } - -- 'hg id' gives us BOTH the branch name AND an indicator that there - -- are uncommitted changes, in one fast(er) call - local pipe = io.popen("hg id 2>&1") + local pipe = io.popen("hg branch 2>&1") local output = pipe:read('*all') local rc = { pipe:close() } - if output ~= nil and - string.sub(output,1,7) ~= "abort: " and -- not an HG working copy - string.sub(output,1,12) ~= "000000000000" and -- empty wc (needs update) - (not string.find(output, "is not recognized")) then -- 'hg' not in path + -- strip the trailing newline from the branch name + local n = #output + while n > 0 and output:find("^%s", n) do n = n - 1 end + local branch = output:sub(1, n) + + if branch ~= nil and + string.sub(branch,1,7) ~= "abort: " and -- not an HG working copy + (not string.find(branch, "is not recognized")) then -- 'hg' not in path local color = colors.clean - -- split elements on space delimiter - local items = {} - for i in string.gmatch(output, "%S+") do - table.insert(items, i) - end - -- if the repo hash ends with '+', the wc has uncommitted changes - if string.sub(items[1], -1, -1) == "+" then color = colors.dirty end - -- substitute the branch in directly -- already WITH parentheses. :) - result = color .. items[2] -- string.sub(items[2], 1, string.len(items[2]) - 1) + + local pipe = io.popen("hg status -amrd 2>&1") + local output = pipe:read('*all') + local rc = { pipe:close() } + + if output ~= nil and output ~= "" then color = colors.dirty end + result = color .. "(" .. branch .. ")" end end diff --git a/vendor/clink_settings.default b/vendor/clink_settings.default new file mode 100644 index 0000000..021a78d --- /dev/null +++ b/vendor/clink_settings.default @@ -0,0 +1,116 @@ +# name: Pressing Ctrl-D exits session +# type: bool +# Ctrl-D exits cmd.exe when it is pressed on an empty line. +ctrld_exits = 1 + +# name: Toggle if pressing 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 +# 0 = PATH only +# 1 = PATH and CWD +# 2 = PATH, CWD, and directories +# 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. A value of -1 will disable executable matching completely. +exec_match_style = 2 + +# name: Whitespace prefix matches files +# type: bool +# If the line begins with whitespace then Clink bypasses executable matching and +# will match all files and directories instead. +space_prefix_match_files = 1 + +# name: Colour of the prompt +# 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 +# 0 = Disabled +# 1 = Answer 'Y' +# 2 = Answer 'N' +# Automatically answers cmd.exe's 'Terminate batch job (Y/N)?' prompts. 0 = +# disabled, 1 = answer 'Y', 2 = answer 'N'. +terminate_autoanswer = 0 + +# name: Lines of history saved to disk +# type: int +# When set to a positive integer this is the number of lines of history that +# will persist when Clink saves the command history to disk. Use 0 for infinite +# lines and <0 to disable history persistence. +history_file_lines = 10000 + +# name: Skip adding lines prefixed with whitespace +# type: bool +# Ignore lines that begin with whitespace when adding lines in to the history. +history_ignore_space = 0 + +# name: Controls how duplicate entries are handled +# type: enum +# 0 = Always add +# 1 = Ignore +# 2 = Erase previous +# If a line is a duplicate of an existing history entry Clink will erase the +# duplicate when this is set 2. A value of 1 will not add duplicates to the +# history and a value of 0 will always add lines. Note that history is not +# deduplicated when reading/writing to disk. +history_dupe_mode = 2 + +# name: Read/write history file each line edited +# type: bool +# When non-zero the history will be read from disk before editing a new line and +# written to disk afterwards. +history_io = 1 + +# name: Sets how command history expansion is applied +# type: enum +# 0 = Off +# 1 = On +# 2 = Not in single quotes +# 3 = Not in double quote +# 4 = Not in any quotes +# The '!' character in an entered line can be interpreted to introduce words +# from the history. This can be enabled and disable by setting this value to 1 +# or 0. Values or 2, 3 or 4 will skip any ! character quoted in single, double, +# or both quotes respectively. +history_expand_mode = 4 + +# name: Support Windows' Ctrl-Alt substitute for AltGr +# type: bool +# Windows provides Ctrl-Alt as a substitute for AltGr, historically to support +# keyboards with no AltGr key. This may collide with some of Readline's +# bindings. +use_altgr_substitute = 1 + +# name: Strips CR and LF chars on paste +# type: enum +# 0 = Paste unchanged +# 1 = Strip +# 2 = As space +# Setting this to a value >0 will make Clink strip CR and LF characters from +# text pasted into the current line. Set this to 1 to strip all newline +# characters and 2 to replace them with a space. +strip_crlf_on_paste = 2 + +# name: Enables basic ANSI escape code support +# type: bool +# When printing the prompt, Clink has basic built-in support for SGR ANSI escape +# codes to control the text colours. This is automatically disabled if a third +# party tool is detected that also provides this facility. It can also be +# disabled by setting this to 0. +ansi_code_support = 1 + diff --git a/vendor/init.bat b/vendor/init.bat index b525daa..20676f6 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -140,12 +140,14 @@ if "%CMDER_CLINK%" == "1" ( if defined CMDER_USER_CONFIG ( if not exist "%CMDER_USER_CONFIG%\settings" ( echo Generating clink initial settings in "%CMDER_USER_CONFIG%\settings" + copy "%CMDER_ROOT%\vendor\clink_settings.default" "%CMDER_USER_CONFIG%\settings" echo Additional *.lua files in "%CMDER_USER_CONFIG%" are loaded on startup.\ ) "%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_USER_CONFIG%" --scripts "%CMDER_ROOT%\vendor" ) else ( if not exist "%CMDER_ROOT%\config\settings" ( echo Generating clink initial settings in "%CMDER_ROOT%\config\settings" + copy "%CMDER_ROOT%\vendor\clink_settings.default" "%CMDER_ROOT%\config\settings" echo Additional *.lua files in "%CMDER_ROOT%\config" are loaded on startup. ) "%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_ROOT%\config" --scripts "%CMDER_ROOT%\vendor" diff --git a/vendor/lib/lib_base.cmd b/vendor/lib/lib_base.cmd index 705cca2..ac8d034 100644 --- a/vendor/lib/lib_base.cmd +++ b/vendor/lib/lib_base.cmd @@ -65,12 +65,17 @@ exit /b echo %comspec% | %WINDIR%\System32\find /i "\tcc.exe" > nul && set "CMDER_SHELL=tcc" echo %comspec% | %WINDIR%\System32\find /i "\tccle" > nul && set "CMDER_SHELL=tccle" - set CMDER_CLINK=1 - if "%CMDER_SHELL%" equ "tcc" set CMDER_CLINK=0 - if "%CMDER_SHELL%" equ "tccle" set CMDER_CLINK=0 + if not defined CMDER_CLINK ( + set CMDER_CLINK=1 + if "%CMDER_SHELL%" equ "tcc" set CMDER_CLINK=0 + if "%CMDER_SHELL%" equ "tccle" set CMDER_CLINK=0 + ) - set CMDER_ALIASES=1 - if "%CMDER_SHELL%" equ "tcc" set CMDER_ALIASES=0 - if "%CMDER_SHELL%" equ "tccle" set CMDER_ALIASES=0 + + if not defined CMDER_ALIASES ( + set CMDER_ALIASES=1 + if "%CMDER_SHELL%" equ "tcc" set CMDER_ALIASES=0 + if "%CMDER_SHELL%" equ "tccle" set CMDER_ALIASES=0 + ) exit /b diff --git a/vendor/sources.json b/vendor/sources.json index 72696ce..b8f3f8a 100644 --- a/vendor/sources.json +++ b/vendor/sources.json @@ -1,8 +1,8 @@ [ { "name": "git-for-windows", - "version": "v2.19.0.windows.1", - "url": "https://github.com/git-for-windows/git/releases/download/v2.19.0.windows.1/PortableGit-2.19.0-64-bit.7z.exe" + "version": "v2.21.0.windows.1", + "url": "https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/PortableGit-2.21.0-64-bit.7z.exe" }, { "name": "clink",