File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ python.uv_venv_create_args = ["--seed"]
1212terminal_progress = false
1313lockfile = true
1414
15+ [hooks ]
16+ enter = { script = ' set_terminal_title' , shell = " zsh" }
17+ leave = { script = " reset_terminal_title" , shell = " zsh" }
1518
1619[tools ]
1720rust = " nightly"
Original file line number Diff line number Diff line change 1- #! /usr/env zsh
1+ #! /usr/bin/ env zsh
22
33# Set terminal title
44function set_terminal_title() {
5- local title=" $1 "
6- if [[ -z " $title " ]]; then
7- echo " Usage: set_terminal_title <title>"
8- return 1
5+ local icon_dir=" "
6+ local start_dir current_dir project_root project_name package_json
7+
8+ start_dir=" $PWD "
9+ current_dir=" $start_dir "
10+ project_root=" "
11+
12+ while [ -n " $current_dir " ] && [ " $current_dir " != " /" ]; do
13+ if [ -d " $current_dir /.git" ]; then
14+ icon_dir=" "
15+ project_root=" $current_dir "
16+ break
17+ fi
18+
19+ current_dir=" $( dirname " $current_dir " ) "
20+ done
21+
22+ if [ -z " $project_root " ]; then
23+ project_root=" $start_dir "
24+ fi
25+
26+ package_json=" $project_root /package.json"
27+ tsconfig=" $project_root /tsconfig.json"
28+ project_name=" $( basename " $project_root " ) "
29+
30+ if [ -f " $package_json " ]; then
31+ icon_dir=" "
32+
33+ if command -v jq > /dev/null 2>&1 ; then
34+ project_name=" $( jq -r ' .name // empty' " $package_json " 2> /dev/null || true) "
35+ fi
36+ fi
37+
38+ if [ -f " $tsconfig " ]; then
39+ icon_dir=" "
940 fi
1041
11- case " $TERM " in
12- wezterm)
13- wezterm cli set-tab-title " $title "
14- ;;
15- esac
42+ if [ " $TERM " = " wezterm" ]; then
43+ wezterm cli set-tab-title " $icon_dir $project_name "
44+ fi
1645}
1746
1847# Reset terminal title
1948function reset_terminal_title() {
20- case " $TERM " in
21- wezterm)
22- wezterm cli set-tab-title " "
23- ;;
24- esac
49+ if [ " $TERM " = " wezterm" ]; then
50+ wezterm cli set-tab-title " "
51+ fi
2552}
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ lockfile = true
33
44[env ]
55HK_MISE = 1
6- HK_STAGE = 0
6+ HK_STAGE = 1
77
88[tools ]
99pkl = " latest"
@@ -12,10 +12,6 @@ shellcheck = "latest"
1212stylua = " latest"
1313yamllint = " latest"
1414
15- [hooks ]
16- enter = { script = ' set_terminal_title " {{ config_root | basename }}"' , shell = " zsh" }
17- leave = { script = " reset_terminal_title" , shell = " zsh" }
18-
1915[tasks .check ]
2016description = " Run all checks"
2117run = " hk run check"
You can’t perform that action at this time.
0 commit comments