This project provides:
- A powerlevel10k-like prompt for
tcls REPL
tclsh
and tk's REPLwish
.
- A wakatime plugin to statistics how much time you write tcl in REPL.
Besides tcl's tclsh
and tk's wish
, there are many programs written in tcl
which provide their REPLs. This project provides some wrapper scripts to use
this plugin for them:
- tclreadline: Provide a function
::tclreadline::prompt1
. Every read-eval-print-loop the function will be called and it's result will be used as prompt string. - tcllib: Provide some functions and variables about ANSI colors.
paru -S tcl-prompt-git
nix-env -iA nixos.nur.repos.wakatime.tcl-prompt
~/.tclshrc
:
package require prompt
::tclreadline::Loop
You can redefined ::tclreadline::prompt1
. This project provides a function
::prompt::get_ps1
to generate prompt string.
str
is last string, such as>
,$
.format
can be%s
to add padding white spacessep
separate every section of prompt string.text_or_function
can be a text or function. Such as:::prompt::wakatime
: statistic time. Output nothing. Ignorefg_color
andbg_color
.::prompt::get_icon
: output OS icon.::prompt::icon
: OS icon.::prompt::get_version
: output tcl version.::prompt::version
: tcl version.::prompt::get_cwd
: output current working directory. Use~
to replace$HOME
.::prompt::get_time
: output current time.
# ::prompt::get_ps1 [str] [[format] {fg_color bg_color text_or_function} [sep]] ...
proc ::tclreadline::prompt1 {} {
return [::prompt::get_ps1 ...]
}
If you just want to statistic time for wakatime and don't want to customize
your prompt string. Just call ::prompt::wakatime
in ::tclreadline::prompt1
:
proc ::tclreadline::prompt1 {} {
::prompt::wakatime
return {$}
# or other simple prompt string
}
By default, It uses the base name of current working directory as your project name.
You can remove --project=%s
from ::prompt::wakatime_cmd
to disable it.
If there is a git repository, the project name can be achieved by git
. Else
use the base name of current working directory.
set ::prompt::wakatime_cmd {exec wakatime-cli --write --plugin=repl-tcl-wakatime --entity-type=app --entity=tcl --alternate-language=tcl --project=%s &}