summary refs log tree commit diff
path: root/home/.kshrc
blob: a74be2b2e3cb38e28a4662a66ffc4b191970acdd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
set -o nounset -o noclobber -o braceexpand -o emacs
HISTFILE=~/.ksh_history HISTSIZE=5000
export GPG_TTY=$(tty)

function colonize {
	IFS=:
	print "$*"
}
systemPath=$PATH
PATH=$(colonize {,/usr{/local,/pkg,},/opt/pkg,$HOME/.local}/{s,}bin /usr/games)
CDPATH=:$HOME
export PWD

export PAGER=less
export LESS=FRX
export MANSECT=2:3:1:8:6:5:7:4:9
export EDITOR=vim
if whence nvim > /dev/null; then
	EDITOR=nvim
	alias vim=nvim
	export MANPAGER="nvim -c 'set ft=man' -"
fi
FCEDIT=$EDITOR
export GIT_EDITOR=$EDITOR
export CLICOLOR=1
export NETHACKOPTIONS='pickup_types:$!?+/=, color, DECgraphics'

alias ls='ls -p'
alias ll='ls -lh'
alias bc='bc -l'
alias date=ddate
if [[ $(uname) = 'Linux' ]]; then
	alias ls='ls --color=auto' grep='grep --color' rm='rm -I'
fi
alias gs='git status --short --branch || ls' gd='git diff'
alias gsh='git show' gl='git log --graph --pretty=log'
alias gco='git checkout' gb='git branch' gm='git merge' gst='git stash'
alias ga='git add' gmv='git mv' grm='git rm'
alias gc='git commit' gca='gc --amend' gt='git tag'
alias gp='git push' gu='git pull' gf='git fetch'
alias gr='git rebase' gra='gr --abort' grc='gr --continue' grs='gr --skip'
alias rand='openssl rand -base64 33'
alias private='eval "$(gpg -d ~/.private)"'

function colors {
	typeset sgr0=sgr0 setaf=setaf
	[[ -f /usr/share/misc/termcap ]] && sgr0=me setaf=AF
	set -A fg \
		$(tput $sgr0) $(tput $setaf 1) $(tput $setaf 2) $(tput $setaf 3) \
		$(tput $setaf 4) $(tput $setaf 5) $(tput $setaf 6) $(tput $setaf 7)
}
colors

function branch {
	typeset git=.git head
	[[ -d $git ]] || git=../.git
	[[ -d $git ]] || return
	read head < $git/HEAD
	if [[ $head = ref:* ]]; then
		print ":${head#*/*/}"
	else
		typeset -L 7 head
		print ":$head"
	fi
}

hostname=$(hostname)
whence realpath > /dev/null && HOME=$(realpath "$HOME")
function prompt {
	typeset status=$?
	typeset path title right color left cols

	[[ ${PWD#$HOME} != $PWD ]] && path="~${PWD#$HOME}" || path=$PWD
	title=${path##*/}
	right="${path}$(branch)"

	color=${fg[7]}
	if [[ -n ${SSH_CLIENT:-} ]]; then
		color=${fg[5]}
		title="${hostname%%.*}:${title}"
	fi
	(( status )) && color=${fg[1]}
	left="\01${color}\01\$\01${fg}\01 "

	[[ $TERM = xterm* ]] && title="\033]0;${title}\07" || title=''
	[[ -n ${COLUMNS:-} ]] && cols=$COLUMNS || cols=$(tput cols)
	while (( ${#right} > (cols / 2) )); do
		right=${right#*/}
	done
	typeset -R $(( cols - 1 )) right
	print "\01\r\01${title}\01\n\01${fg[7]}${right}${fg}\r\01${left}"
}

PS1='$(prompt)'
-01-04Replace gr alias with git resetJune McEnroe I haven't been doing much rebasing in a long time and I've caught myself trying to use gr to do reset. 2020-01-03Remove shotty -c flag from upJune McEnroe 2020-01-03Add Darling Don't CryJune McEnroe Heard at cafe. 2020-01-01Update license header templates for the new yearJune McEnroe 2019-12-26Add \S to sort inside bracesJune McEnroe 2019-12-23Reformat music.txtJune McEnroe 2019-12-23Rename music.md to music.txtJune McEnroe 2019-12-23Add DO YOU DOUBT ME TRAITORJune McEnroe 2019-12-22Add license header to cgit CSSJune McEnroe As requested. Funny that its license header capitalizes You. 2019-12-22Add The Book of EttaJune McEnroe 2019-12-21Revert "Add first working version of imbox"June McEnroe Moved to <https://git.causal.agency/imbox>. This reverts commit 6aa7f2f6bf47fa9df9c749ce665171fa30800937. 2019-12-21Add first working version of imboxJune McEnroe 2019-12-20Respect mailmap in gl pretty formatJune McEnroe 2019-12-20Set LANG in cgit filtersJune McEnroe ttpre needs to know about UTF-8 too so it can bold/italic non-ASCII chars. 2019-12-20Source .editrc before applying -v or -eJune McEnroe Otherwise a bind -v in .editrc will take precedence and overwrite the ^I binding for sh-complete. 2019-12-20Disable signing commitsJune McEnroe Why did I ever turn this on? This gets me nothing but inconvenience. RIP to all the wasted bytes in my git repos. 2019-12-19Ignore about-filterJune McEnroe 2019-12-19Fix matching make tags with no sourcesJune McEnroe 2019-12-19Avoid matching := assignments as tagsJune McEnroe 2019-12-18Hide line numbers when rendering mdocJune McEnroe Hack: output an extra <td> after rendering mdoc so that line numbers can be hidden based on there being three. This required splitting source-filter and about-filter since on about pages there is no table. 2019-12-18Customize cgit CSSJune McEnroe 2019-12-18Use :target rather than :focus pseudo-classJune McEnroe :target persists after you click on something else. 2019-12-18Copy cgit auxiliary binaries properlyJune McEnroe 2019-12-18Add git.causal.agency cgit configJune McEnroe 2019-12-18Bail from hi if input is binaryJune McEnroe NULs in the input cause an infinite loop in htmlEscape, not to mention regexes obviously not working, etc. 2019-12-16Post "cgit setup"June McEnroe