Skip to content

Commit b352ab5

Browse files
committed
chore(flake): Improve Nix shell prompt for portability
1 parent 862e572 commit b352ab5

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

flake.nix

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,24 @@
2020
git
2121
chromium
2222
bash-completion
23+
ncurses # Provides the 'tput' command
2324
];
2425

2526
shellHook = ''
27+
# Point Puppeteer to the Nix-provided Chromium
2628
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
2729
export PUPPETEER_EXECUTABLE_PATH="${pkgs.chromium}/bin/chromium"
2830
29-
# Set a nice, readable prompt for the Nix shell
30-
# This is the corrected version.
31-
export PS1="\\[\\033[01;32m\\][nix-dev]\\[\\033[00m\\] \\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ "
31+
# Set a nice, readable prompt using tput for portability
32+
# This is the robust way to set colors.
33+
if command -v tput >/dev/null && tput setaf 1 >/dev/null; then
34+
green=$(tput setaf 2)
35+
blue=$(tput setaf 4)
36+
reset=$(tput sgr0)
37+
export PS1="$green[nix-dev]$reset $blue\w$reset$ "
38+
else
39+
export PS1='[nix-dev] \w\$ '
40+
fi
3241
3342
echo ""
3443
echo "----------------------------------------------------"

0 commit comments

Comments
 (0)