commit 5bbd1073e9c02824ece6979eac5f022823da1662 (patch)
parent bf7d6a618ea84f57425e333b62aaa203cb2ee303
Author: Alex Karle <alex@karle.co>
Date: Mon, 13 Apr 2020 23:57:31 -0400
sh: Add HISTFILE, simplify prompt
In ksh for OpenBSD, we need to set HISTFILE so that history is saved.
However, we don't want to clobber HISTFILE if already set (i.e. by bash)
This commit also simplifies the prompt significantly. I've been playing
around with a no-path prompt and grown quite fond of it. This is the
formula I've settled on for now.
Diffstat:
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/sh/shrc b/sh/shrc
@@ -6,23 +6,21 @@
PATH=$HOME/bin:$PATH # Put ~/bin on the for personal scripts
EDITOR='vi' # $EDITOR, the most important (personal) of exports
VISUAL='vi' # Some programs give priority to this
-MANPAGER="less" # less is more
+PAGER='less' # less is more
+export PATH EDITOR VISUAL PAGER
-export PATH EDITOR VISUAL MANPAGER
-
-# Build up a somewhat fancy prompt (with SSH and error code indicators!)
-if [ -n "$SSH_CLIENT" ]; then
- SSH_PROMPT="$USER@$(hostname -s):"
-fi
+# 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)[${SSH_PROMPT}${PWD}]\$ '
-PS2="> "
-
+# Includes
[ -r "$HOME/.aliases" ] && . "$HOME/.aliases"