Skip to content

Commit 38c4d6c

Browse files
thiagowfxAmp
andcommitted
wt: display relative paths for all worktrees under repo root
Previously only worktrees under .worktrees/ had their paths shortened. Worktrees under other subdirectories (e.g. .claude/worktrees/) showed full absolute paths. Now any worktree under the repo root displays as a relative path. Amp-Thread-ID: https://ampcode.com/threads/T-019c86ac-9974-742e-8ceb-83b179d4cde6 Co-authored-by: Amp <amp@ampcode.com>
1 parent 2a48327 commit 38c4d6c

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

wt/wt.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ cmd_list() {
306306

307307
if [[ "$path" == "$main_worktree" ]]; then
308308
path="."
309-
elif [[ "$path" == "$main_worktree/.worktrees/"* ]]; then
310-
path="$(basename "$path")"
309+
elif [[ "$path" == "$main_worktree/"* ]]; then
310+
path="${path#"$main_worktree"/}"
311311
fi
312312

313313
paths+=("$path")
@@ -1336,10 +1336,10 @@ show_dashboard() {
13361336
[[ ${#branch} -gt $max_branch_len ]] && max_branch_len=${#branch}
13371337

13381338
local display_path="$path"
1339-
if [[ "$path" == "$main_worktree/.worktrees/"* ]]; then
1340-
display_path="$(basename "$path")"
1341-
elif [[ "$path" == "$main_worktree" ]]; then
1339+
if [[ "$path" == "$main_worktree" ]]; then
13421340
display_path="."
1341+
elif [[ "$path" == "$main_worktree/"* ]]; then
1342+
display_path="${path#"$main_worktree"/}"
13431343
fi
13441344
[[ ${#display_path} -gt $max_path_len ]] && max_path_len=${#display_path}
13451345
done
@@ -1351,10 +1351,10 @@ show_dashboard() {
13511351
IFS='|' read -r path branch <<< "$entry"
13521352

13531353
local display_path="$path"
1354-
if [[ "$path" == "$main_worktree/.worktrees/"* ]]; then
1355-
display_path="$(basename "$path")"
1356-
elif [[ "$path" == "$main_worktree" ]]; then
1354+
if [[ "$path" == "$main_worktree" ]]; then
13571355
display_path="."
1356+
elif [[ "$path" == "$main_worktree/"* ]]; then
1357+
display_path="${path#"$main_worktree"/}"
13581358
fi
13591359

13601360
local status

0 commit comments

Comments
 (0)