dotfiles

$HOME is where the <3 is
git clone git://git.alexkarle.com/dotfiles.git
Log | Files | Refs | Submodules | README

commit 3bc0455be162705bb663c68f5686569371face73 (patch)
parent 0641fc64c3a1bbc80cc610693f4331c68e6d28fa
Author: Alex Karle <alex@alexkarle.com>
Date:   Tue, 18 Aug 2020 20:05:20 -0400

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...)

Diffstat:
Msh/shrc | 5++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git 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 }