-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.env
246 lines (223 loc) · 6.39 KB
/
.env
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#echo .env
if [ ${UID:-65535} -gt 0 ] && [ "${LOGNAME:-$USER}" = "$(id -ng)" ] ; then # usergroups
umask 002
else
umask 022
AUTO_UMASK=yes
fi
# Environment
PATH="$HOME/.local/bin:$HOME/bin:/usr/lib/ccache:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/games"
case $HOSTNAME in *.*) HOSTNAME=`echo $HOSTNAME | cut -f1 -d.` ;; esac
export HOSTNAME
: ${USER:=$LOGNAME}
[ -z "${TMPDIR:-}" ] && [ -d "$HOME/tmp" ] && export TMPDIR="$HOME/tmp"
: ${UID:=$(id -u)}
if [ -z "${XDG_RUNTIME_DIR:-}" ] && [ -O "/run/user/$UID" ]; then
export XDG_RUNTIME_DIR="/run/user/$UID"
fi
if [ -z "${SSH_AUTH_SOCK:-}" ] && [ -S "$XDG_RUNTIME_DIR/gnupg/S.gpg-agent.ssh" ]; then
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/gnupg/S.gpg-agent.ssh"
fi
if [ -z "${GPG_AGENT_INFO:-}" ] && [ -S "$XDG_RUNTIME_DIR/gnupg/S.gpg-agent" ]; then
export GPG_AGENT_INFO="$XDG_RUNTIME_DIR/gnupg/S.gpg-agent:0:1"
fi
if [ -z "${DISPLAY:-}" ] && [ -S "/tmp/.X11-unix/X0" ]; then
export DISPLAY=:0
fi
type -p lesspipe > /dev/null && export LESSOPEN='|lesspipe %s'
# check whether we run interactively
[ "$PS1" ] || return
[ "$BASH_VERSION" ] || return
#echo ".env: interactive"
# check for rxvt-(unicode-)256color support (in ncurses-term)
case $TERM in rxvt*)
if [ ! -f "/lib/terminfo/r/$TERM" ] &&
[ ! -f "/usr/share/terminfo/r/$TERM" ]; then
TERM="rxvt-unicode" # ncurses-base: /lib/terminfo/r/rxvt-unicode
fi
esac
export LS_COLORS='di=01;34:ln=01;36:*.deb=32:*.dsc=31:*.changes=1;35:'
export QUOTING_STYLE='literal'
export PGDATABASE='postgres'
# debian.org
if [ -f /etc/ssl/ca-global/ca-certificates.crt ]; then
export GIT_SSL_CAINFO=/etc/ssl/ca-global/ca-certificates.crt
fi
# Aliases
# check for GNU utils
if cp --version > /dev/null 2>&1 ; then
alias cp='cp -iv'
alias mv='mv -iv'
alias rm='rm -v'
case "$TERM" in
linux*|*vt100*|cons25|xterm*|rxvt*|screen*|cygwin)
alias ls='ls -F --color=auto' ;;
*) alias ls='ls -F' ;;
esac
alias grep="grep --exclude-dir=.git --exclude-dir=.pc --exclude tags --exclude '*~' --color=auto"
alias zgrep="zgrep --color=auto"
else
alias cp='cp -i'
alias mv='mv -i'
alias ls='ls -F'
fi
alias -- -='popd && ps1_set_vcs && ls'
cal () { if [ "$1" ] ; then ncal -bw "$@" ; else ncal -bw3 ; fi }
alias d=date
alias diffstat='diffstat -p1 -r2'
alias f=finger
alias gf=sl
alias ip='ip -c=auto'
alias m='mutt'
alias man='man -LC'
alias ncdu='ncdu --color dark -e'
alias ping='ping -n'
alias rehash='hash -r'
alias y=sl
# Functions
# print pwd
? () {
echo "pwd: $PWD"
echo -n "real: "; /bin/pwd
echo "stack: ${DIRSTACK[@]}"
echo "uri: $USER@$(hostname -f):$PWD"
echo "umask: `umask` (auto: ${AUTO_UMASK:-no})"
}
# set umask depending on directory group/sgid bit
auto_umask () {
local dir group
umask 022
if [[ `stat -c "%04a" .` == [267]* ]] ; then # sgid directory
dir=`stat -c "%g" .`
for group in ${GROUPS[@]} ; do
[ $group -eq $dir ] && { umask 002 ; break ; }
done
fi
}
ps1_vcs_git ()
{
local branch
branch=$(git branch | sed -ne 's/^\* \(.*\)/\1/p')
PS1_VCS=" $branch"
}
ps1_quilt ()
{
unset PS1_QUILT
local top="$(quilt top 2>/dev/null)"
if [ "$top" ]; then
PS1_QUILT=" q:$(echo $top | sed -e 's/^\(.\{12\}\).\+/\1../')"
fi
}
ps1_vcs () { # executed on every prompt
case $VCS in
git) ps1_vcs_git ;;
esac
if [ "$QUILT" ]; then
ps1_quilt
fi
}
ps1_set_vcs () { # executed on dir change
unset VCS PS1_VCS QUILT PS1_QUILT
local d
for d in . .. ../.. ../../.. ../../../..; do
if git ls-files --error-unmatch . >/dev/null 2>&1; then
VCS="git"
if [ "$(find .git/FETCH_HEAD -mtime +1 2>/dev/null)" ]; then
echo -e "\e[43mLast git pull: $(date -r .git/FETCH_HEAD +%x)\e[0m"
fi
break
elif [ -d $d/.svn ] && [ -r $d/.svn ]; then
local info branch
info=$(LC_ALL=C svn info 2>/dev/null)
if [ "$info" ]; then
branch=$(echo "$info" | sed -ne 's/^URL: .*branches\/\([^/]*\).*/:\1/p')
PS1_VCS=" svn$branch"
fi
break
elif [ -d $d/.bzr ] && [ -r $d/.bzr ]; then
PS1_VCS=" bzr"
break
elif [ -d $d/.hg ] && [ -r $d/.hg ]; then
PS1_VCS=" hg"
break
elif [ -d $d/CVS ] && [ -r $d/CVS ]; then
PS1_VCS=" cvs"
break
fi
done
# support quilt on top of the other VCS
for d in . .. ../.. ../../.. ../../../..; do
if [ -d $d/.pc ] || [ -f $d/debian/changelog ]; then
QUILT="1"
break
fi
done
if [ "$VTE_VERSION" ]; then
PS1_VTE=$(printf "\033]7;file://%s%s\033\\" "${HOSTNAME}" "$(/usr/libexec/vte-urlencode-cwd)")
fi
}
ps1_set_vcs
# cd with some nice options
cd () {
local cur dir d d0 arg opt OPTIND OPTERR
while getopts "10nprLP" opt ; do
case $opt in
1) set */ ; dir="$1" ; [ "$dir" ] || return 1 ;;
0) for dir in */ ; do : ; done ; [ "$dir" ] || return 1 ;;
n) cur="../`basename "$PWD"`/"
for d in ../*/ ; do [ "$d0" = "$cur" ] && { dir="$d"; break; } ; d0="$d" ; done
[ -z "$dir" ] && return 1 ;;
p|r) cur="../`basename "$PWD"`/"
for d in ../*/ ; do [ "$d" = "$cur" ] && { dir="$d0"; break; } ; d0="$d" ; done
[ -z "$dir" ] && return 1 ;;
L|P) arg="-$opt" ;;
esac
done
shift $(($OPTIND - 1))
[ "${DIRSTACK[10]}" ] && popd +10 -n > /dev/null
# support "cd %1"
case $1 in %*) dir="`jobs $1 | perl -ne 's/wd: ~/wd: $ENV{HOME}/; print $1 if /wd: (.*)\)/'`" ;; esac
pushd $arg "${dir:-${1:-$HOME}}" > /dev/null || return $?
[ "$AUTO_UMASK" ] && auto_umask
ps1_set_vcs
ls
}
# mkdir/cd wrappers
nd () { mkdir "$1" && cd "$1" ; }
nv () { local nv ; nv=`nv.pl "$@"` && cd "$nv" ; }
# edit variable in vi
vared () {
local vared
vared=`mktemp /tmp/vared.XXXXXX`
( echo -n "$1="\' ; eval echo -n "\$$1" ; echo \' ) > $vared
${EDITOR:-"vi"} $vared && . $vared
/bin/rm -f $vared
}
# untar and cd into dir
unalias ttar xtar 2> /dev/null || : # remove system default
if type -p xtar.pl > /dev/null ; then
xtar () {
local xtar
xtar=`xtar.pl "$@"` && cd "$xtar"
}
else
alias xtar='tar xvzf'
fi
# PostgreSQL
pgenv () {
[ "$1" ] || return 1
export PGVERSION="$1"
if pg_lsclusters $PGVERSION main > /dev/null 2>&1; then
export PGCLUSTER="$PGVERSION/main"
export PGPORT="$(pg_conftool -s $PGVERSION main show port || echo 5432)"
fi
export PG_CONFIG="/usr/lib/postgresql/$PGVERSION/bin/pg_config"
PATH="/usr/lib/postgresql/$PGVERSION/bin:${PATH#/usr/lib/postgresql/*:}"
}
# personal stuff
if [[ "$USER" == cb* ]] || [ "$USER" = myon ] ; then
export DEBEMAIL="[email protected]"
#export DEBEMAIL="[email protected]"
export PGPKEY2="D224C8B07E63A6946DA32E07C5AF774A58510B5A"
export PGPKEY3="5C48FE6157F49179597087C64C5A6BAB12D2A7AE"
fi