https://github.com/wakatime/tcl-prompt
Tcl plugin for powerlevel10k style prompt and WakaTime time tracking
https://github.com/wakatime/tcl-prompt
expect tcl tk vitis vivado wakatime xsct
Last synced: 5 months ago
JSON representation
Tcl plugin for powerlevel10k style prompt and WakaTime time tracking
- Host: GitHub
- URL: https://github.com/wakatime/tcl-prompt
- Owner: wakatime
- License: gpl-3.0
- Created: 2023-08-28T09:40:10.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-04T20:27:13.000Z (almost 2 years ago)
- Last Synced: 2025-02-17T09:28:09.561Z (8 months ago)
- Topics: expect, tcl, tk, vitis, vivado, wakatime, xsct
- Language: Tcl
- Homepage:
- Size: 49.8 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# tcl-prompt
[](https://results.pre-commit.ci/latest/github/wakatime/tcl-prompt/main)
[](https://github.com/wakatime/tcl-prompt/releases)
[](https://github.com/wakatime/tcl-prompt/releases/latest)
[](https://github.com/wakatime/tcl-prompt/issues)
[](https://github.com/wakatime/tcl-prompt/issues?q=is%3Aissue+is%3Aclosed)
[](https://github.com/wakatime/tcl-prompt/pulls)
[](https://github.com/wakatime/tcl-prompt/pulls?q=is%3Apr+is%3Aclosed)
[](https://github.com/wakatime/tcl-prompt/discussions)
[](https://github.com/wakatime/tcl-prompt/milestones)
[](https://github.com/wakatime/tcl-prompt/network/members)
[](https://github.com/wakatime/tcl-prompt/stargazers)
[](https://github.com/wakatime/tcl-prompt/watchers)
[](https://github.com/wakatime/tcl-prompt/graphs/contributors)
[](https://github.com/wakatime/tcl-prompt/graphs/commit-activity)
[](https://github.com/wakatime/tcl-prompt/commits)
[](https://github.com/wakatime/tcl-prompt/releases/latest)[](https://github.com/wakatime/tcl-prompt/blob/main/LICENSE)
[](https://github.com/wakatime/tcl-prompt)
[](https://github.com/wakatime/tcl-prompt)
[](https://github.com/wakatime/tcl-prompt)
[](https://github.com/wakatime/tcl-prompt)
[](https://github.com/wakatime/tcl-prompt)
[](https://github.com/wakatime/tcl-prompt)This project provides:
- A [powerlevel10k](https://github.com/romkatv/powerlevel10k)-like prompt for
[tcl](https://www.tcl.tk)s REPL `tclsh` and [tk](https://www.tcl.tk/)'s REPL
`wish`.

- A [wakatime](https://wakatime.com/) 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:- [`expect`](https://expect.sourceforge.net)
- [vivado](https://www.xilinx.com/products/design-tools/vivado.html)'s
[`vivado -mode tcl`](https://docs.xilinx.com/r/en-US/ug835-vivado-tcl-commands)
- [vitis](https://www.xilinx.com/products/design-tools/vitis.html)'s
[`xsct`](https://docs.xilinx.com/r/en-US/ug1400-vitis-embedded)


## Dependencies
- [tclreadline](https://github.com/flightaware/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](https://core.tcl-lang.org/tcllib): Provide some functions and
variables about ANSI colors.## Install
### [AUR](https://aur.archlinux.org/packages/tcl-prompt)
```sh
paru -S tcl-prompt-git
```### [NUR](https://nur.nix-community.org/repos/freed-wu)
```sh
nix-env -iA nixos.nur.repos.wakatime.tcl-prompt
```## Usage
`~/.tclshrc`:
```tcl
package require prompt::tclreadline::Loop
```## Customize
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 spaces
- `sep` separate every section of prompt string.
- `text_or_function` can be a text or function. Such as:
- `::prompt::wakatime`: statistic time. Output nothing. Ignore `fg_color` and
`bg_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.```tcl
# ::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`:```tcl
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.```tcl
set ::prompt::wakatime_cmd {exec wakatime-cli --write --plugin=repl-tcl-wakatime --entity-type=app --entity=tcl --alternate-language=tcl --project=%s &}
```