Last active
March 20, 2025 17:23
-
-
Save jevinskie/7e5e008e4d04bbd281fc72462b1568e7 to your computer and use it in GitHub Desktop.
.tclshrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# if [[ -d ~/.tcl/brew-tcl-8-6-16 ]]; then | |
# export MY_TCL_ROOT=~/.tcl/brew-tcl-8-6-16 | |
# export TCLLIBPATH=$MY_TCL_ROOT/lib | |
# export TCL_EXEC_PREFIX=$MY_TCL_ROOT | |
# export PATH=$MY_TCL_ROOT/bin:$PATH | |
# fi | |
namespace eval TclshLoader { | |
set tcl_rcFileDir [file join $::env(HOME) .tcl rcfiles] | |
if {[expr {[file exists $tcl_rcFileDir] && [file isdirectory $tcl_rcFileDir]}]} { | |
set tcl_rcFiles [glob -type {f r} -directory $tcl_rcFileDir -- *.tcl] | |
# put tclreadline.tcl last since it enters a loop and prevents further execution of .tclsh/.wishsh | |
set tcl_rcFiles_tclreadlineIdx [lsearch -glob $tcl_rcFiles */tclreadline.tcl] | |
if {[expr {($tcl_rcFiles_tclreadlineIdx != -1) && ([llength $tcl_rcFiles] > 1)}]} { | |
set tcl_rcFiles_tclreadlinePath [lindex $tcl_rcFiles $tcl_rcFiles_tclreadlineIdx] | |
set tcl_rcFiles [lreplace $tcl_rcFiles $tcl_rcFiles_tclreadlineIdx $tcl_rcFiles_tclreadlineIdx] | |
lappend tcl_rcFiles $tcl_rcFiles_tclreadlinePath | |
} | |
# puts "tcl_rcFiles: $tcl_rcFiles" | |
unset tcl_rcFiles_tclreadlineIdx | |
unset -nocomplain tcl_rcFiles_tclreadlinePath | |
set tcl_rcFiles_lastIdx [expr [llength $tcl_rcFiles] - 1] | |
set tcl_rcFiles_idx 0 | |
interp alias {} lambda {} proc {} | |
foreach tcl_rcFiles_rcFile $tcl_rcFiles { | |
# puts "sourcing $tcl_rcFiles_rcFile" | |
namespace eval :: { | |
if {[expr $TclshLoader::tcl_rcFiles_idx == $TclshLoader::tcl_rcFiles_lastIdx]} { | |
unset TclshLoader::tcl_rcFiles_idx | |
unset TclshLoader::tcl_rcFiles_lastIdx | |
source [[lambda f {unset TclshLoader::tcl_rcFiles_rcFile; return $f}] $TclshLoader::tcl_rcFiles_rcFile] | |
} else { | |
source $TclshLoader::tcl_rcFiles_rcFile | |
} | |
} | |
incr tcl_rcFiles_idx | |
} | |
} else { | |
unset tcl_rcFileDir | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment