WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit cb64c5a

Browse files
committed
fix bash prompt for non-interactive tty
1 parent b573b20 commit cb64c5a

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

.bash_prompt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22

33
export PS1="\u@\h:\w\\$ "
44

5-
if [[ $HOSTNAME == "biowulf.nih.gov" ]] ; then
6-
export PS1="\u@\[$(tput sgr0)\]\[\033[38;5;214m\]\h\[$(tput sgr0)\]:\w\\$ "
7-
fi
8-
if [[ $HOSTNAME == "helix.nih.gov" ]]; then
9-
export PS1="\u@\[$(tput sgr0)\]\[\033[38;5;174m\]\h\[$(tput sgr0)\]:\w\\$ "
5+
# Only change prompt if running interactively
6+
if tty -s; then
7+
8+
# For colors, use colors.sh in the daler/dotfiles repo to easily show the
9+
# color codes. E.g., in \033[38;5;214m\]\h, the 214 indicates an
10+
# orange-yellow hostname.
11+
#
12+
# Or try https://bash-prompt-generator.org/ for more customization.
13+
if [[ $HOSTNAME == "biowulf.nih.gov" ]] ; then
14+
15+
export PS1="\u@\[$(tput sgr0)\]\[\033[38;5;214m\]\h\[$(tput sgr0)\]:\w\\$ "
16+
fi
17+
if [[ $HOSTNAME == "helix.nih.gov" ]]; then
18+
export PS1="\u@\[$(tput sgr0)\]\[\033[38;5;174m\]\h\[$(tput sgr0)\]:\w\\$ "
19+
fi
1020
fi

docs/changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ However if you re-install (i.e. ``setup.sh --install-neovim``) you'll get nvim
1616
0.11.5, which behaves a little differently with LSPs but is also now supported
1717
here. See :ref:`nvimlspconfig_ref` for details on these keymaps.
1818

19+
**bash**
20+
21+
Update ``.bash_prompt`` to only change prompts in an interactive session, which
22+
prevents the message ``tput: No value for $TERM and no -T specified`` when
23+
using non-interactive prompts like rsync or cron jobs. Also include some info
24+
on the colors and how to customize further.
25+
1926
2025-10-27
2027
----------
2128

0 commit comments

Comments
 (0)