clink

Bash's powerful command line editing in cmd.exe

GPL-3.0 License

Stars
3.5K
clink - v1.3.21

Published by chrisant996 over 2 years ago

Recent highlights: The v1.3.13 release added features that make the i.lua script possible. Argmatchers can now be written to do match completion in directories other than the current directory. Argmatchers can also be written to take a whole command line as an argument: for example the built-in cmd argmatcher (cmd some_command).

v1.3.21

  • Improved the auto-updater when there are multiple copies of Clink on a computer; it no longer needs to download the .zip update file multiple times.
  • Fixed mouse input when the console is scrolled.
  • Fixed #299; update shown even though up to date.
clink - v1.3.20

Published by chrisant996 over 2 years ago

Recent highlights: The v1.3.13 release added features that make the i.lua script possible. Argmatchers can now be written to do match completion in directories other than the current directory. Argmatchers can also be written to take a whole command line as an argument: for example the built-in cmd argmatcher (cmd some_command).

v1.3.20

  • Speculative fix for #296.
  • Fixed potential crash in popup lists if there are only a few items (regression introduced in v1.3.18).
clink - v1.3.19

Published by chrisant996 over 2 years ago

Recent highlights: The v1.3.13 release added features that make the i.lua script possible. Argmatchers can now be written to do match completion in directories other than the current directory. Argmatchers can also be written to take a whole command line as an argument: for example the built-in cmd argmatcher (cmd some_command).

v1.3.19

  • Added directories.dupe_mode setting that controls how duplicates are handled in the directory history list for the clink-popup-directories command.
  • Added Del to delete a directory entry in the clink-popup-directories command.
  • Fixed obscure intermittent problem with delayinit argmatchers.
  • Fixed Ctrl-C and Ctrl-Break in CMD built-in commands (regression introduced in v1.3.14).
clink - v1.3.18

Published by chrisant996 over 2 years ago

Recent highlights: The v1.3.13 release added features that make the i.lua script possible. Argmatchers can now be written to do match completion in directories other than the current directory. Argmatchers can also be written to take a whole command line as an argument: for example the built-in cmd argmatcher (cmd some_command).

