From 6f56dd6cd0969d59d9b10683e5a2ac02a1bee0ee Mon Sep 17 00:00:00 2001 From: Chris Antos Date: Thu, 24 Aug 2023 11:01:25 -0700 Subject: [PATCH] Add inputrc syntax highlighting in docs. --- docs/clink.html | 6 +++ docs/clink.md | 119 +++++++++++++++++++++++++----------------------- 2 files changed, 67 insertions(+), 58 deletions(-) diff --git a/docs/clink.html b/docs/clink.html index 01d33ef89..5992e19ec 100644 --- a/docs/clink.html +++ b/docs/clink.html @@ -14,6 +14,12 @@ function go() { // Apply syntax highlighting. + const COMMENT=hljs.COMMENT("#", "$"); + const STRING={className:'string',begin:'"',end:'"',contains:[hljs.BACKSLASH_ESCAPE]}; + const OPERATOR={className:'name',begin:/\:/}; + const PREPROCESSOR={className:'meta',begin:/\$[a-z]+\b/,end:/$/,keywords:{keyword:'$if $else $endif $include'},contains:[{begin:/\\\n/,relevance:0},COMMENT]}; + const INPUTRC={name:"inputrc",case_insensitive:true,keywords:{keyword:"set",literal:"on off true false"},contains:[COMMENT,STRING,OPERATOR,PREPROCESSOR]}; + hljs.registerLanguage("inputrc",function(){"use strict";return function(e){return INPUTRC}}()); hljs.initHighlighting(); // Fix hyperlink styling inside highlighted comments. diff --git a/docs/clink.md b/docs/clink.md index 565f0229b..29dcf5e56 100644 --- a/docs/clink.md +++ b/docs/clink.md @@ -87,6 +87,8 @@ See [Key Bindings](#gettingstarted_keybindings) to learn more. Optional auto-answering of the "[Terminate batch job?](#cmd_auto_answer)" prompt. +[Enhanced doskey expansion](#enhanced-doskey-expansion) even after `&` and `|`. + [Directory shortcuts](#directory-shortcuts): - `dirname\` is a shortcut for `cd /d` to that directory. - `..` or `...` are shortcuts for `cd ..` or `cd ..\..` (etc). @@ -205,7 +207,7 @@ notepad %userprofile%\.inputrc You may want to copy/paste the following sample text into the file as a starting point, and then press Ctrl-S to save the file. -```plaintext +```inputrc # Some common Readline config settings. set colored-stats on # Turn on completion colors. @@ -1032,14 +1034,14 @@ Key bindings can be either functions or macros (literal text). Functions are no When entering the text of a macro, single or double quotes must be used to indicate a macro definition. Unquoted text is assumed to be a function name. In the macro body, the backslash escapes described above are expanded. Backslash will quote any other character in the macro text, including `"` and `'`. For example, the following binding will make pressing Ctrl-x \\ insert a single `\` into the line: -```plaintext +```inputrc "\C-x\\": "\\" ```

Examples
-```plaintext +```inputrc # Using key names. C-u: universal-argument # Bind Ctrl-u to invoke the universal-argument command. C-o: "> output" # Bind Ctrl-o to insert the text "> output" into the line. @@ -1064,7 +1066,7 @@ The `$if` construct allows bindings to be made based on the editing mode, the te The `$if mode=` form of the `$if` directive is used to test whether Readline is in `emacs` or `vi` mode. This may be used in conjunction with the "set keymap" command, for instance, to set bindings in the `emacs-standard` and `emacs-ctlx` keymaps only if Readline is starting out in `emacs` mode. (The directive is only tested during startup.) -```plaintext +```inputrc $if mode == emacs set show-mode-in-prompt on $endif @@ -1074,7 +1076,7 @@ The `$if term=` form may be used to include terminal-specific key bindings, perh The `$if version` test may be used to perform comparisons against specific Readline versions. The `version` expands to the current Readline version. The set of comparison operators includes `=` (and `==`), `!=`, `<=`, `>=`, `<`, and `>`. The version number supplied on the right side of the operator consists of a major version number, an optional decimal point, and an optional minor version (e.g., "7.1"). If the minor version is omitted, it is assumed to be "0". The operator may be separated from the string `version` and from the version number argument by whitespace. The following example sets a variable if the Readline version being used is 7.0 or newer: -```plaintext +```inputrc $if version >= 7.0 set show-mode-in-prompt on $endif @@ -1082,7 +1084,7 @@ $endif The `$if application` construct is used to include application-specific settings. Each program using the Readline library sets the _application name_, and you can test for a particular value. This could be used to bind key sequences to functions useful for a specific program. For instance, the following command adds a key sequence that quotes the current or previous word, but only in Clink: -```plaintext +```inputrc $if clink # Quote the current or previous word "\C-xq": "\eb\"\ef\"" @@ -1091,7 +1093,7 @@ $endif The `$if variable` construct provides simple equality tests for Readline variables and values. The permitted comparison operators are `=`, `==`, and `!=`. The variable name must be separated from the comparison operator by whitespace; the operator may be separated from the value on the right hand side by whitespace. Both string and boolean variables may be tested. Boolean variables must be tested against the values _on_ and _off_. The following example is equivalent to the `mode=emacs` test described above: -```plaintext +```inputrc $if editing-mode == emacs set show-mode-in-prompt on $endif @@ -1112,7 +1114,7 @@ Commands in this branch of the `$if` directive are executed if the test fails. This directive takes a single filename as an argument and reads commands and bindings from that file. For example, the following directive reads from "c:\dir\inputrc": -```plaintext +```inputrc $include c:\dir\inputrc ``` @@ -1121,56 +1123,57 @@ $include c:\dir\inputrc Here is a sample `.inputrc` file with some of the variables and key bindings that I use: -
$if clink           # begin clink-only section
-
-set colored-completion-prefix                       on
-set colored-stats                                   on
-set mark-symlinked-directories                      on
-set visible-stats                                   off
-set completion-auto-query-items                     on
-set history-point-at-end-of-anchored-search         on
-set menu-complete-wraparound                        off
-set search-ignore-case                              on
-
-# The following key bindings are for emacs mode.
-set keymap emacs
-
-"\e[27;8;72~":      clink-popup-show-help           # Alt-Ctrl-Shift-H
-
-# Completion key bindings.
-"\t":               old-menu-complete               # Tab
-"\e[Z":             old-menu-complete-backward      # Shift-Tab
-"\e[27;5;32~":      clink-select-complete           # Ctrl-Space
-
-# Some key bindings I got used to from 4Dos/4NT/Take Command.
-C-b:                                                # Ctrl-B (cleared because I redefined Ctrl-F)
-C-d:                remove-history                  # Ctrl-D (replaces `delete-char`)
-C-f:                clink-expand-doskey-alias       # Ctrl-F (replaces `forward-char`)
-C-k:                add-history                     # Ctrl-K (replaces `kill-line`)
-"\e[A":             history-search-backward         # Up (replaces `previous-history`)
-"\e[B":             history-search-forward          # Down (replaces `next-history`)
-"\e[5~":            clink-popup-history             # PgUp (replaces `history-search-backward`)
-"\e[6~":                                            # PgDn (cleared because I redefined PgUp)
-"\e[1;5F":          end-of-line                     # Ctrl-End (replaces `kill-line`)
-"\e[1;5H":          beginning-of-line               # Ctrl-Home (replaces `backward-kill-line`)
-
-# Some key bindings handy in default (conhost) console windows.
-M-b:                                                # Alt-B (cleared because I redefined Alt-F)
-M-f:                clink-find-conhost              # Alt-F for "Find..." from the console's system menu
-M-m:                clink-mark-conhost              # Alt-M for "Mark" from the console's system menu
-
-# Some key bindings for interrogating the Readline configuration.
-"\C-x\C-f":         dump-functions                  # Ctrl-X, Ctrl-F
-"\C-x\C-m":         dump-macros                     # Ctrl-X, Ctrl-M
-"\C-x\C-v":         dump-variables                  # Ctrl-X, Ctrl-V
-
-# Misc other key bindings.
-"\e[27;2;32~":      clink-magic-suggest-space       # Shift-Space
-"\e[5;6~":          clink-popup-directories         # Ctrl-Shift-PgUp
-C-_:                kill-line                       # Ctrl-- (replaces `undo`)
-
-$endif              # end clink-only section
-
+```inputrc +$if clink # begin clink-only section + +set colored-completion-prefix on +set colored-stats on +set mark-symlinked-directories on +set visible-stats off +set completion-auto-query-items on +set history-point-at-end-of-anchored-search on +set menu-complete-wraparound off +set search-ignore-case on + +# The following key bindings are for emacs mode. +set keymap emacs + +"\e[27;8;72~": clink-popup-show-help # Alt-Ctrl-Shift-H + +# Completion key bindings. +"\t": old-menu-complete # Tab +"\e[Z": old-menu-complete-backward # Shift-Tab +"\e[27;5;32~": clink-select-complete # Ctrl-Space + +# Some key bindings I got used to from 4Dos/4NT/Take Command. +C-b: # Ctrl-B (cleared because I redefined Ctrl-F) +C-d: remove-history # Ctrl-D (replaces `delete-char`) +C-f: clink-expand-doskey-alias # Ctrl-F (replaces `forward-char`) +C-k: add-history # Ctrl-K (replaces `kill-line`) +"\e[A": history-search-backward # Up (replaces `previous-history`) +"\e[B": history-search-forward # Down (replaces `next-history`) +"\e[5~": clink-popup-history # PgUp (replaces `history-search-backward`) +"\e[6~": # PgDn (cleared because I redefined PgUp) +"\e[1;5F": end-of-line # Ctrl-End (replaces `kill-line`) +"\e[1;5H": beginning-of-line # Ctrl-Home (replaces `backward-kill-line`) + +# Some key bindings handy in default (conhost) console windows. +M-b: # Alt-B (cleared because I redefined Alt-F) +M-f: clink-find-conhost # Alt-F for "Find..." from the console's system menu +M-m: clink-mark-conhost # Alt-M for "Mark" from the console's system menu + +# Some key bindings for interrogating the Readline configuration. +"\C-x\C-f": dump-functions # Ctrl-X, Ctrl-F +"\C-x\C-m": dump-macros # Ctrl-X, Ctrl-M +"\C-x\C-v": dump-variables # Ctrl-X, Ctrl-V + +# Misc other key bindings. +"\e[27;2;32~": clink-magic-suggest-space # Shift-Space +"\e[5;6~": clink-popup-directories # Ctrl-Shift-PgUp +C-_: kill-line # Ctrl-- (replaces `undo`) + +$endif # end clink-only section +``` ## Bindable Commands