Newer
Older
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
#!/bin/bash
## Functions to setup BDAP user account for bash & git (only if pending).
set -e
function mute {
"${@}" 1> /dev/null 2>&1
}
function upd_inputrc {
if mute grep -v ':history-search-forward' ~/.inputrc; then
echo "${FUNCNAME[0]}: already ok"
else
echo -n "${FUNCNAME[0]}: updating..."
cat >> ~/.inputrc <<- "EOF"
$include /etc/inputrc
## arrow up
"\e[A":history-search-backward
## arrow down
"\e[B":history-search-forward
"\C-x\C-r": re-read-init-file
EOF
echo "UPDATED"
fi
}
function upd_bashrc_git_completions {
if mute grep "/usr/share/bash-completion/completions/git" ~/.bashrc ; then
echo "${FUNCNAME[0]}: already ok"
else
echo -n "${FUNCNAME[0]}: updating..."
cat >> ~/.bashrc <<- "EOF"
## Enable git completions
source /usr/share/bash-completion/completions/git
EOF
echo "UPDATED"
fi
}
function upd_bashrc_history {
if mute grep "PROMPT_COMMAND=\"history -a\"" ~/.bashrc ; then
echo "${FUNCNAME[0]}: already ok"
else
echo -n "${FUNCNAME[0]}: updating..."
cat >> ~/.bashrc <<- "EOF"
####
## HISTORY CONTROL:
## (more options may lie above))
##
## Save all lines of a multiple-line command in the same history entry.
shopt -s cmdhist
## Save multi-line commands to the history with embedded newlines.
shopt -s lithist
## Save each and EVERY cmd to history
# (not to loose it if terminal closed abruptly!)
PROMPT_COMMAND="history -a"
## Don't put duplicate lines or lines starting with space in the history.
## Ignore 1-char cmds
HISTIGNORE=?:?
EOF
echo "UPDATED"
fi
}
function upd_bashrc_ustore_vars {
if mute grep "export USTORE=" ~/.bashrc; then
echo "${FUNCNAME[0]}: already ok"
else
echo -n "${FUNCNAME[0]}: updating..."
cat >> ~/.bashrc <<- EOF
## BDAP Storage locations
export PSTORE="/eos/jeodpp/data/projects/LEGENT"
export USTORE="/eos/jeodpp/home/users/${USER}"
export UTRANS="/eos/jeodpp/home/users/${USER}/transfer"
export PTRANS="/eos/jeodpp/data/projects/LEGENT/transfer"
EOF
echo "UPDATED"
fi
}
function upd_bash_aliases {
if mute grep 'alias lg=' ~/.bash_aliases; then
echo "${FUNCNAME[0]}: already ok"
else
echo -n "${FUNCNAME[0]}: updating..."
cat >> ~/.bash_aliases <<- "EOF"
## GIT ALIASES
alias lg='git lg'
alias lgg='git lgg'
alias status='git status'
alias show='git show'
alias log='git log'
EOF
echo "UPDATED"
fi
}
function upd_git_user {
if mute git config --global --get user.name; then
echo "${FUNCNAME[0]}.name: already ok"
else
echo "${FUNCNAME[0]}.name: updating..."
read -e -p " +--Enter your git author-name:" inp
git config --global user.name "inp"
echo "UPDATED"
fi
if mute git config --global --get user.email; then
echo "${FUNCNAME[0]}.email: already ok"
else
echo "${FUNCNAME[0]}.email: updating..."
read -e -p " +--Enter your git author-email:" inp
git config --global user.email "inp"
echo "UPDATED"
fi
}
function upd_git_lg {
if mute git config --global --get alias.lg; then
echo "${FUNCNAME[0]}: already ok"
else
echo -n "${FUNCNAME[0]}: updating..."
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git config --global alias.lgg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all"
git config --global credential.helper store
echo "UPDATED"
fi
}
function upd_bashrc_conda_init {
if mute grep " >>> conda initialize >>>" ~/.bashrc; then
echo "${FUNCNAME[0]}: already ok"
else
echo -n "${FUNCNAME[0]}: updating..."
conda init bash
fi
}
if [ $# -eq 0 ]; then
echo -e "SYNTAX:\n $0 UPD_FN\nWHERE UPD_FN one of:"
declare -F|grep -oE " +upd_.+"
else
"${@}"
fi