-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbashrc_minimal
More file actions
123 lines (101 loc) · 2.22 KB
/
Copy pathbashrc_minimal
File metadata and controls
123 lines (101 loc) · 2.22 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# This file is sourced early from ~/.bashrc
# It contains simplified versions of my essential commands
# so that I can work more easily even if ~/.bashrc fails later
MINIMAL_SOURCE=$(readlink -f $BASH_SOURCE)
.m () {
source $MINIMAL_SOURCE
}
debug_ (){
echo "+ $@" >&2
}
QUIETLY () {
"$@" 2>/dev/null 1>&2
}
quietly () {
"$@" 2>/dev/null
}
from () {
[[ $3 ]] || return 1
local source_="$1"
local import_=$2
local type_=$3
QUIETLY type "$type_" && return 0
QUIETLY test -f "$source_" || return 2
source "$source_"
}
import_essentials () {
# debug_ "import_essentials"
from ~/cde.sh import cde
from ~/whyp.sh import whyp
from ~/bash/keys.sh import keys_read
from ~/bash/crayons.sh.sh import green_line
}
minimally () {
local blue_="\033[0;34m"
local green_="\033[1;32m"
local grey_="\033[1;30m"
local off_="\033[0m"
local yellow_="\033[1;33m"
(
cmd_=$1; shift
rest_="$@"
echo
printf "${green_}${cmd_}${blue_}${rest_} "
printf "${grey_}# MINIMALLY $off_"
echo
echo
) >&2
}
g () {
minimally "git " "$@"
git "$@"
}
gr () {
minimally "grep --color " "$@"
grep --color "$@"
}
ht () {
minimally "history | tail -n 30"
history | tail -n 30
}
l () {
minimally "ls" "$@"
if QUIETLY ls --version; then
ls --color --group-directories-first --classify "$@"
else
ls -GF "$@"
fi
}
ll () {
l -l "$@"
}
vd () {
minimally "vim -dO " "$@"
vim -dO "$@"
}
vin () {
vim -c "setlocal buftype=nofile bufhidden=hide noswapfile" -
minimally "vim - "
}
vv () {
minimally "vim -p " "$@"
vim -p "$@"
}
vbb () {
local files_=~/.bashrc
[[ -z ~/log/bashrc.log ]] && files_="$files_ ~/log/bashrc.log"
[[ -z ~/log/bashrc.err ]] && files_="$files_ ~/log/bashrc.log"
vim -p "$MINIMAL_SOURCE" $files_ "$@" +/MINIMAL_SOURCE
source $MINIMAL_SOURCE
minimally "vim -p $MINIMAL_SOURCE $files_" "$@" +/MINIMAL_SOURCE
minimally "source $MINIMAL_SOURCE"
}
vd12 () {
minimally "vim -dO ~/one ~/two "
vim -dO ~/one ~/two
}
w () {
minimally "type" "$@"
quietly type "$@" | grep -v "is a function"
}
quietly import_essentials