mirror of
https://github.com/notwa/rc
synced 2024-11-05 02:49:02 -08:00
46 lines
1.7 KiB
Bash
46 lines
1.7 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 hide='\\[' show='\\]' prompt='\\$' cwd='\\w' host='\\H'
|
|
local ESC='\E' BEL='\a' SI='\017' SO='\016' # SI/SO: switch to G0/G1 charset
|
|
local CSI="$ESC[" OSC="$ESC]"
|
|
local G0="(" G1=")" # change G0/G1 charset
|
|
local USASCII="B" SPECIAL="0" # charsets: sane default & line drawing
|
|
local DECTCEM="25"
|
|
local DECSET="h" SGR="m" # final characters of a command sequence
|
|
local sanity="$CSI?$DECTCEM$DECSET"
|
|
local color1="$CSI;--$SGR" color2="$CSI--;97$SGR" reset="$hide$CSI$SGR$show"
|
|
if [ "$t" = xterm ] || [ "$t" = screen ] || [ "$t" = tmux ]; then
|
|
[ "$t" = tmux ] && title="$cwd" || title="$host: $cwd"
|
|
title="${OSC}2;$title$BEL"
|
|
sanity="$ESC$G0$USASCII$SI$sanity"
|
|
fi
|
|
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}" ret_fail="${ret//--/41}" # green/red bg
|
|
PROMPT_COMMAND="[ \$? = 0 ] && PS1=\$'$ret_okay' || PS1=\$'$ret_fail'"
|
|
}; _temporary_scope_; unset -f _temporary_scope_
|
|
|
|
#ADDPATH "$HOME/sh" # this doesn't work for all scripts at the moment
|
|
dummy() { :; } ### @- return 0, ignoring arguments.
|
|
. ~/.shrc
|
|
|
|
alias reload='cd; exec bash' ### @- **TODO:** respect initctl like in `.zshrc`.
|
|
[ ! -e ~/.lol ] || . ~/.lol
|
|
|
|
true
|