-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.bash_profile.seb
222 lines (191 loc) · 9.2 KB
/
.bash_profile.seb
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
# vim: ft=bash noet:
#[ -n "$ZSH_VERSION" ] && emulate -l bash
[ ${BASH_VERSINFO[0]} = 3 ] && [ -x ~/usr/local/bin/bash ] && exec ~/usr/local/bin/bash -l
declare -gxr isAdmin=$(groups 2>/dev/null | \egrep -wq "sudo|adm|admin|root|wheel" && echo true || echo false)
declare -gxr isSudoer=$(groups 2>/dev/null | \egrep -wq "sudo|adm|admin|root|wheel" && echo true || echo false)
[ $isSudoer = true ] && declare -gx sudo=$(type -P sudo) || declare -gxr sudo=""
test -z "$initDir" && export initDir=$HOME/.initBash
! declare 2>&1 | grep -wq ^colors= && [ ${BASH_VERSINFO[0]} -ge 4 ] && source $initDir/.colors
initDir=$(basename $initDir) #Pour creer des liens symboliques relatifs a $HOME
cd $HOME
[ -f ~/.profile ] || ln -sv $initDir/.bash_profile ~/.profile
[ -f ~/.bashrc ] || ln -sv $initDir/.bashrc ~/.bashrc
[ -f ~/.bash_logout ] || ln -sv $initDir/.bash_logout ~/.bash_logout
initDir=$HOME/$initDir
#command -v termux-chroot >/dev/null 2>&1 && command -v bash 2>/dev/null | grep termux -q && termux-chroot
if tty -s;then
function Debug { test "$debug" -gt 0 && echo "$bold${colors[blue]}$@$normal"; }
function Echo { echo -e "$@"; }
function Printf { printf "$@"; }
else
function Debug { : ; }
function Echo { : ; }
function Printf { : ; }
fi
test "$debug" -gt 0 && Echo "\n=> \${BASH_SOURCE[*]} = ${BASH_SOURCE[*]}\n"
tty -s && Debug "=> Running $bold${colors[blue]}$(basename ${BASH_SOURCE[0]})$normal ..."
echo $OSTYPE | grep -q android && export osFamily=Android || export osFamily=$(uname -s)
function SourceProfile { test "$debug" -gt 0 && { time . "$@";echo;true; } || . "$@" ; }
function Source { test "$debug" -gt 0 && { time . "$@";echo;true; } || . "$@" ; }
function addmanpaths {
for manpath
do
test ! -d "$manpath" && continue
echo $MANPATH | \grep -wq "$manpath" || {
test -z "$MANPATH" && MANPATH=$manpath || MANPATH=$MANPATH:$manpath
}
done
export MANPATH
}
function addpaths {
for path
do
test ! -d "$path" && continue
echo $PATH | \grep -wq "$path" || PATH=$path:$PATH
done
export PATH
}
function addpathsAtTheEnd {
for path
do
test ! -d "$path" && continue
echo $PATH | \grep -wq "$path" || PATH=$PATH:$path
done
export PATH
}
TeXLiveDIR=$(\ls -d /usr/local/texlive/*/bin/* 2>/dev/null | egrep "/texlive/[0-9]+/bin/$archi-${osFamily,,}")
addpaths $TeXLiveDIR
#addpathsAtTheEnd /home/linuxbrew/.linuxbrew/bin /home/linuxbrew/.linuxbrew/sbin
export youtube_dl="command youtube-dl"
if [ -n "$youtube_dl" ];then # Recuperation de la variable _USER_AGENT_TPL de youtube-dl pour construire le user agent
pythonVersion=$(python3 -V | awk -F "[ .]" '/Python/{printf$2"."$3}')
chromeVersion="73.0.3671.2"
test -r /usr/local/lib/python$pythonVersion/dist-packages/youtube_dl/utils.py && userAgent="$(awk -F "'" '/_USER_AGENT_TPL\s*=/{print$2}' /usr/local/lib/python$pythonVersion/dist-packages/youtube_dl/utils.py)" && export userAgent="$(printf "$userAgent" $chromeVersion)"
else
export userAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3513.1 Safari/537.36"
fi
#DEFINITION DES VARIABLES
[ ${BASH_VERSINFO[0]} -ge 4 ] && export which="type -P"
[ ${BASH_VERSINFO[0]} -ge 4 ] && export find="$(type -P find)"
export bashProfileLoaded=true
[ $osFamily = Linux ] && export osID=$(source /etc/os-release && echo $ID) osID_LIKE=$(source /etc/os-release && echo $ID_LIKE)
[ $osFamily = Darwin ] && export osID=Darwin && export osID_LIKE=FreeBSD
export HISTSIZE=2000
export HISTFILESIZE=4000
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
test $HOSTNAME && export HOSTNAME || export HOSTNAME=$(hostname | cut -d. -f1)
export EDITOR=vim
export UPMC_ID=3607968
export [email protected]
export [email protected]
export myDefault_sshOptions="-A -Y"
export JOLLA=nemo@jolla-wlan
#export HOMEBREW_TEMP=$HOME/tmp
export HOMEBREW_NO_GITHUB_API=1
type -P go >/dev/null 2>&1 && test -z "$GOPATH" && export GOPATH=$HOME/go
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:~/gnu/lib/pkgconfig:~/local/lib/pkgconfig
PERL5LIB="$HOME/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="$HOME/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"$HOME/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=$HOME/perl5"; export PERL_MM_OPT;
export myPerl5DefaultOptions="-ale"
export PIP_FORMAT=columns
test -z "$XDG_RUNTIME_DIR" && export XDG_RUNTIME_DIR="/run/user/$UID" && export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus" # For "systemctl --user" # i.e https://askubuntu.com/q/1461457/426176
if [ $osID_LIKE == debian ];then
sourceHighlightPath=$(dpkg -L libsource-highlight-common 2>/dev/null | grep lesspipe)
elif [ $osID_LIKE == redhat ];then
sourceHighlightPath=$(rpm -ql source-highlight 2>/dev/null | grep lesspipe)
fi
if ! groups 2>/dev/null | egrep -wq "sudo|adm|admin|root|wheel";then
export HOSTALIASES=~/.hosts
export PYTHONUSERBASE=$HOME/.local
export HOMEBREW_PREFIX=$HOME/usr/local
fi
export domain=$(awk -F"[ .]" '/domain/{print$(NF-1);exit}' /etc/resolv.conf /private/etc/resolv.conf 2>/dev/null)
test -z $domain && export domain=local # Si le domaine est inconnu
case $domain in
jussieu|enst)
export proxyName=proxy
export proxyPort=3128
;;
*)
export proxyName=unknown
export proxyPort=0
;;
esac
export ssh="command ssh"
type -P tlmgr >/dev/null 2>&1 && test -r $initDir/.bash_profile.texlive && SourceProfile $initDir/.bash_profile.texlive
#Si le proxy est joignable
if [ $domain != localhost ] && nc -v -z -w 4 $proxyName $proxyPort >/dev/null 2>&1
then
test -z $http_proxy && export http_proxy=http://proxy:$proxyPort
fi
if test -n "$http_proxy"; then
export https_proxy=$http_proxy
export dnsSuffix=$(basename $http_proxy | cut -d. -f2- | cut -d: -f1)
fi
type -P gnuplot >/dev/null 2>&1 && export GNUTERM=qt
export RSYNC_SKIP_COMPRESS_LIST="7z/aac/aif/aiff/avi/bz2/deb/flv/gz/iso/jpeg/jpg/m2ts/m4a/m4v/mkv/mov/MOV/mp2/mp3/mp4/mpeg/mpg/mxf/oga/ogg/ogm/ogv/png/rpm/tbz/tgz/tif/wav/webm/z/zip"
export RSYNC_EXCLUSION=$(printf -- "--exclude %s/ " /dev /sys /run /proc)
#FIN DE DEFINITION DES VARIABLES
if [ $osFamily = Linux ] || [ $osFamily = Darwin ];then
if type -P ssh-agent >/dev/null 2>&1; then
# Echo "=> Testing if not logged through ssh i.e if the SSH_CLIENT variable is not set ..." >&2
if test -z "$SSH_CLIENT"; then # Si on est PAS a l autre bout d une connection ssh
Echo "=> Testing if the ssh-agent is loaded ..." >&2
if pgrep -u $USER ssh-agent >/dev/null 2>&1;then
Echo "=> The ssh-agent is already running." >&2
# Connecting to the already ssh-agent if SSH_AGENT_PID and/or SSH_AUTH_SOCK are unset
test -z "$SSH_AGENT_PID" && export SSH_AGENT_PID=$(\pgrep -u $USER -n ssh-agent)
test -z "$SSH_AUTH_SOCK" && export SSH_AUTH_SOCK=$(\ls /tmp/ssh-*/agent.$(($SSH_AGENT_PID-1)))
else
# Echo "=> Starting the ssh-agent for $USER ..." >&2 && eval $(ssh-agent -s) >/dev/null && Echo "=> Done" >&2
:
fi
fi
# pgrep -lfu $USER ssh-agent 2>/dev/null
fi
#Definition des parametres de proxy dans cpan
if test "$http_proxy"
then
grep -q "http_proxy.*$http_proxy" ~/.cpan/CPAN/MyConfig.pm 2>/dev/null
test $? = 1 && printf "o conf http_proxy $http_proxy\no conf commit" | cpan
fi
#my locale configuration
type -P locale >/dev/null 2>&1 && test -e $initDir/.bash_profile.locale && SourceProfile $initDir/.bash_profile.locale
#GDM_LANG=fr_FR.UTF-8
export GDM_LANG=$LANG
#my lpr configuration
type -P lpr >/dev/null 2>&1 && test -f $initDir/.bash_profile.lpr && SourceProfile $initDir/.bash_profile.lpr
# ! pgrep -u $USER -f "adb -. " >/dev/null && tty -s && echo "=> Starting the <adb> service ..." && time adb start-server
pgrep -u $USER -f "adb -. " >/dev/null && export androidWlanInterface=$(adb shell getprop wifi.interface 2>/dev/null | tr -d '\r')
fi
test -r $initDir/.bash_profile.$osFamily && SourceProfile $initDir/.bash_profile.$osFamily
test "$debug" -gt 0 && echo "=> BACK to $bold${colors[blue]}$(basename ${BASH_SOURCE[0]})$normal"
[ $debug = 1 ] && echo "=> system = <$system>."
if [ "$osFamily" != Darwin ] && [ "$osFamily" != Linux ] && [ "$osFamily" != Android ];then
if [ -z "$system" ];then
[ $debug = 1 ] && echo "=> system = <$system>."
if type -P lsb_release >/dev/null;then
declare -gxr system="$(lsb_release -sd | awk -F '"' '{print$(NF-1)}')"
elif type -P getprop >/dev/null;then
declare -gxr system="$osFamily $(getprop ro.build.version.release)"
else
declare -gxr system=$(echo $HOSTTYPE-$OSTYPE | sed "s/arm[^-]*-/arm-/")
fi
[ $debug = 1 ] && echo "=> system = <$system>."
fi
fi
matlab=$(type -P matlab)
git=$(type -P git)
brew=$(type -P brew)
set -o | grep -q xtrace.*on && xtrace="set -o xtrace"
set +x
test -x "$matlab" && test -r $initDir/.bash_profile.matlab && SourceProfile $initDir/.bash_profile.matlab
test -x "$git" && test -r $initDir/.bash_profile.git && SourceProfile $initDir/.bash_profile.git
test -x "$brew" && test -r $initDir/.bash_profile.brew && SourceProfile $initDir/.bash_profile.brew
$xtrace
type -P hub >/dev/null 2>&1 && eval "$(hub alias -s)" # See https://github.com/github/hub
which neofetch >/dev/null 2>&1 && time neofetch && echo
test "$debug" -lt 3 && set +x
test "$debug" -gt 0 && echo "=> END of $bold${colors[blue]}$(basename ${BASH_SOURCE[0]})$normal"