From 3bc0455be162705bb663c68f5686569371face73 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Tue, 18 Aug 2020 20:05:20 -0400 Subject: [PATCH] sh: Change default prompt to include cwd I've been using a prompt like so for a while: [user@host]$ Which is nice because it's consistently short, helpful when I'm SSH-ing around, and nicely minimal. But after testing ash as a login shell, I grew fond of the simple "\w \$" prompt: ~/dotfiles $ So I'm going back to the cwd-in-prompt crew (admittedly, I mostly use my fancy bash prompt which is multi-line--this is the prompt I use on OpenBSD and fresh Linux installs). I confirmed \w is portable to pdksh, bash, and busybox ash. dash doesn't recognize it, but that's OK (can't imagine using dash as a login shell...) --- sh/shrc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sh/shrc b/sh/shrc index 6fe2d68..46a566e 100755 --- a/sh/shrc +++ b/sh/shrc @@ -13,16 +13,15 @@ export PATH EDITOR VISUAL PAGER PERL5LIB MANPATH # Shell vars HISTFILE=${HISTFILE:="$HOME/.sh_histo"} # Don't override bash_history -HOSTNAME="$(hostname -s)" # Prompt last_err() { err="$?" if [ $err -ne "0" ]; then - echo "($err)" + echo "($err) " fi } -PS1='$(last_err)[${USER}@${HOSTNAME}]\$ ' +PS1='$(last_err)\w \$ ' # Includes include() { if [ -r "$1" ]; then . "$1"; fi } -- libgit2 0.28.4