~q3cpma/dotfiles

dotfiles/.tclshrc -rw-r--r-- 889 bytes
eb1d763dq3cpma Sync 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
if {$tcl_interactive} {
	if {[file readable ~/Programming/Tcl/util.tcl]} {
		source ~/Programming/Tcl/util.tcl
	}

	package require tclreadline
	proc ::tclreadline::prompt1 {} {
		global env

		catch {pwd} pwd
		# Replace leading env(HOME) by ~
		if [info exists env(HOME)] {
			set strlen [string length $env(HOME)]
			if {[string equal -len $strlen $env(HOME) $pwd]} {
				set pwd [string replace $pwd 0 [expr {$strlen - 1}] ~]
			}
		}
		string cat "\x1[util::tput setaf 1]\x2" \
			"\[$pwd\]" \
			"\x1[util::tput sgr0]\x2" \
			" "
		# string cat "\[$pwd\] "
	}

	::tclreadline::readline historyexpansion 0
	set tclreadline::autosave 1
	# Workaround tclreadline setting COLUMNS/LINES but not updating them
	# with SIGWINCH
	after idle {
		# unset doesn't work because of a Tcl bug, use array unset instead
		array unset ::env COLUMNS
		array unset ::env LINES
	}
	tclreadline::Loop
}