forked from mitchweaver/dots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkshrc
executable file
·77 lines (64 loc) · 2.18 KB
/
kshrc
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
#!/bin/mksh
#
# http://github.com/mitchweaver/dots
#
# don't run if not interactive
[[ $- != *i* ]] && return
alias echo='builtin print'
alias type='builtin whence -v'
. ${HOME}/etc/aliases
set -o bgnice nohup trackall
case ${SHELL} in
/*/mksh) set -o vi ;;
/*/ksh) set -o csh-history vi-tabcomplete
esac
export HISTFILE=${HOME}/tmp/.ksh_history \
{SAVEHIST,HISTSIZE}=1000 \
HISTCONTROL=ignoreboth
ulimit -c 0
cd() {
if [ $# -eq 0 ] ; then
builtin cd ${HOME}
else
builtin cd "$@" ||
builtin cd "$@"* ||
builtin cd *"$@" ||
builtin cd *"$@"* ||
for i in 0 1 2 3 4 5 6 7 8 ; do
builtin cd "$(find . -maxdepth $(($i + 1)) -mindepth $i -type d -iname "*$@*" | head -n 1)" &&
break
done
fi 2> /dev/null
export PS1="$(_get_PS1)${RANGER_LEVEL:+[ranger] }${SSH_TTY:+(SSH) }"
}
_parse_branch() {
local branch=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`
[ -n "$branch" ] &&
echo -n " $branch"
} 2> /dev/null
# todo: find a good way to wrap these
case ${SHELL} in
/*/mksh)
_x="$(echo -n \\001)"
_get_PS1() {
case ${PWD} in
${HOME}) local tmp_pwd='~' ;;
'/') local tmp_pwd='/' ;;
*) local tmp_pwd="${PWD##*/}"
esac
case ${USER} in
mitch) echo -n "$_x$(echo -n \\r)$_x\e[1;35mm$_x\e[0;32mi$_x\e[0;33mt$_x\e[0;34mc$_x\e[1;31mh$_x\e[1;36m $tmp_pwd$_x$(_parse_branch)$_x\e[1;37m " ;;
root) echo -n "$_x$(echo -n \\r)$_x\e[1;35m[root]$_x\e[1;36m $tmp_pwd$_x$(_parse_branch)$_x\e[1;37m " ;;
*) echo -n '% $tmp_pwd '
esac
} ;;
/*/ksh) # openbsd
case ${USER} in
mitch) _get_PS1() { echo -n "\[\e[1;35m\]m\[\e[0;32m\]i\[\e[0;33m\]t\[\e[0;34m\]c\[\e[1;31m\]h\[\e[1;36m\] \W $(_parse_branch)\[\e[1;37m\] " ; } ;;
root) _get_PS1() { echo -n "\[\e[0;32m\][root]\[\e[1;36m\] \W\[\e[1;37m\] " ; } ;;
*) _get_PS1() { echo -n '% \W ' ; }
esac
esac
[ -n "$RANGER_LEVEL" ] && clear
cd .
(rm -rf ${HOME}/{*.core,*.out,*.dump,Desktop,Downloads} 2> /dev/null &)