-
-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathminimal-shellrc
91 lines (83 loc) · 2.79 KB
/
minimal-shellrc
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
# vim:ft=sh:fdm=marker
# Configuration for the `minimal-shell' function of grml's zsh setup.
# That function spawns a `mksh' shell with this file as its configuration.
# skip this setup for non-interactive shells
[[ -o interactive && -t 0 ]] || return
export PATH="/bin:/sbin/:/usr/bin/:/usr/sbin:/usr/local/bin:/usr/local/sbin:${HOME}/bin:/opt/bin"
export EDITOR='ed'
if [[ -x $(which vim) ]] ; then
export VISUAL='vim'
else
export VISUAL='vi'
fi
if [[ -x $(which less) ]] ; then
export PAGER='less'
else
export PAGER='more'
fi
# some options.
set -o bgnice \
-o braceexpand \
-o emacs \
-o markdirs \
-o monitor \
-o nohup \
-o trackall
# aliases for various command shortcuts
alias ls='command ls --color=auto' # we're on grml, so we do have GNU ls.
alias ll='command ls -l --color=auto'
alias la='command ls -la --color=auto'
alias pu='ps -fu $USER'
## Keybindings
bind '^L=clear-screen'
if [[ -x $(which infocmp) ]] && [[ -x $(which sed) ]] ; then
# Reading some special keys from terminfo database. If `infocmp'
# cannot be found, we rely on mksh to do the right thing.
infocmp -x1L | sed '/^\t[^k]/d;/^[^\t]/d;s/\t//;s/,$//' | \
while read -r line ; do
key="${line%=*}"
[[ "${key}" != k* ]] && continue
seq="$(print -r -- "${line#*=}" | sed -e 's,\\\([1-7][0-7]*\),\\0\1,g')"
seq="$(print "${seq}")"
case "$key" in
key_left) bind "${seq}"='backward-char' ;;
key_right) bind "${seq}"='forward-char' ;;
key_up) bind "${seq}"='up-history' ;;
key_down) bind "${seq}"='down-history' ;;
key_ppage) bind "${seq}"='search-history-up' ;;
key_npage) bind "${seq}"='search-history-down' ;;
key_home) bind "${seq}"='beginning-of-line' ;;
key_end) bind "${seq}"='end-of-line' ;;
key_backspace) bind "${seq}"='delete-char-backward' ;;
key_dc) bind "${seq}"='delete-char-forward' ;;
esac
done
fi
function _lrv {
local rv="$?"
if [[ "${rv}" != 0 ]]; then
print -- "[${rv}]-"
fi
return 0
}
# put the current directory and history number in the prompt.
# use a wrapper for 'cd' to get '~' instead of /home/foo/.
function _cd {
"cd" "$@"
[[ $PWD = $HOME* && $HOME != / ]] && _pwd=\~"${PWD#$HOME}" && return
_pwd="$PWD"
}
alias cd=_cd
_cd .
PS1='$(_lrv)(!)-$_pwd'
if (( USER_ID )); then
PS1="$PS1"'\$ '
else
PS1="$PS1"'# '
fi
HISTSIZE=500
HISTEDIT="$EDITOR"
# This is the default in mksh, but we make sure in case people tempered
# with it in their environment.
unset HISTFILE
true