Jump to content

Recommended Posts

  • Active Members
Posted

Bringing Bash's powerful command line editing to Microsoft Windows' cmd.exe

Introduction

EuTRT.png

Clink enhances your productivity in Microsoft Windows' "cmd.exe".

If you're familiar with Bash then you will be familiar with the changes that clink brings to "cmd.exe" (it uses the same 'Readline' library that Bash uses). It is a small utility to enhance "cmd.exe", adding more powerful command line completion, editing, and history.

Features

  • Powerful Bash-like line editing from GNU's Readline library. Read more on Readline's keyboard shortcuts.
  • Superior path completion (TAB).
  • Paste from clipboard (Ctrl-V).
  • Support for the completion of executables/commands, and environment variables.
  • Undo/Redo (Ctrl-_ or Ctrl-X, Ctrl-U)
  • Improved command line history.
    • Persists across sessions.
    • Searchable (Ctrl-R and Ctrl-S).
    • History expansion (e.g. !!, !<string>, and !$).

    [*] Scriptable completion using Lua.

Usage

There are a variety of ways to start clink;

If you installed the auto-run, start "cmd.exe" as per usual.

To manually start, run the clink shortcut from the Start menu (or the clink.bat located in the install directory).

To deploy clink to an existing cmd.exe process, use "<install_dir>\clink.exe inject"

clink has been tested on Windows XP SP3 and upwards.

Visual C++ Redistributable requirement

clink requires that the Microsoft's Visual C++ 2010 Redistributable be install on your system. If you need to install them they can be found here;

Writing completion scripts with Lua

It is easy to customise completion in clink with simple Lua scripts. It is a matter of writing a match generator function and registering the function with clink. When called the generator function adds matches to clink - if appropriate.

A very basic example script gives the best overview of what is involved;

-- Globals;
-- rl_line_buffer : The current command line.
-- rl_point : Current location of the cursor.


function example_match_generator(text, first, last)
-- Arguments;
-- text : The word being completed, as tokenised by Readline.
-- first : The index into rl_line_buffer where 'text' starts.
-- last : Index into rl_line_buffer where 'text' ends.


-- Returns;
-- true : No further generator functions should be called.
-- false : Generator has done nothing. Try the next generator.


-- In this simple example generate a match when the user types
-- the following; my_ma<TAB> if not rl_line_buffer == "my_ma" then
return false
end


clink.add_match("my_match")
return true
end


-- clink.register_match_generator(<function>, <priority>)
clink.register_match_generator(example_match_generator, 50)

Further examples can be found in clink's install directory.

User's Lua scripts go in %ALLUSERSPROFILE%\clink\ (which is usually C:\ProgramData\clink\) and clink loads the .lua files it finds there. The keyboard shortcut Ctrl-Q will force clink to reload the Lua scripts - useful when writing your own scripts.

Changing match display colour

  1. Create a new Lua script in %ALLUSERSPROFILE%\clink\
  2. Add the following line (where X is a number in the range 0-15);

clink.setpalette(X)


  1. For values for X run "color /?" on a command prompt.

Building clink

  1. Download Premake from here; Premake | Industrious One
    • There is a bug in Premake 4.3 that generates corrupt .vcxproj files. Please use 4.4 (or newer).

[*] Run "premake <toolchain>" in the root of clink's source tree.

  • Where "<toolchain>" is one of Premake's actions (see "premake --help")
  • clink has been tested with vs2010, gmake (with mingw32), and vs2008.

[*] Build scripts will be generated in ".build\<toolchain>\". For example; .build\vs2010\clink.sln.

Builds

Builds from the git repository can be found here;

https://www.dropbox.com/sh/r9oqmn2mqfp3okp/Jm_F3pJSNI

Downloads

Source: https://code.google.com/p/clink/

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...