.tclshrc
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 11 Dec 2023 00:27:20 +0200
changeset 1037 b386e087b97f
parent 635 799341bb0ea7
permissions -rw-r--r--
Added workaround for Cygwin, npm authors explicitly forbids it: npm/lib/commands/completion.js if (isWindowsShell) { const msg = 'npm completion supported only in MINGW / Git bash on Windows' throw Object.assign(new Error(msg), {
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
632
500dcbf3445d Add readline and completion support to tclsh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     1
# -*- mode: tcl -*-
500dcbf3445d Add readline and completion support to tclsh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
500dcbf3445d Add readline and completion support to tclsh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     3
if {$tcl_interactive} {
634
89a1a77ad559 Add check for tclreadline package and terminal color support.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 632
diff changeset
     4
    catch {
89a1a77ad559 Add check for tclreadline package and terminal color support.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 632
diff changeset
     5
        package require tclreadline
89a1a77ad559 Add check for tclreadline package and terminal color support.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 632
diff changeset
     6
        namespace eval tclreadline {
89a1a77ad559 Add check for tclreadline package and terminal color support.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 632
diff changeset
     7
            if ([regexp "^(xterm|eterm-color)" "$::env(TERM)"]) {
89a1a77ad559 Add check for tclreadline package and terminal color support.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 632
diff changeset
     8
                proc prompt1 {} { return "\[0;31m\[1mtcl>\[0m " }
635
799341bb0ea7 Add prompt2 style.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 634
diff changeset
     9
                proc prompt2 {} { return "\[0;31m...> \[0m" }
634
89a1a77ad559 Add check for tclreadline package and terminal color support.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 632
diff changeset
    10
            } {
89a1a77ad559 Add check for tclreadline package and terminal color support.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 632
diff changeset
    11
                proc prompt1 {} { return "tcl> " }
635
799341bb0ea7 Add prompt2 style.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 634
diff changeset
    12
                proc prompt2 {} { return "...> " }
634
89a1a77ad559 Add check for tclreadline package and terminal color support.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 632
diff changeset
    13
            }
89a1a77ad559 Add check for tclreadline package and terminal color support.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 632
diff changeset
    14
        }
89a1a77ad559 Add check for tclreadline package and terminal color support.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 632
diff changeset
    15
        ::tclreadline::Loop
89a1a77ad559 Add check for tclreadline package and terminal color support.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 632
diff changeset
    16
    }
632
500dcbf3445d Add readline and completion support to tclsh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    17
}