clink

Bash's powerful command line editing in cmd.exe

GPL-3.0 License

Stars
3.5K
clink - v1.6.1

Published by chrisant996 9 months ago

Features:

  • Improved input line parsing and coloring:
    • Commands starting with @ are supported, and completion correctly ignores the @.
    • Each of the following CMD syntax errors are recognized: lines starting with & or @2>, and lines containing & & or 2>&file.
    • The whole redirections 2>file or >file or 2>&1 are colored instead of only the > or >&.
  • Completions for clink set color settings include a color sample in the description field (e.g. type clink set colorAlt-= to see the color settings and their current color samples).
  • The clink-reload bindable command now reverts key bindings and config variables before reloading the inputrc file, so that old bindings and values don't linger in the current session if they've been removed from the inputrc file.
  • Added clink-dump-functions and clink-dump-macros bindable commands. These behave similar to dump-functions and dump-macros, but they show user-friendly key names and luafunc: macros are listed as functions instead of as macros.
  • Added some new "bigword" cursor movement commands for moving to the next or previous space delimited word; clink-backward-bigword, clink-forward-bigword, cua-backward-bigword, cua-forward-bigword.
  • Added a new conditional directive $if clink_version in the inputrc file (e.g. $if clink_version >= 1.6.1).
  • Added a new prompt.spacing setting which can control blank lines before the prompt (it was a clink-flex-prompt feature which has now been incorporated into Clink itself).
  • Added a new match.coloring_rules setting and %CLINK_MATCH_COLORS% environment variable, both of which supersede Readline's %LS_COLORS% definitions when displaying match completions.
  • Internal changes.

Lua:

  • Added line_state:getrangeoffset() and line_state:getrangelength() to get the beginning offset and length of the range in the input line described by the line_state.
  • Added console.explodeansi() to split a string into substrings on ANSI escape code boundaries.
  • Added rl.getinputrcfilename() to get the loaded inputrc file name.
  • Added rl.translatekey() to translate between key sequence formats (input key, key binding, and friendly key name).
  • Added rl.bracketpromptcodes() to apply \1 and \2 codes as needed by Readline in certain inputrc config variables.
  • Document the CLINK_EXE global variable which has existed since v1.0.0 but was accidentally undocumented.

