Commit eab5549

Eric Bower  ·  2026-06-12 23:51:45 -0400 EDT
parent be42e51
chore(yash): use custom base cfg file
2 files changed,  +114, -4
+111, -0
  1@@ -0,0 +1,111 @@
  2+set --brace-expand    # bash-like extended exp
  3+set --extended-glob   # recursive pathname exp
  4+set --no-clobber      # prevent redirections from overwriting existing files
  5+set --no-unset        # don't expand non-existent variables to empty strings
  6+set --hist-space      # don't save cmds starting with a space in history
  7+set --notify-le       # print job status update asap while line-editing
  8+set --le-no-conv-meta # terminfo data broken; meta flags ignore utf-8
  9+set --le-predict      # enable line prediction
 10+set -o vi             # vim mode
 11+
 12+bindkey --vi-insert '\^F' accept-prediction
 13+
 14+sh() { yash --posix "$@"; }
 15+yash() { command yash "$@"; }
 16+
 17+# define some basic variables if missing
 18+: ${PAGER:=less} ${EDITOR:=vi} ${FCEDIT:=${VISUAL:=$EDITOR}}
 19+: ${LOGNAME:=$(logname)} ${HOSTNAME:=$(uname -n)}
 20+
 21+# disable confusing treatment of arguments in the echo command
 22+: ${ECHO_STYLE:=RAW}
 23+
 24+if ! [ "${HISTFILE-}" ]; then
 25+  HISTFILE=${XDG_STATE_HOME:-~/.local/state}/yash/history
 26+fi
 27+# create HISTFILE parent directory if missing
 28+! [ -d "${HISTFILE%/*}" ] && mkdir -p "${HISTFILE%/*}"
 29+
 30+HISTSIZE=5000
 31+
 32+# default mail check interval is too long
 33+MAILCHECK=0
 34+
 35+# emulate bash's $SHLVL
 36+if [ "${_old_shlvl+set}" != set ]; then
 37+  _old_shlvl=${SHLVL-}
 38+fi
 39+SHLVL=$((_old_shlvl+1)) 2>/dev/null || SHLVL=1
 40+export SHLVL
 41+
 42+# initialize event handlers
 43+COMMAND_NOT_FOUND_HANDLER=()
 44+PROMPT_COMMAND=()
 45+POST_PROMPT_COMMAND=()
 46+YASH_AFTER_CD=()
 47+
 48+# define prompt
 49+if [ -n "${SSH_CONNECTION-}" ]; then
 50+  _hc='\fy.'     # yellow hostname for SSH remote
 51+else
 52+  _hc='\fg.'     # green hostname for local
 53+fi
 54+if [ "$(id -u)" -eq 0 ]; then
 55+  _uc='\fr.'     # red username for root
 56+  _2c='\fr.'     # red PS2 for root
 57+else
 58+  _uc=$_hc _hc=  # same username color as hostname for non-root user
 59+  _2c=           # PS2 in normal color for non-root user
 60+fi
 61+# The main prompt ($YASH_PS1) contains the username, hostname, working
 62+# directory, last exit status (only if non-zero), and $SHLVL (only if
 63+# non-one).
 64+YASH_PS1=$_uc'${LOGNAME}'$_hc'@${HOSTNAME%%.*}\fd. '\
 65+'${${${PWD:/~/\~}##*/}:-$PWD} ${{?:/0/}:+\\fr.$?\\fd. }${{SHLVL-0}:/1}\$ '
 66+YASH_PS1S='\fo.'
 67+YASH_PS2=$_2c'> '
 68+YASH_PS2S=$YASH_PS1S
 69+YASH_PS4='\fm.+ '
 70+YASH_PS4S='\fmo.'
 71+unset _hc _uc _2c
 72+# No escape sequences allowed in the POSIXly-correct mode.
 73+PS1='${LOGNAME}@${HOSTNAME%%.*} '$PS1
 74+
 75+# find escape sequence to change terminal window title
 76+case "$TERM" in
 77+  (xterm|xterm[+-]*|gnome|gnome[+-]*|putty|putty[+-]*|cygwin)
 78+    _tsl='\033];' _fsl='\a' ;;
 79+  (*)
 80+    _tsl=$( (tput tsl 0; echo) 2>/dev/null |
 81+    sed -e 's/\\/\\\\/g' -e 's/%/%%/g')
 82+    _fsl=$( (tput fsl  ; echo) 2>/dev/null |
 83+    sed -e 's/\\/\\\\/g' -e 's/%/%%/g') ;;
 84+esac
 85+# if terminal window title can be changed...
 86+if [ "$_tsl" ] && [ "$_fsl" ]; then
 87+  # set terminal window title on each prompt
 88+  _set_term_title()
 89+  if [ -t 2 ]; then
 90+    printf "$_tsl"'%s@%s:%s'"$_fsl" "${LOGNAME}" "${HOSTNAME%%.*}" \
 91+      "${${PWD:/$HOME/\~}/#$HOME\//\~\/}" >&2
 92+  fi
 93+  PROMPT_COMMAND=("$PROMPT_COMMAND" '_set_term_title')
 94+
 95+  # reset window title when changing host or user
 96+  ssh() {
 97+    if [ -t 2 ]; then printf "$_tsl"'ssh %s'"$_fsl" "$*" >&2; fi
 98+    command ssh "$@"
 99+  }
100+  su() {
101+    if [ -t 2 ]; then printf "$_tsl"'su %s'"$_fsl" "$*" >&2; fi
102+    command su "$@"
103+  }
104+  sudo() {
105+    if [ -t 2 ]; then printf "$_tsl"'sudo %s'"$_fsl" "$*" >&2; fi
106+    command sudo "$@"
107+  }
108+  doas() {
109+    if [ -t 2 ]; then printf "$_tsl"'doas %s'"$_fsl" "$*" >&2; fi
110+    command doas "$@"
111+  }
112+fi
+3, -4
 1@@ -1,7 +1,6 @@
 2-. --autoload --no-alias initialization/common
 3-
 4-set -o vi
 5-bindkey --vi-insert '\^F' accept-prediction
 6+if test -e "$HOME/.config/yash/base.sh"; then
 7+  . --autoload --no-alias "$HOME/.config/yash/base.sh"
 8+fi
 9 
10 if test -e "$HOME/.config/yash/private.sh"; then
11   . "$HOME/.config/yash/private.sh"