-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkshrc
72 lines (64 loc) · 2.17 KB
/
mkshrc
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
# ---------------------------------------------------------------------+
# file: .mkshrc +
# author: Ypnose - http://ywstd.fr +
# ---------------------------------------------------------------------+
# -- TEST mksh ---------------------------------------------------------
[[ $- != *i* ]] && return
case $KSH_VERSION in
*MIRBSD\ KSH*) ;;
*) return 0 ;;
esac
# -- TMOUT -------------------------------------------------------------
tty | grep -q 'tty[0-9]' && readonly TMOUT=120
# -- PS1 ---------------------------------------------------------------
#PS1=$'\1\r\1\033[0;35m\1${PWD}\1\033[0m\1 >> '
PS1=$'\001\r \001\033[1;31m\001${SSH_CONNECTION:+[REMOTE] }\001\033[1;33m\001${
\\builtin typeset e=$?
(( e )) && \\builtin print -nr -- "$e "
\\builtin return $e
}\001\033[1;32m\001${
\\builtin typeset e=$? d="${PWD:-?}" p=~
[[ $p = ?(*/) ]] || d="${d/#$p/\\~}"
\\builtin print -nr -- "$d"
\\builtin return $e
}\001\033[1;34m\001 \$\001\033[0m\001 '
# -- OPTIONS -----------------------------------------------------------
set -o emacs
# -- BINDINGS ----------------------------------------------------------
bind '^L'=clear-screen
stty -ixon
# -- FUNCTIONS ---------------------------------------------------------
function dif {
diff -u "$@" | yiff
}
function lf {
typeset F_FIL
find . -maxdepth 1 -iname "*${1}*" \
| sort \
| while IFS=$'\n' read -r F_FIL; do \
print -r -- "${F_FIL##*/}"; done
}
function nd {
mkdir -p "$1" && cd "$1" && ls
}
function reduc {
print -r -- "scale=2;(${1//,/.}*${2//,/.})/100;(${1//,/.}-.)/1" | bc
}
function shadate {
# GNU date(1)
if (( ${#1} == 5 )); then
date -d @"$(( #$1 * 86400 ))"
elif (( ${#1} == 8 )); then
print -r -- "$(( #$(date -d "$1" '+%s') / 86400 ))"
elif (( ${#1} == 10 )); then
date -d @"$1"
else
print -r -- "$(( #$(date '+%s') / 86400 ))"
fi
}
function tva {
print -r -- "scale=2;(${1//,/.}*0.2)/1;(${1//,/.}+.)/1" | bc
}
# -- ALIASES -----------------------------------------------------------
[[ -r ${HOME}/.local/etc/aliases.local ]] && . "${HOME}/.local/etc/aliases.local"
[[ -r ${HOME}/.aliases ]] && . "${HOME}/.aliases"