mirror of
https://github.com/notwa/rc
synced 2024-11-05 07:19:02 -08:00
80 lines
2.2 KiB
Bash
80 lines
2.2 KiB
Bash
[ -z "$PS1" ] && return
|
|
. ~/.prep # handle boring stuff like /etc/profile and $PATH
|
|
|
|
HISTCONTROL=erasedups
|
|
HISTSIZE=1000
|
|
HISTFILESIZE=2000
|
|
|
|
shopt -s histappend
|
|
shopt -s checkwinsize
|
|
#shopt -s physical # chaselinks (doesn't exist?)
|
|
set -o hashall # enable hash command
|
|
set +o histexpand # disable expansion of ! characters
|
|
|
|
[ "$TERM" != rxvt-unicode-256color ] || export TERM=xterm-256color
|
|
|
|
_temporary_scope_() {
|
|
local t="${TERM%%-*}" title=
|
|
|
|
local ESC="\\E"
|
|
local BEL="\\a"
|
|
local SI="\\017" # switch to G0 charset
|
|
local SO="\\016" # switch to G1 charset
|
|
|
|
local CSI="$ESC["
|
|
local OSC="$ESC]"
|
|
|
|
if [ "$t" = xterm ] || [ "$t" = screen ] || [ "$t" = tmux ]; then
|
|
title="\\\\w"
|
|
[ "$t" = tmux ] || title="\\\\H: $title"
|
|
title="${OSC}2;$title$BEL"
|
|
fi
|
|
|
|
local G0="(" # change G0 charset
|
|
local G1=")" # change G1 charset
|
|
local USASCII="B" # sane default
|
|
local SPECIAL="0" # DEC Special Character and Line Drawing Set
|
|
|
|
local DECTCEM="25"
|
|
local DECSET="h"
|
|
local SGR="m"
|
|
|
|
local sanity="$ESC$G0$USASCII$SI$CSI?$DECTCEM$DECSET"
|
|
local hide="\\\\["
|
|
local show="\\\\]"
|
|
local prompt="\\\\$"
|
|
local reset="$hide$CSI$SGR$show"
|
|
local color1="$CSI;--$SGR"
|
|
local color2="$CSI--;97$SGR"
|
|
local line1="$hide$title$sanity$color1$show $reset"
|
|
local line2="$hide$color2$show$prompt$reset "
|
|
local ret="$line1\\n$line2"
|
|
local ret_okay="${ret//--/42}" # use green background
|
|
local ret_fail="${ret//--/41}" # use red background
|
|
|
|
PROMPT_COMMAND="[ \$? = 0 ] && PS1=\$'$ret_okay' || PS1=\$'$ret_fail'"
|
|
}; _temporary_scope_; unset -f _temporary_scope_
|
|
|
|
. ~/.shrc
|
|
|
|
# this doesn't work for all scripts at the moment, but
|
|
ADDPATH "$HOME/sh"
|
|
|
|
# combine everything matching "YES_BASH" in ~/sh/ into ~/.sh-bash.
|
|
# unlike zsh, we do not check the sha1sum of the output.
|
|
(: \
|
|
&& cd ~/sh \
|
|
&& printf '%s\n' '#!/usr/bin/env false' '[ -n "$preload" ] || exit 1' '' \
|
|
| cat - > ~/.sh-bash \
|
|
$(grep -lF YES_BASH -- $(find ~/sh/ -maxdepth 1 -type f '!' -name '*.bak')) \
|
|
;)
|
|
|
|
dummy() { :; } ### @- return 0, ignoring arguments.
|
|
preload=dummy
|
|
. ~/.sh-bash
|
|
unset preload
|
|
|
|
alias reload='cd; exec bash' ### @- **TODO:** respect initctl like in `.zshrc`.
|
|
[ ! -e ~/.lol ] || . ~/.lol
|
|
|
|
true
|