v1.3.18

  • Added a built-in updater for Clink, which is enabled by default. When enabled, Clink reports when an update is available. Run clink update to apply the update.
  • Added clink-insert-suggested-line, clink-insert-suggested-word, clink-insert-suggested-full-word, and clink-accept-suggested-line commands (see #280).
  • Added optional timestamps in the history file. The new history.time_stamp and history.time_format settings control whether timestamps are saved and whether/how timestamps are shown.
  • Added cmd.altf4_exits setting to control whether Alt-F4 makes cmd.exe exit. This is so that when the terminal.raw_esc setting is enabled pressing EscEsc behaves the same as Alt-Ctrl-[ as expected, while still allowing Alt-F4 to work.
  • Added horizontal scrolling in the history popup list.
  • Added clink.onprovideline() so scripts can register a function to be called after onbeginedit but before any input is processed. The function can return a string to be executed as a command line, in which case the line editor is not invoked and the onendedit and onfilterinput events happen immediately (see #263).
  • Added rl.gethistorycount() and rl.gethistoryitems() to access the history items.
  • Added os.gettemppath() to get the system temporary directory.
  • Added io.sopen() to control sharing access when opening or creating a file.
  • Both io.open() and io.sopen() support the "x" file mode modifier (combined with "w" or "w+"), which makes the function fail if the file already exists.
  • Improved the what-is command to apply word wrapping to the command description.
  • Fixed generating matches from history (fromhistory=true) in argmatchers (regression introduced in v1.3.13).
  • Fixed executable file detection for file names that contain + characters.
  • Fixed some input keys accidentally handled by the OS sometimes (regression introduced in v1.3.6; original fix was introduced in v1.2.10).
  • Fixed timing conditions where other console programs could accidentally override Clink's mouse input mode.
  • Fixed left mouse click in popup lists when terminal.mouse_input is enabled.
  • Fixed alternate key bindings for copy (Ctrl-Ins) and paste (Shift-Ins).
  • Fixed description column alignment in clink.popuplist().
  • Fixed keyboard driver for Alt-Ctrl-[ when the terminal.raw_esc setting is enabled.
  • Fixed keyboard driver for Alt-Ctrl-] and Alt-Ctrl-</kbd>.
clink - v1.3.17

Published by chrisant996 over 2 years ago

Recent highlights: The v1.3.13 release added features that make the i.lua script possible. Argmatchers can now be written to do match completion in directories other than the current directory. Argmatchers can also be written to take a whole command line as an argument: for example the built-in cmd argmatcher (cmd some_command).

Changes in v1.3.17

  • Fixed coloring executable files in the input line (some file types weren't detected correctly, and missing files were considered executable if their extension had a file type association).
  • Fixed #281; screen height detected incorrectly (regression introduced in v1.3.16).
clink - v1.3.16

Published by chrisant996 over 2 years ago

Recent highlights: The v1.3.13 release added features that make the i.lua script possible. Argmatchers can now be written to do match completion in directories other than the current directory. Argmatchers can also be written to take a whole command line as an argument: for example the built-in cmd argmatcher (cmd some_command).

Changes in v1.3.16

  • Added os.sleep().
  • Revised the Clink documentation to directly include the Readline documentation.
  • Fixed executable file detection for file extensions that point at Progids instead of having a shell command.
  • Fixed double help message from history command when invalid flags are used.
  • Fixed crash when file permissions block accessing the history file, and the history command reports an error message accordingly.
  • Fixed #262; changing the terminal width between prompts (while a different program is running) caused Readline to start displaying the input line incorrectly.
clink - v1.3.15

Published by chrisant996 over 2 years ago

Recent highlights: The v1.3.13 release added features that make the i.lua script possible. Argmatchers can now be written to do match completion in directories other than the current directory. Argmatchers can also be written to take a whole command line as an argument: for example the built-in cmd argmatcher (cmd some_command).

Changes in v1.3.15

  • Fixed #269; reverse video could get confused (regression introduced in v1.3, and incompletely fixed in v1.3.4).

Changes in v1.3.14

  • Ctrl+Break can now interrupt some operations, including match display and match generators and the os.globfiles() and os.globdirs() functions in Lua scripts.
  • Added os.issignaled() so Lua scripts can cooperatively interrupt themselves.
  • Improved responsiveness of completion commands when an async prompt filter is still running in the background (io.popen() and os.execute() are serialized in prompt filter coroutines, and are serialized separately in match generator coroutines, but are not serialized in other coroutines).
  • Fixed displaying pasted lines.
  • Fixed doskey aliases in pasted lines.
  • Fixed #268; crash when copy command prompts whether to overwrite a file (regression introduced in v1.3.13).
clink - v1.3.14

Published by chrisant996 over 2 years ago

Recent highlights: The v1.3.13 release added features that make the i.lua script possible. Argmatchers can now be written to do match completion in directories other than the current directory. Argmatchers can also be written to take a whole command line as an argument: for example the built-in cmd argmatcher (cmd some_command).

Changes in v1.3.14

  • Ctrl+Break can now interrupt some operations, including match display and match generators and the os.globfiles() and os.globdirs() functions in Lua scripts.
  • Added os.issignaled() so Lua scripts can cooperatively interrupt themselves.
  • Improved responsiveness of completion commands when an async prompt filter is still running in the background (io.popen() and os.execute() are serialized in prompt filter coroutines, and are serialized separately in match generator coroutines, but are not serialized in other coroutines).
  • Fixed displaying pasted lines.
  • Fixed doskey aliases in pasted lines.
  • Fixed #268; crash when copy command prompts whether to overwrite a file (regression introduced in v1.3.13).
clink - v1.3.13

Published by chrisant996 over 2 years ago

The v1.3.13 release adds features that make the i.lua script possible. Argmatchers can now be written to do match completion in directories other than the current directory. Argmatchers can also be written to take a whole command line as an argument: for example the built-in cmd argmatcher (cmd some_command).

Changes in v1.3.13

  • Argmatchers can use :chaincommand() to treat the rest of the command line as another command.
    • Added an argmatcher for cmd that uses :chaincommand().
    • E.g. so that completion after cmd program can be parsed by an argmatcher for program instead of cmd.
  • Argmatchers can be more involved in parsing the command line, if they wish. See Responding to Arguments in Argmatchers for more information.
    • A callback function can be assigned to an argument position by including onarg=your_callback_function in the table given to :addarg().
    • The onarg callback and match functions receive an additional user_data parameter. When parsing begins, the user_data is an empty table, and your functions can set or get data from the table. Each time a flag or argument links to another argmatcher, the new argmatcher gets a separate new empty user_data table.
    • The built-in cd and pushd argmatchers use this to influence match completion for the rest of the input line. E.g. pushd \foo & program Tab uses \foo as the current directory when generating possible completions.
  • Functions registered with clink.onfilterinput() may optionally return multiple lines in a table.
  • Fixed completions for words that contain ., such as clink set color.Tab (regression introduced in v1.3.11).
  • Fixed doskey macros that use echo off $T ....
  • Fixed input line coloring for a drive letter by itself.
  • Fixed input line coloring for a file that exists but is not executable.
  • Fixed obscure edge case with delayinit argmatchers and operate-and-get-next.
  • Fixed potentially inconsistent input line coloring when classifier:applycolor() is given an escape code that sets only the foreground or background color.
clink - v1.3.12

Published by chrisant996 over 2 years ago

Important: Updating to v1.3.10 or higher is recommended in a timely manner: v1.3.1 through v1.3.9 have a memory corruption issue that can eventually lead to a malfunction or crash the more often you use completion.

Changes in v1.3.12

  • Improved clink-select-complete to show inline descriptions as long as they don't require more than 9 rows to display the matches.
  • Added second argument to the delayinit function for an argmatcher.
  • Added argmatcher:setflagsanywhere() and argmatcher:setendofflags() to control where flags are recognized.
  • Added clink.getargmatcher() to find the argmatcher for a command name or command line (line_state).
  • Added os.resolvealias() to expand doskey alias(es) in a line of text.
  • Added clink.oncommand() to register a function to be called when a command is entered in the edit line.
  • Improved support for argmatcher non-flag argument values that end with =: now they can have a linked argmatcher, and input line coloring is applied correctly.
  • Fixed quotes during completion (regression introduced in v1.3.11).
  • Fixed cd /d dir argmatcher (regression introduced in v1.3.11).
  • Fixed input line coloring for "echo" and other CMD commands; quotes disqualify a word from being a CMD command.
  • Fixed redundant argmatcher delayinit for flags.
  • Various minor backward compatibility fixes.
clink - v1.3.11

Published by chrisant996 over 2 years ago

Important: Updating to v1.3.10 or higher is recommended in a timely manner: v1.3.1 through v1.3.9 have a memory corruption issue that can eventually lead to a malfunction or crash the more often you use completion.

Changes in v1.3.11

  • Updated the list of recognized CMD command names.
  • Better support for ( and ) when expanding doskey macros (e.g. now ( macro foo ) & ( macro bar ) works).
  • Fixed word break characters during completion. Only = ; had ever worked before, and now the normal CMD completion word break characters work (including , ! + ( and many others).
  • Fixed match display to not force a single column unless there are descriptions present.
  • Fixed backward compatibility for _argmatcher:add_arguments() and _argmatcher:set_arguments() (they were mistakenly adding all the arguments into the first argument position).
  • Fixed backward compatibility for merging argmatchers.
    • Merging argmatchers works again. It is still a simple merge similar to v0.4.9, but it should be sufficient for common cases.
    • Fixed some bugs in how Clink v0.4.9 merged argmatchers (the unit tests for merging fail in v0.4.9).
    • Added support for some merging cases that weren't implemented yet in v0.4.9.
  • And other obscure minor backward compatibility fixes.
clink - v1.3.10

Published by chrisant996 over 2 years ago

Important: Updating to v1.3.10 is recommended in a timely manner if you are already using v1.3.1 or higher: v1.3.1 through v1.3.9 have a memory corruption issue that can eventually lead to a malfunction or crash the more often you use completion.

Changes in v1.3.10

  • An argmatcher can extend itself on the fly, when needed. For example, if it needs to parse arguments and flags from --help text, or if the available command arguments change based on the current directory, or etc. See Adaptive Argmatchers for more information.
  • Recognizes ^ and environment variables when coloring the command word, and when navigating by typing a directory name by itself.
  • Added input line coloring for the rem command.
  • Fixed memory corruption (regression introduced in v1.3.1).
  • Fixed input line coloring for clink set setting value & another command.
  • Fixed argmatcher input line coloring for matches using the { match="abc" } syntax.
  • Fixed finding an argmatcher after ( at the beginning of the line.
  • Fixed mouse clicks in clink-select-complete to insert the clicked match, in addition to highlighting it.
  • Fixed #252; md and rd should complete more than 1 argument.
clink - v1.3.9

Published by chrisant996 over 2 years ago

  • When argmatcher:addarg() is passed a table containing fromhistory=true then additional matches are generated by parsing the history file to find values for that argument slot from commands in the history file.
  • Added clink.reclassifyline() which triggers input line coloring and redisplays the input line. This is intended for use by a coroutine that has made changes that will affect input line coloring.
  • Added match_builder:isempty().
  • Added mouse horizontal wheel support in clink-select-complete.
  • Added back the _argmatcher:setflagprefix() function.
  • Loading Lua scripts now reports any syntax errors when the lua.debug setting is enabled.
  • Incorporate Lua 5.2.4 (minor patches to the Lua language).
  • Report a warning if the profile directory is configured to point at a file.
  • AutoRun is selected by default again in the installer (reverted change from v1.3.5).
  • The terminal.raw_esc setting now also address the same kind of problem with Alt+[ and Alt+Shift+O as with the Esc key.
  • Fixed when an argmatcher adds nested tables of matches using the { match="abc" } syntax, so that the nested matches are added recursively and properly suppress adding a space after argument matches that end with : or =.
  • Fixed when match_builder:addmatch() and match_builder:addmatches() add nested tables of matches using the { match="abc" } syntax, so that the nested matches are added recursively.
  • Fixed when match_builder:addmatch() and match_builder:addmatches() add an "arg" match type, so that they automatically suppress appending a space after matches that end with : or = (the behavior was documented, but did not work correctly).
  • Fixed remove-history so that it updates the history offset correctly and subsequent editing operations affect the correct undo list.
  • Fixed obscure issues in how certain key binding patterns were reported by clink-show-help and dump-functions.
  • Fixed how clink echo reports Ctrl+Backspace and Ctrl+Alt+Backspace.
  • Fixed #249; sending keystrokes from WScript does nothing for some keys.
  • Fixed #244; installer did not detect previous installation directory (regression introduced in v1.3.5; the fix takes effect on the next install after an install with the fix).
clink - v1.3.8

Published by chrisant996 over 2 years ago

Recent highlights

  • The installer has a new "Use enhanced default settings" option; this activates more of Clink's enhancements by default.
  • Optional mouse input is controlled by the terminal.mouse_input setting.

Changes in v1.3.8

  • Added terminal.mouse_modifier setting and %CLINK_MOUSE_MODIFIER% environment variable; these can override the modifier keys that activate Clink mouse input.
  • Added %CLINK_SETTINGS% environment variable; this can override the directory where the clink_settings file is located. This can be used to put it in a directory that syncs between computers, for example.
  • During clink-select-complete Ctrl+Home or Ctrl+End select the first or last match.
  • When argmatcher:addarg() is passed a table containing nosort=true then the matches are unsorted (displayed in the order listed in the table).
  • The .zip file now contains _default_settings and _default_inputrc so that they do not take effect unless manually renamed to remove the _ name prefix. This avoids changing the defaults unexpectedly.
  • Fixed mouse click+drag in the input line (it accidentally behaved like double click+drag).
  • Fixed the selection highlight width in clink-select-complete when some matches have descriptions but some do not.
  • Fixed argmatcher:addargunsorted() to turn off sort.
  • Fixed #239; crash when F7 and Del.
clink - v1.3.7

Published by chrisant996 over 2 years ago

Recent highlights

  • The installer has a new "Use enhanced default settings" option; this activates more of Clink's enhancements by default.
  • Optional mouse input is controlled by the terminal.mouse_input setting.

Changes in v1.3.7

  • Mouse click+drag now works.
  • Mouse click below clink-select-complete list expands the list instead of dismissing it.
  • Fixed responding to mouse clicks when the terminal's scrollback buffer is not empty (it only worked in Windows Terminal).
  • Fixed #237; installer does not maintain previously selected "Autorun when cmd.exe starts" (regression introduced in v1.3.5).
clink - v1.3.6

Published by chrisant996 over 2 years ago

The installer has a new "Use enhanced default settings" option

This activates several things by default, which previously required manual configuration after installation:

  • Windows-friendly default key bindings (familiar keys in CMD continue to work, rather than being replaced by alternative bash key bindings).
  • Auto-suggestions are enabled.
  • Rich coloring enabled by default, including colors for recognized and unrecognized commands.
  • Case insensitive history search.
  • Keep 25000 lines of history.
  • Performing completion also expands environment variables.
  • If no completions match the typed prefix, then use a substring search instead.

Changes in v1.3.6

  • Added terminal.mouse_input setting; the default is auto. auto lets mouse input work in ConEmu, or in the default Conhost terminal when Quick Edit mode is unchecked in the console Properties dialog. See the documentation for more information.
  • Added cua-select-word command that selects the word at the cursor.
  • Ctrl+X,Ctrl+Z with a numeric argument always includes registered Lua match generators, prompt filters, etc even when the lua.debug setting is off.
  • Fixed potential for a coroutine to have extra delays sometimes when continuing past the end of one edit line, and into the next edit line.
  • Fixed a potential busy loop when the command word is unrecognized.
  • Fixed Quick Edit mode in plain Conhost windows; it had always been disabled (I never noticed because I always configure console windows to disable it anyway).
clink - v1.3.5

Published by chrisant996 over 2 years ago

The installer has a new "Use enhanced default settings" option

This activates several things by default, which previously required manual configuration after installation:

  • Windows-friendly default key bindings (familiar keys in CMD continue to work, rather than being replaced by alternative bash key bindings).
  • Auto-suggestions are enabled.
  • Rich coloring enabled by default, including colors for recognized and unrecognized commands.
  • Case insensitive history search.
  • Keep 25000 lines of history.
  • Performing completion also expands environment variables.
  • If no completions match the typed prefix, then use a substring search instead.

Changes in v1.3.5

  • Raised default history.max_lines to 10000.
  • Added an optional default_inputrc file:
    • It is loaded from the profile directory, or from the binaries directory.
    • It uses the same format as the .inputrc file, and is loaded immediately before the .inputrc files.
    • It has the effect of superseding built-in default values for Readline configuration variables and key bindings; any settings in the .inputrc supersede those in the default_inputrc file.
  • The installer has a new "Use enhanced default settings" option which installs default_settings and default_inputrc files to provide default values that activate more of the Clink enhancements (to give a more enhanced experience "out of the box").
  • The installer no longer defaults to installing AutoRun.
  • The installer no longer has an option to use versioned install directory; files are installed directly in the install directory.
  • Added clink.runcoroutineuntilcomplete() which allows a coroutine to keep running past the end of one edit line, and into the next edit line.
  • Fixed os.execute() return values when run in a coroutine (regression introduced in v1.3.2).
  • Fixed the selection color in clink-select-complete when colored-stats is off.
  • Fixed problems when displaying matches that exceed the screen width.
  • Fixed #231; installer fails sometimes when uncheck "Use versioned install directory".
clink - v1.3.4

Published by chrisant996 over 2 years ago

Try out these color settings!

Setting these will make executable files be colored in blue, and unrecognized commands be colored in red. (If you've used the fish shell before, this will be very familiar.)

clink set color.executable sgr 38;5;32
clink set color.unrecognized sgr 38;5;203

Changes in v1.3.4

  • Pressing Del or Ctrl+D in a command history popup deletes the selected history entry.
  • Changed the default color for directory match completions to bright yellow (bright blue is hard to see).
  • Added an argmatcher for history.
  • Improvements to the default_settings file:
    • It is loaded from the profile directory, or from the binaries directory.
    • Settings are now saved if they are set (vs clear by clink set setting.name clear), even if the set value matches the default value.
  • Minor performance improvement when calculating columns widths when match.fit_columns is enabled.
  • Fixed accidentally using only one column in clink-select-complete when there are 9 or fewer matches and none of them have description text (regression introduced in v1.3.3).
  • Fixed Shift+Right to accept the next full word of the suggestion without clearing the rest of the suggestion (regression introduced in v1.3.3).
  • Fixed terminal emulation for the reverse video escape codes (this also fixes the right border color of the selected item in popup lists).
  • Fixed buffer overrun in Readline yank-last-arg when the previous command ends in a backslash.
  • Fixed the Readline History library to not apply Unix style backslash escaping in CMD (e.g. in program subdir\ text there are 3 arguments; the \ is not an escaped space).
  • Fixed crash when displaying matches and match.fit_columns is enabled and the terminal width is greater than 150 characters.
  • Fixed potential busy loop during idle (until a key is pressed) in certain cases (regression introduced in v1.3.3).
  • Fixed the emulated terminal color conversions from 8-bit and 24-bit.
  • Fixed cursor style when using clink to start a new command window from inside a Windows Terminal window.
  • Fixed quirk when using Clink file completion to complete a directory name for clink --profile \foo\, so that the path doesn't end up malformed.
  • Fixed a memory leak.
clink - v1.3.3

Published by chrisant996 over 2 years ago

Try out these color settings!

Setting these will make executable files be colored in blue, and unrecognized commands be colored in red. (If you've used the fish shell before, this will be very familiar.)

clink set color.executable sgr 38;5;32
clink set color.unrecognized sgr 38;5;203

Changes in v1.3.3

  • Match completion display calculates column widths to fit the most columns on the screen. Can be controlled by the match.fit_columns and match.limit_fitted_columns settings.
  • Match descriptions are right-justified when more than one column is displayed, to help more columns fit.
  • When multiple columns of matches are displayed with descriptions, the descriptions are bracketed with parentheses for readability and accessibility purposes.
  • F1 in clink-select-complete toggles between showing descriptions at the bottom vs with the matches.
  • Added match.substring setting that uses a substring search for completions if none are found with a prefix search.
  • Added color.executable and color.unrecognized settings. When set, these cause the command word (the first word) to be colored if it is recognized as an executable file, or is not recognized as a command, doskey macro, directory, argmatcher, or executable file. Lookups are asynchronous for optimum responsiveness while typing.
  • Argmatchers can hide certain flags (e.g. synonyms) by using argmatcher:hideflags().
  • Argmatchers can disable sorting matches by using argmatcher:addargunsorted() or argmatcher:addflagsunsorted().
  • Generators can disable sorting matches by using match_builder:setnosort().
  • Fixed duplicated closing quote in clink-select-complete.
  • Fixed display of non-directory matches that contain slashes, such as git branch names (regression introduced in v1.3.1).
  • Fixed match display filtering in clink-select-complete (regression introduced in v1.3.1).
  • Fixed the insert-comment command (regression introduced in v1.2.44).
  • Fixed sorting flag completions so that all - flags precede any -- flags.
  • Fixed a couple of memory leaks, and added memory tracking system to more easily catch leaks.
  • Various minor fixes in clink-select-complete.
clink - v1.3.2

Published by chrisant996 almost 3 years ago

  • Added Shift+Space as a recognized key. By default it is bound to clink-shift-space, which invokes whatever is bound to the normal Space key, so that it continues to behave as before unless you specifically bind something else to the Shift+Space key.
  • Added clink-magic-suggest-space command which inserts the next full suggested word (if any) up to a space, and then inserts a space. Binding this to Shift+Space can be very handy.
  • Added cmd.admin_title_prefix setting that can replace the "Administrator: " console title prefix.
  • When loading settings, if there is no setting file yet then Clink looks for a default_settings file in the binaries directory and uses that to initalize the settings.
  • Added CLINK_TERM_VE and CLINK_TERM_VS environment variables that can be set to override the normal (insert mode) and enhanced (overwrite mode) cursor styles, respectively.
  • Various minor fixes to how the cursor style is updated; the visible bell now works in Windows Terminal.
  • When os.execute() is used in a coroutine, it automatically yields until complete.
  • Fixed async match generators (during autosuggest) to be allowed to finish, instead of getting canceled on every keystroke if they hadn't finished yet.
  • Fixed cursor blink, which was accidentally disabled (regression introduced in v1.2.44).
  • Fixed the win-cursor-forward command so it doesn't trigger generating a new suggestion if there isn't already one.