Skip to content

Commit d3fd005

Browse files
committed
Warn if running commands that change terminal environment
Since they don't persist outside of hdi
1 parent aa5bafe commit d3fd005

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

hdi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,12 @@ run_interactive() {
11981198

11991199
echo ""
12001200
if (( rc == 0 )); then
1201-
printf "%s%s✓ Done (exit %d)%s\n" "$DIM" "$GREEN" "$rc" "$RESET"
1201+
printf "%s✓ Done (exit %d)%s\n" "$GREEN" "$rc" "$RESET"
1202+
# Warn about commands that modify the shell environment
1203+
if [[ "$cmd" =~ (^|[;&|]\ *)(source|\.)\ ]] || [[ "$cmd" =~ activate ]]; then
1204+
printf "%s Tip: environment changes (eg. venv activation) don't persist outside hdi.%s\n" "$DIM" "$RESET"
1205+
printf "%s You may prefer to run this command directly in your shell instead.%s\n\n" "$DIM" "$RESET"
1206+
fi
12021207
else
12031208
printf "%s%s✗ Exited with code %d%s\n" "$BOLD" "$YELLOW" "$rc" "$RESET"
12041209
fi

src/picker.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,12 @@ run_interactive() {
411411

412412
echo ""
413413
if (( rc == 0 )); then
414-
printf "%s%s✓ Done (exit %d)%s\n" "$DIM" "$GREEN" "$rc" "$RESET"
414+
printf "%s✓ Done (exit %d)%s\n" "$GREEN" "$rc" "$RESET"
415+
# Warn about commands that modify the shell environment
416+
if [[ "$cmd" =~ (^|[;&|]\ *)(source|\.)\ ]] || [[ "$cmd" =~ activate ]]; then
417+
printf "%s Tip: environment changes (eg. venv activation) don't persist outside hdi.%s\n" "$DIM" "$RESET"
418+
printf "%s You may prefer to run this command directly in your shell instead.%s\n\n" "$DIM" "$RESET"
419+
fi
415420
else
416421
printf "%s%s✗ Exited with code %d%s\n" "$BOLD" "$YELLOW" "$rc" "$RESET"
417422
fi

0 commit comments

Comments
 (0)