-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc-work
194 lines (158 loc) · 7.26 KB
/
.zshrc-work
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
#!/bin/zsh
#########################################################
# ASSIA
export MAVEN_OPTS="-Xms1024m -Xmx4096m -XX:PermSize=1024m"
export JIRA_URL='https://assia-inc.atlassian.net'
export JAVA_HOME="/usr/java/jdk1.8.0_201/jre/"
export PATH=$JAVA_HOME:$PATH
export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib:$LD_LIBRARY_PATH
export SQLPATH=$HOME/.local/share/sqlcl/
export PYTHONPATH='/home/pganuza/Repositorios/work/pyhelpers'
# Corporate mounts
alias mount-home="sudo mount.cifs -o user=pganuza,domain=ASSIA-INC,uid=1000,gid=1000,vers=1.0 //rc-netapp02a.assia-inc.com/home/pganuza /mnt/assianet-home"
alias mount-corp="sudo mount.cifs -o user=pganuza,domain=ASSIA-INC,uid=1000,gid=1000,vers=1.0 //rc-netapp02a.assia-inc.com/corp /mnt/assianet-corp"
alias mount-onedrive='rclone mount $(basename $(pwd)): onedrive'
# Backup important work info into external HDD
alias backup-pganuza-e7470="rsync -avh --delete-after ~/.* ~/Plantillas ~/Software ~/Trabajo ~/Workspace/system-level_test_plan ~/Workspace/drafts /run/media/pganuza/pganuza-backups/"
# Alias for very frequent SSH connections
alias se='sshrc $CUSTOMER_ENV'
# Alias to allow... to long to explain
alias _#=''
#########################################################
# GIT configuration
git_diff_ticket() {
ticket=$1
# The commit that appears on top which message contains the ticket ID
after=$(git log --grep="$ticket"| grep commit | head -n1 | cut -d' ' -f2)
# The commit previous to the first commit that contains the ticket ID
first_commit=$(git log --grep="$ticket" | grep commit | tail -n1 | cut -d' ' -f2)
before=$(git log $first_commit~1 | head -n1 | cut -d' ' -f2)
echo "git diff --unified=9999 $before $after"
git diff --unified=9999 $before $after
}
alias rsync-lexus='rsync -rvzh $CUSTOMER_DIR_CVS lexus:$CUSTOMER_DIR_CVS --exclude "*/target/"'
#########################################################
# CURRENTLY WORKING
# Add some useful paths to the hotlist for n-cd
znt_cd_hotlist=( "${znt_cd_hotlist[@]}" '=====================================pganuza-e7470rc====' )
znt_cd_hotlist=( "${znt_cd_hotlist[@]}" '~/Documents/KnowHow/wiki/'
'~/Documents/QA/'
'~/Repositorios/ASSIA/bookmarks/' )
customer_info_file="$HOME/Documents/Releases/customers-info.csv"
populate_customer_variables() {
export CUSTOMER=$1
export CUSTOMER_NAME="$(grep -E "^$CUSTOMER" $customer_info_file | cut -d';' -f'2')"
export CUSTOMER_ENV="$(grep -E "^$CUSTOMER" $customer_info_file | cut -d';' -f'3')"
export CUSTOMER_DB="$(grep -E "^$CUSTOMER" $customer_info_file | cut -d';' -f'4')"
export CUSTOMER_VER="$(grep -E "^$CUSTOMER" $customer_info_file | cut -d';' -f'5')"
export DBF='plain'
export CUSTOMER_DIR="$HOME/Documents/Releases/$CUSTOMER/$CUSTOMER_VER"
export CUSTOMER_DIR_CVS="$HOME/Repositorios/ASSIA/releases/$CUSTOMER/"
znt_cd_hotlist=( "${znt_cd_hotlist[@]}" '------------------------------------=currently working=-' )
znt_cd_hotlist=( "${znt_cd_hotlist[@]}" "$CUSTOMER_DIR_CVS" "$CUSTOMER_DIR" )
}
populate_customer_variables demo-b
alias cdc='cd $CUSTOMER_DIR'
#########################################################
# UTILS
# Just throw a fast query
alias query='sqlturbo.py -u $CUSTOMER_DB -f $DBF'
# Translate to Jira and copy to clipboard a comment written in Markdown
cp_jira_comment(){
cat **/README.md | md2jira.sh | xclip
}
alias cpjc='cp_jira_comment'
# Get version installed on a customer's support environment
get_customer_versions(){
ssh $1 'ls -d install/*-*' | sed 's/install\///'
}
compdef get_customer_versions=ssh
# Connect to a database
function dbconn() {
if [ $# -ne 0 ]; then
sqlcl $1/[email protected]:1521:dslo2 @$2
else
echo "Connecting to $CUSTOMER_DB..."
sqlcl $CUSTOMER_DB/[email protected]:1521:dslo2
fi
}
#########################################################
## TASK MANAGEMENT
#
task_start_specifics(){
ji.py query --issue $TASK --fields 'summary' > .title
ji.py query --issue $TASK --fields 'description' > .description
ji.py query --issue $TASK --fields 'unit_test' > .unit_test
# About where to check it
echo -e "To be verified in:" >> README.md
ji.py query --issue $TASK --fields 'fixVersions' | grep -oE "name='[^']+'" | cut -d= -f2 | sed -E 's/^/- [pending] /' >> README.md
# The line below would strip the quotes, but it messes VIMs syntax highlighting in this file
# ji.py query --issue DSLE-22740 --fields 'fixVersions' | grep -oE "name='[^']+'" | cut -d= -f2 | sed 's/^/- [<++>] /' |sed "s/'//g" > README.md
echo -e "\n------------------------------------" >> README.md
echo -e "\nVerified in **$CUSTOMER_ENV $CUSTOMER_VER**." >> README.md
# Rutinary checks
module_fix_for_version=$(ji.py query --issue $TASK --fields 'module_fix_for_version' | grep -oE "[^ ]+[ |-][0-9|.]+")
if [ ! -z $module_fix_for_version ]; then
echo -e '\n##### Modules versions' >> README.md
## Get every module with its version in one line
echo $module_fix_for_version | sed -E 's/([^ ]+)[ |-]([0-9|.]+)/- [<++>] \1 \2/' >> README.md
modules_check=$( echo $module_fix_for_version | sed -E 's/([^ ]+)[ |-]([0-9|.]+)/find install\/ *simulator*\/ -name "*\1*" ; /' | tr -d \\n)
#modules_check=$( echo $module_fix_for_version | sed -E 's/([^ ]+) ([0-9|.]+)/find install\/ -name "*\1*" ; /' )
echo -e '\n```sh' >> README.md
echo -e "\n$modules_check" >> README.md
#ssh $CUSTOMER_ENV "'$(echo $modules_check | tr -d \\n)'" >> README.md
echo -e "\n\`\`\`\n" >> README.md
fi
# Update Jira
ji.py assign --issue $TASK --value '5bd7a4938995b717bb1b86dd'
# Add a task to follow up on what is it that I am doing
t add pri a "@comprobar +$TASK '$(cat .title)'"
}
task_resume_specifics(){
#jira_ticket $TASK
}
jira_ticket(){
xdg-open "https://assia-inc.atlassian.net/browse/$1"
}
task_download_data() {
rsync -rvzh ${1:-$CUSTOMER_ENV}:pganuza/${$(pwd)#/home/pganuza/Documents/}/ .
}
task_upload_data() {
rsync -rvzh ./ ${1:-$CUSTOMER_ENV}:pganuza/${$(pwd)#/home/pganuza/Documents/}/
}
task_package_for_jira() {
package_name=$(basename $(cut -d' ' -f1 <(pwd)))
tar -cvzf $package_name.tar.gz --exclude='*.md' --exclude='.*' --exclude='*.sql' --exclude='*.sh' --exclude='config' --exclude='backup' --exclude='scrappbook*' *
}
#########################################################
# USEFUL FUNCTIONS for tickets
# Handle configurations for tests
template_test() {
template="$1"
tname="$2"
mkdir $tname && cd $tname && cp ../$template/setup.sh . && cp -r ../$template/config .
}
alias tt='template_test'
# Place configured files in their places
push_config() {
rsync -Krvh "${1:-./}" --exclude='*.swp' --exclude='*~*' $CUSTOMER_ENV:
}
alias backup='rsync -Rrvzh'
alias mm='module_manager.sh'
mock_server_restart() {
se '~/installAdditional/mock_server/tomcat/bin/shutdown.sh && ~/installAdditional/mock_server/tomcat/bin/startup.sh'
}
#########################################################
## SHOW STATUS
#
if [[ $HOSTNAME == 'PGANUZA-E7470' ]]; then
echo '#########################################################'
echo '# TODO priorities'
t
echo -e '\n#########################################################'
echo "# TODO for $CUSTOMER"
t ls +$CUSTOMER
fi
################################################
# SOURCES
# [1] https://superuser.com/questions/271986/execute-a-command-from-another-directory-in-bash#271992