Bash's powerful command line editing in cmd.exe
GPL-3.0 License
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
).
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
).
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
).
directories.dupe_mode
setting that controls how duplicates are handled in the directory history list for the clink-popup-directories
command.clink-popup-directories
command.delayinit
argmatchers.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
).
clink update
to apply the update.clink-insert-suggested-line
, clink-insert-suggested-word
, clink-insert-suggested-full-word
, and clink-accept-suggested-line
commands (see #280).history.time_stamp
and history.time_format
settings control whether timestamps are saved and whether/how timestamps are shown.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.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).rl.gethistorycount()
and rl.gethistoryitems()
to access the history items.os.gettemppath()
to get the system temporary directory.io.sopen()
to control sharing access when opening or creating a file.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.what-is
command to apply word wrapping to the command description.fromhistory=true
) in argmatchers (regression introduced in v1.3.13).+
characters.terminal.mouse_input
is enabled.clink.popuplist()
.terminal.raw_esc
setting is enabled.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
).
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
).
os.sleep()
.history
command when invalid flags are used.history
command reports an error message accordingly.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
).
os.globfiles()
and os.globdirs()
functions in Lua scripts.os.issignaled()
so Lua scripts can cooperatively interrupt themselves.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).copy
command prompts whether to overwrite a file (regression introduced in v1.3.13).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
).
os.globfiles()
and os.globdirs()
functions in Lua scripts.os.issignaled()
so Lua scripts can cooperatively interrupt themselves.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).copy
command prompts whether to overwrite a file (regression introduced in 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
).
:chaincommand()
to treat the rest of the command line as another command.
cmd
that uses :chaincommand()
.cmd program
can be parsed by an argmatcher for program
instead of cmd
.onarg=your_callback_function
in the table given to :addarg()
.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.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.clink.onfilterinput()
may optionally return multiple lines in a table..
, such as clink set color.
Tab (regression introduced in v1.3.11).echo off $T ...
.operate-and-get-next
.classifier:applycolor()
is given an escape code that sets only the foreground or background color.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.
clink-select-complete
to show inline descriptions as long as they don't require more than 9 rows to display the matches.delayinit
function for an argmatcher.argmatcher:setflagsanywhere()
and argmatcher:setendofflags()
to control where flags are recognized.clink.getargmatcher()
to find the argmatcher for a command name or command line (line_state
).os.resolvealias()
to expand doskey alias(es) in a line of text.clink.oncommand()
to register a function to be called when a command is entered in the edit line.=
: now they can have a linked argmatcher, and input line coloring is applied correctly.cd /d dir
argmatcher (regression introduced in v1.3.11)."echo"
and other CMD commands; quotes disqualify a word from being a CMD command.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.
(
and )
when expanding doskey macros (e.g. now ( macro foo ) & ( macro bar )
works).=
;
had ever worked before, and now the normal CMD completion word break characters work (including ,
!
+
(
and many others)._argmatcher:add_arguments()
and _argmatcher:set_arguments()
(they were mistakenly adding all the arguments into the first argument position).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.
--help
text, or if the available command arguments change based on the current directory, or etc. See Adaptive Argmatchers for more information.^
and environment variables when coloring the command word, and when navigating by typing a directory name by itself.rem
command.clink set setting value & another command
.{ match="abc" }
syntax.(
at the beginning of the line.clink-select-complete
to insert the clicked match, in addition to highlighting it.md
and rd
should complete more than 1 argument.Published by chrisant996 over 2 years ago
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.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.match_builder:isempty()
.clink-select-complete
._argmatcher:setflagprefix()
function.lua.debug
setting is enabled.terminal.raw_esc
setting now also address the same kind of problem with Alt+[ and Alt+Shift+O as with the Esc key.{ match="abc" }
syntax, so that the nested matches are added recursively and properly suppress adding a space after argument matches that end with :
or =
.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.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).remove-history
so that it updates the history offset correctly and subsequent editing operations affect the correct undo list.clink-show-help
and dump-functions
.clink echo
reports Ctrl+Backspace and Ctrl+Alt+Backspace.Published by chrisant996 over 2 years ago
terminal.mouse_input
setting.terminal.mouse_modifier
setting and %CLINK_MOUSE_MODIFIER%
environment variable; these can override the modifier keys that activate Clink mouse input.%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.clink-select-complete
Ctrl+Home or Ctrl+End select the first or last match.argmatcher:addarg()
is passed a table containing nosort=true
then the matches are unsorted (displayed in the order listed in the table)._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.clink-select-complete
when some matches have descriptions but some do not.argmatcher:addargunsorted()
to turn off sort.Published by chrisant996 over 2 years ago
terminal.mouse_input
setting.clink-select-complete
list expands the list instead of dismissing it.Published by chrisant996 over 2 years ago
This activates several things by default, which previously required manual configuration after installation:
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.cua-select-word
command that selects the word at the cursor.lua.debug
setting is off.Published by chrisant996 over 2 years ago
This activates several things by default, which previously required manual configuration after installation:
history.max_lines
to 10000.default_inputrc
file:
.inputrc
file, and is loaded immediately before the .inputrc
files..inputrc
supersede those in the default_inputrc
file.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").clink.runcoroutineuntilcomplete()
which allows a coroutine to keep running past the end of one edit line, and into the next edit line.os.execute()
return values when run in a coroutine (regression introduced in v1.3.2).clink-select-complete
when colored-stats
is off.Published by chrisant996 over 2 years ago
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
history
.default_settings
file:
clink set setting.name clear
), even if the set value matches the default value.match.fit_columns
is enabled.clink-select-complete
when there are 9 or fewer matches and none of them have description text (regression introduced in v1.3.3).yank-last-arg
when the previous command ends in a backslash.program subdir\ text
there are 3 arguments; the \
is not an escaped space).match.fit_columns
is enabled and the terminal width is greater than 150 characters.clink
to start a new command window from inside a Windows Terminal window.clink --profile \foo\
, so that the path doesn't end up malformed.Published by chrisant996 over 2 years ago
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
match.fit_columns
and match.limit_fitted_columns
settings.clink-select-complete
toggles between showing descriptions at the bottom vs with the matches.match.substring
setting that uses a substring search for completions if none are found with a prefix search.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.argmatcher:hideflags()
.argmatcher:addargunsorted()
or argmatcher:addflagsunsorted()
.match_builder:setnosort()
.clink-select-complete
.clink-select-complete
(regression introduced in v1.3.1).insert-comment
command (regression introduced in v1.2.44).-
flags precede any --
flags.clink-select-complete
.Published by chrisant996 almost 3 years ago
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.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.cmd.admin_title_prefix
setting that can replace the "Administrator: " console title prefix.default_settings
file in the binaries directory and uses that to initalize the settings.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.os.execute()
is used in a coroutine, it automatically yields until complete.win-cursor-forward
command so it doesn't trigger generating a new suggestion if there isn't already one.