Fixes:

  • Removed superfluous ;39 and/or ;49 from color setting escape codes in some cases.
  • Fixed console.readinput() repeatedly returning nil after console.checkinput() returns true (regression introduced in v1.5.12).
  • Fixed loading the default_inputrc file if it exists (introduced in v1.3.5, and it never worked properly until now).
  • Fixed the history-size config variable to be completely ignored (it interfered with Clink's history database and settings, which were meant to supersede it).
  • Fixed the clink-popup-show-help command when including unbound commands (numeric argument of 4) so it doesn't double-list the bound luafunc: macros.
  • Fixed updating column text in clink.popuplist() when Del is pressed (e.g. history timestamps in the clink-popup-history command).
  • Fixed the width of clink.popuplist() to take the title into account.
  • Fixed Lua argument errors for some objects (the argument # in the error message was one lower than it should have been in some messages).
  • Fixed the return value from rl_buffer:setcursor().
  • Fixed console:getnumlines() between onendedit and onbeginedit.
  • Fixed erasing the "History expansion for" preview when the transient prompt is enabled.
  • Fixed the transient prompt sometimes not erasing properly (regression introduced in v1.5.17).
  • Fixed the color of flags for clink set (e.g. --help).
  • Fixed the clink-reload command so any inputrc file parse errors are printed on new lines.
  • Fixed the lua.break_on_error setting so it works properly in released builds of Clink.
clink - v1.6.0

Published by chrisant996 11 months ago

  • Updated the Readline library to v8.2 patch 7 (the list here omits changes that were contributed to Readline from Clink, or which do not affect Clink).
    • New features:
      • History expansion better understands multiple history expansions that may contain strings that would ordinarily inhibit history expansion (e.g., abc!$!$).
      • There is a new fetch-history bindable command that retrieves the history entry corresponding to its numeric argument. Negative arguments count back from the end of the history.
      • There is a new option: enable-active-region. This separates control of the active region and bracketed-paste. It has the same default value as bracketed-paste, and enabling bracketed paste enables the active region. Users can now turn off the active region while leaving bracketed paste enabled.
      • Readline looks in %LS_COLORS% for a custom filename extension (*.readline-colored-completion-prefix) and uses that as the default color for the common prefix displayed when colored-completion-prefix is set, superseding the so type if both are present.
      • Two new bindable string variables: active-region-start-color and active-region-end-color. The first sets the color used to display the active region; the second is unused and unnecessary in Clink, but exists anyway for compatibility. If set, these are used in place of terminal standout mode.
    • Fixes:
      • Fixed a problem with cleaning up active marks.
      • Fixed a problem with arithmetic comparison operators checking the version in the inputrc file.
      • Fixed a bug that could cause readline to crash if the application removed the callback line handler before readline read all typeahead.
      • Added additional checks for read errors in the middle of readline commands.
      • Fixed a problem with unix-filename-rubout that caused it to delete too much when applied to a pathname consisting only of one or more slashes.
      • Fixed a problem that caused the \r output by turning off bracketed paste to overwrite the line if terminal echo was disabled.
      • Fixed a couple problems where transpose-words could corrupt the end of the input line.
      • Fixed an issue that caused a history line's undo list to be cleared when it should not have been.
      • Fixed leaked memory from undo lists.
      • When replacing a history entry, make sure the existing entry has a non-NULL timestamp before copying it; it may have been added by the application, not the history library.
  • The blink-matching-paren setting works in Clink now.
  • Completion works for UNC share names now (share names like \\server\share, not server names like \\server).
  • Improved undo grouping for consecutive inserted text.
  • Added os.enumshares() to enumerate the SMB UNC shares on a given server.
  • Fixed Lua error messages from custom Lua libraries that report errors using table objects instead of strings.
  • Fixed issue with the autosuggest.hint setting where it could apply incorrect input line coloring when the Right key isn't bound to one of the usual commands for that key.
  • Internal changes and optimizations.
clink - v1.5.18

Published by chrisant996 11 months ago

  • Fixed #524 and #523; garbled display in wide terminal windows (regression introduced in v1.5.14, which exacerbated and revealed a bug that's existed since Clink v1.0.0 alpha and which could intermittently garble Unicode text or escape sequences).
  • Fixed the transient prompt sometimes not displaying properly (regression introduced in v1.5.17).
clink - v1.5.17

Published by chrisant996 11 months ago

  • Reduced flicker when async prompt filtering redraws the prompt.
  • When _argmatcher:addarg() or _argmatcher:addflags() is passed a table containing nowordbreakchars="chars" then the chars are not treated as word breaks for that argument index or for flags (see Overcoming Word Breaks for more information).
  • Added a user_data argument to the custom classifier function for an argmatcher (set via _argmatcher:setclassifier()).
  • Improved input line coloring for clink set so that color.unexpected is only used for a completed word that isn't a match.
  • Fixed reading lines from stdin in Lua scripts (e.g. io.stdin:read()).
  • Fixed accidentally showing matches in a single column sometimes even when there are no descriptions.
  • Fixed an incomplete clink inject if an explicit or implicit endlocal happens after clink inject but before the prompt is shown (the injection didn't finish successfully until the next time an environment variable was set, but now it finishes immediately).
clink - v1.5.16

Published by chrisant996 11 months ago

  • Fixed #522; garbled display in JetBrains WebStorm terminal (regression introduced in v1.5.15).
    • Fixing this required reverting the change that automatically chose a default for color.suggestion based on the current console colors.
  • Fixed :chaincommand() so that generators and classifiers that come after argmatchers in the priority order receive the same line_state objects as ones that come before argmatchers in the priority order.
  • Fixed :setdelayinit() with linked argmatchers; the callback function was only called for registered argmatchers (e.g. clink.argmatcher("foo"):setdelayinit(func)) and it wasn't called for linked argmatchers (e.g. "-x" .. clink.argmatcher():setdelayinit(func)).
  • Fixed the word parser to recognize a single digit as a word when followed by punctuation.
  • Fixed loopchars for characters like - or * that are also Lua pattern characters.
clink - v1.5.15

Published by chrisant996 11 months ago

  • Added localized descriptions for flag completions in cmd, cd, and rd.
  • Added partial ability to detect light/dark console color themes:
    • Added console.getcolortable() which returns a table with the console's current 16 predefined colors. When possible, the table includes a field indicating whether the current console color theme is a light or dark theme.
    • At this time, the colors can be accurately retrieved only when using the legacy conhost terminal. When using Windows Terminal, ConEmu, or other ConPty-based terminals there is currently no way to accurately retrieve the colors. Once the Terminal#10639 issue is fixed then Clink will also detect the background color in these terminal programs.
    • Changed the default for color.suggestion so that it attempts to detect light themes (bright background colors) when possible, and it attempts automatically choose a default color for suggestions that is faint but has sufficient contrast to be readable.
  • Fixed the onlink callback function in :addflags() so that the arg_index parameter is correctly 0 instead of 1.
  • Fixed the upper bound line number for Lua console line API functions.
  • Fixed console.getlinetext() when emoji are present.
clink - v1.5.14

Published by chrisant996 11 months ago

  • Added a visible usage hint for Auto-Suggestions to help make the feature more discoverable and usable. The usage hint can be hidden by turning off the autosuggest.hint setting.
  • Added a callback function that can be assigned to an argument position by including onadvance=your_callback_function in the table given to :addarg() (see Responding to Arguments in Argmatchers for more information).
  • Fixed displaying match descriptions containing embedded color codes.
  • Fixed finding argmatchers for doskey alias names containing quotes.
  • Fixed parsing the input line when a doskey alias references a command with an argmatcher that uses the :chaincommand() function (e.g. an alias foo=sudo dir $* with an argmatcher like clink.argmatcher("sudo"):chaincommand() so that completions and input line coloring work properly for the rest of the input line).
  • Fixed the exec.commands setting with an argmatcher that uses the :chaincommand() function.
  • Fixed _argmatcher:setclassifier() so the custom classifier is called for flags as well as for arguments.
clink - v1.5.13

Published by chrisant996 12 months ago

  • Added clink.onhistory() to register a function to be called when the input line has been accepted and is about to be added to history (and optionally cancel adding it).
  • Fixed history delete with a negative number so it indexes backwards from the end, as advertised.
  • Fixed calling clink.refilterprompt() from a coroutine, and related fixes to ensure various Lua functions coexist properly with coroutines.
  • Fixed #520; add a link to the Releases page in the updater dialog box.
clink - v1.5.12

Published by chrisant996 12 months ago

  • Fixed updating the input line display after using clink-popup-history or win-popup-history (regression introduced in v1.5.3; the fix in v1.5.4 was incomplete).
  • Fixed console.checkinput() so it doesn't eat whatever pending input it detects.
  • Fixed the updater to be more specific about what PowerShell cmdlet it invokes, in case a module replaces the built-in Expand-Archive cmdlet.
clink - v1.5.11

Published by chrisant996 about 1 year ago

  • Fixed prompt filters and other Lua coroutines when color.executable and color.unrecognized are both empty (regression introduced in v1.5.10).
clink - v1.5.10

Published by chrisant996 about 1 year ago

  • Changed clink update to consider "up-to-date" as a successful case.
  • Fixed a case where the completion auto-suggest strategy could be temporarily prevented from providing a suggestion (regression introduced in v1.4.22).
  • Fixed leaked memory when showing history expansion previews.
  • Fixed #511; ! doesn't need to be treated as a word break character.
  • Internal changes.
clink - v1.5.9

Published by chrisant996 about 1 year ago

  • Added default key binding Alt-Ctrl-Up for clink-popup-history.
  • Fixed the match.max_rows setting to control the number of rows of items (instead of the total number of rows including description rows).
  • Fixed #509; crash when using clink-popup-history if history.time_stamp is off (regression introduced in v1.5.7).
clink - v1.5.8

Published by chrisant996 about 1 year ago

  • Fixed #504; the clink.autoupdate setting behaves like auto even when it's set to check (regression introduced in v1.5.5).
  • Fixed #503; the updater could hang if any additional CMD instances were started while the "Clink Update" prompt window was open (regression introduced in v1.5.5).
clink - v1.5.7

Published by chrisant996 about 1 year ago

  • Added vertical scrollbars in clink-select-complete and in popup lists.
  • Added terminal.scrollbars setting which can disable the vertical scrollbars (e.g. according to preference, or if a terminal or font is incompatible with extended Unicode box drawing characters).
  • Added clink set --info flag.
  • Added language-related diagnostic info in clink info.
  • Added minor optimization when displaying prompt text.
  • Added enhancements in the pager used when displaying help or matches; Tab or Space or Y print the next page, D prints the next half-page, Enter prints the next line, N or Q stop printing, and ? shows the available keys in the -- More -- pager prompt (the enhancements were accidentally lost in v1.1.1-alpha).
  • Horizontal scrolling in popup lists works for all columns, if text doesn't fit in the column.
  • Fixed crash in rl.getmatchcolor(match, type); when the optional type parameter was passed in, the API could crash.
  • Fixed #498; when autosuggest.enable is False, cycling or searching through history and then pressing Right does nothing.
  • Internal improvements.
clink - v1.5.6

Published by chrisant996 about 1 year ago

  • Added os.getpushddepth(), which works when %PROMPT% contains exactly one $+.
  • The clink-popup-history and win-history-list commands show timestamps when history.time_stamp is set to show.
  • Fixed os.geterrorlevel() when cmd /u was used.
  • Fixed word break parsing in the input line when certain Unicode characters are present.
  • Fixed Unicode string conversions to disallow translating to "similar" characters (which could be problematic in filenames).
  • Fixed a crash in rl.getkeybindings() if it's called by a Lua script running inside clink set.
  • Fixed Lua debugger input if a script error occurs inside clink set.
  • Fixed a width quirk in clink-select-complete where typing to narrow the list to a single item accidentally made the column width at least 3 characters, even if the item was only 1 or 2 characters width.
  • Fixed clink history to handle escape codes embedded in the history.time_format setting.
  • Fixed a potential crash after using remove-history at the beginning of the history list.
  • Fixed #494; Lua error when using unicode.fromcodepage() (reported and fixed before the bug was published).
  • Fixed #493; clink-select-complete displays the selected item incorrectly if both colored-stats and colored-completion-prefix are off (regression introduced in v1.5.5).
clink - v1.5.5

Published by chrisant996 about 1 year ago

  • Changed the clink.autoupdate setting to allow off, check (the default), prompt, and auto for more control over how and when updating happens. When set to prompt or auto Clink can trigger updates automatically, so you don't need to even run clink update.
  • Enhanced debug.log_terminal to include low level console keyboard and mouse input events.
  • Fixed debug.log_terminal to capture all input (regression introduced in v1.5.2).
  • Fixed slowness during clink-select-complete while typing, caused by excessive match generation.
  • Fixed selection highlight in clink-select-complete when the whole match text has been typed.
  • Fixed #486; window title escape code doesn't work properly if it contains emoji or UTF content.
  • Internal changes.
clink - v1.5.4

Published by chrisant996 about 1 year ago

  • Further contrast improvements for default colors to be readable in both Dark and Light terminal themes.
  • Added arginfo field in builder:addmatches() and in match display filtering.
  • Auto-suggestions are no longer shown while searching history; it was too distracting and confusing.
  • Fixed updating the input line display after using clink-popup-history or win-popup-history (regression introduced in v1.5.3).
  • Fixed old-menu-complete and menu-complete when there's only one match. The first time it should insert the match, and subsequent times should ding instead of cycling through the same match over and over and requiring an equal number of undo to undo.
  • Fixed match display filtering to support the match.substring setting.
  • Fixed match display filtering to support the files.system setting.
  • Fixed the cursor position if match display filtering happens the first time clink-select-complete is used in a session.
  • Fixed a case where two undo were required to fully undo what menu-complete inserted.
  • Fixed Esc during incremental history search mode so it cancels the search.
  • Fixed input line coloring after non-incremental-reverse-search-history or non-incremental-forward-search-history finds an exact match for the search text (since v1.1.5).
  • Internal changes and optimizations.
clink - v1.5.3

Published by chrisant996 about 1 year ago

  • Added builder:setfullyqualified() to force completions to be inserted as fully qualified path names.
  • Completions for clink set setting_name input use fully qualified path names for input. This helps avoid accidentally setting relative paths in global settings; since the current directory changes frequently, setting relative paths usually leads to unintended consequences.
  • Only load a script from a completions\ directory if the associated command exists in the file system. Also, pass the fully qualified file name as input to the script (in Lua, use ... to get script arguments, e.g. local command = ...).
  • clink info now reports whether Clink is injected.
  • Improve efficiency of updating the input line display. This eliminates some redundant processing in the Readline library and in Clink.
  • Fixed input line parsing and coloring when the doskey.enhanced setting is off or when doskey macro expansion is suppressed.
  • Fixed line_state:getwordinfo() to accurately set the .alias field when the doskey.enhanced setting is off or when doskey macro expansion is suppressed.
  • Fixed coloring the command word in the command line when queued keys select and accept a command line from history instantly (it could accidentally continue without applying the appropriate coloring).
  • Fixed script error in clink.filematches(nil) and clink.dirmatches(nil); they were meant to behave the same as passing an empty string.
clink - v1.5.2

Published by chrisant996 about 1 year ago

  • Adjusted the colors in "Use enhanced defaults" to have sufficient contrast to be readable in both Dark and Light terminal themes.
  • More reliably detect whether hosted in Windows Terminal, and even when Windows Terminal is set as the default terminal application.
  • Fixed crash in clink.popuplist() when the current argument is past the end of the list of items.
  • Fixed cursor location when the input line contains embedded CTRL characters.
  • Fixed #474; pasting is slow in Windows Terminal and ConEmu.
  • Fixed #470; typo in help text.
clink - v1.5.1

Published by chrisant996 over 1 year ago

  • Added rl.getcommandbindings() to get info about a command, including the key(s) bound to it, if any.
  • Changed to also allow clink.popuplist() inside a function registered by clink.onfiltermatches().
  • Changed console input mode handling to more aggressively clear ENABLE_VIRTUAL_TERMINAL_INPUT since it interferes with input (especially Ctrl key combinations) and some console programs set it but accidentally neglect to clear it when they're finished.