dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit b5e9417106e3b79fc3c9fb502f1c13a96b229c4f
parent e27899b08ddfa47d42a2e9bc4a4bbc9fedcd5a20
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Sun,  5 Apr 2020 14:29:47 -0400

ps1.sh: Remove PS1 cruft

Diffstat:
Metc/shrc.d/ps1.sh | 57++++++++++++---------------------------------------------
1 file changed, 12 insertions(+), 45 deletions(-)

diff --git a/etc/shrc.d/ps1.sh b/etc/shrc.d/ps1.sh @@ -1,47 +1,14 @@ -__ps1() { - last=$? - [ $last -ne 0 ] && echo -n "[$last] " - echo -n $LOGNAME@$HOSTNAME: - if [ "$PWD" = "$HOME" ] - then - echo -n '~' - else - echo -n $(basename "$PWD") - fi +uid=$(id -u) - if type git > /dev/null 2>&1 - then - workdir=$(git rev-parse --is-inside-work-tree 2>/dev/null) - if [ $? -eq 0 ] - then - if [ "$workdir" = "false" ] - then - bare=$(git rev-parse --is-bare-repository 2>/dev/null) - if [ $? -ne 0 ] - then - echo - else - echo " (GIT: bare)" - fi - else - gitref=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) - [ $? -ne 0 ] && gitref="GIT: empty" - [ "$gitref" = HEAD ] && gitref=\($(git rev-parse --short HEAD)\) - git diff --no-ext-diff --quiet || status="*" - git diff --no-ext-diff --cached --quiet || status="$status+" - if [ "$(git config --bool sh.showUntrackedFiles)" != "false" ] && - git ls-files --others --exclude-standard --directory \ - --no-empty-directory --error-unmatch -- ':/*' >/dev/null 2>/dev/null - then - status="$status%" - fi - [ -n "$status" ] && gitref="$gitref $status" - echo " ($gitref)" - fi - else - echo - fi - fi -} -PS1='$(__ps1)\$ ' +if [ $uid -ne 0 ] +then + PS1='$ ' +else + PS1='# ' +fi + +if [ -n "$SSH_TTY" ] +then + PS1="$(hostname -s)$PS1" +fi export PS1