Конфигурация tclsh шелла .tclshrc

За конфиг спасибо Данилову Александру, который когда-то поделился им со мной. Если я правильно ошибаюсь, то исходник был найден в вики и допилен по месту. Поддерживается история команд и вызов внешних утилит. При желании можно автоматически загружать нужные пакеты расширений и проч.

.tclshrc

if {$tcl_interactive == 1} {

# set pglib_path "/usr/lib/libpgtcl1.5/libpgtcl1.5.so"
# load $pglib_path
# set sqlitelib_path "/usr/lib/sqlite3/libtclsqlite3.so.0"
# load $sqlitelib_path

lappend auto_path /usr/local/lib
puts "auto_path: $auto_path"

interp alias {} printenv {} parray env

if {$tcl_platform(platform) eq "unix"} {
proc help {command} {
exec xterm -e man -S 3tcl:3tk $command &
return
}
}
proc lspackages {{pattern *}} {
# Force the package loader to do its thing:
# NOTE: this depends on a side effect of the
# built-in [package unknown]. Other [package unknown]
# handlers might not meet our expectations.
eval [package unknown] Tcl [package provide Tcl]
foreach package [lsort [package names]] {
if {![string match $pattern $package]} { continue }
foreach version [package versions $package] {
set present [expr {
[string compare $version [package provide $package]]
? " " : "+" }]
set ifneeded \
[string replace \
[string trim \
[string map {"\n" " " "\t" " "} \
[package ifneeded $package $version]]] \
50 end "..."]
puts [format "%1s%-15s %6s %-55s" \
$present $package $version $ifneeded]
}
}
}

if {$::env(TERM) ne "dumb"} {
package require tclreadline

# uncomment the following if block, if you
# want `ls' executed after every `cd'. (This was
# the default up to 0.8 == tclreadline_version.)
#
# if {"" == [info procs cd]} {
# catch {rename ::tclreadline::Cd ""}
# rename cd ::tclreadline::Cd
# proc cd {args} {
# if {[catch {eval ::tclreadline::Cd $args} message]} {
# puts stderr "$message"
# }
# tclreadline::ls
# }
# }

# uncomment the following line to use
# tclreadline's fancy ls proc.
#
# namespace import tclreadline::ls

# tclreadline::Print is on (`yes') by default.
# This mimics the command echoing like in the
# non-readline interactive tclsh.
# If you don't like this, uncomment the following
# line.
#
# tclreadline::Print no

# uncomment the folling line, if you want
# to change tclreadline's print behaviour
# frequently with less typing.
#
# namespace import tclreadline::Print

# store maximal this much lines in the history file
#
set tclreadline::historyLength 200

# disable tclreadline's script completer
#
# ::tclreadline::readline customcompleter ""

# go to tclrealdine's main loop.
#
tclreadline::Loop
}

}

Comments

Popular posts from this blog

Открытый софт для научных расчетов

Счетчики в SQLite

Обработка email-сообщений