-
Notifications
You must be signed in to change notification settings - Fork 0
/
.sshrc
161 lines (137 loc) · 4.51 KB
/
.sshrc
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
# .bashrc
PS1='\[\033[1;36m\]\u\[\033[1;31m\]@\[\033[1;32m\]\h:\[\033[1;35m\]\w\[\033[1;31m\]\$\[\033[0m\] '
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
EDITOR=vim
if [[ $(hostname) =~ 'assia-inc.com' ]]; then
export TERM='xterm-256color'
fi
#########################################################
# VARIOUS CONFIGURATIONS
#
# Common aliases
alias ls='ls --color=auto'
alias la='ls -a'
alias ll='ls -lah'
alias ..='cd ..'
alias grep='grep --color=always'
alias e='vim'
# Path for custom programs
export PATH=$PATH:$HOME/.local/bin
# CVS configuration [2]
export CVSROOT=:ext:[email protected]:/cvs
alias cvsp="cvs -d $CVSROOT"
alias cvs-update='cvsp update -PAd'
alias cvs-discard_changes='cvs_update -C'
alias cvs-checkout='cvsp co -r'
# VIM config
alias vim='vim -u $SSHHOME/.sshrc.d/.vimrc'
# readline config
bind -f $SSHHOME/.sshrc.d/.inputrc
# less [1]
export LESS='-R -C -M -I -j 10 -# 4'
export PAGER=less
# "enable" syntax highlight in view
alias view='vim -R'
alias v='view'
# tmux
export SHELL=$SSHHOME/bashsshrc
alias m="tmux -f $SSHHOME/.sshrc.d/.tmux.conf"
# Others
#alias diff='diff --color=auto'
export LANG="en_EN.UTF-8"
#########################################################
# USEFUL FUNCTIONS
#
# Create a directory and cd into it. Name is taken from ZSH analogue function.
take () {
mkdir -p "$1"
cd "$1"
}
#function sql() {
# if [ -z "$2" ]
# then
# /usr/bin/sql $1/[email protected]:1521:dslo2
# else
# /usr/bin/sql $1/[email protected]:1521:dslo2 @$2
# fi
#}
# Toggle showing history timestamps
function toggle_history_timestamps () {
if [ -z "$HISTTIMEFORMAT" ];
then
export HISTTIMEFORMAT="%d/%m/%y %T "
else
unset HISTTIMEFORMAT
fi
}
alias th='toggle_history_timestamps'
#########################################################
# USEFUL FUNCTIONS for tickets
# Copy log
log() {
if [[ $# < 1 ]]; then
>&2 echo "Usage: log dcpc|dcpc2|gui|oldgui|dbloader|pe|po|prov|reqgen|/path/to/file.log"
else
case $1 in
"dcpc") tail -n0 -f ~/install/dcpc/log/assia_dcpc.log | tee "${2}"assia_dcpc.log ;;
"dcpc2") tail -n0 -f ~/install2/dcpc/log/assia_dcpc.log | tee "${2}"assia_dcpc2.log ;;
"gui") tail -n0 -f ~/install/tomcat/logs/expresseGuiNapi.log | tee "${2}"expresseGuiNapi.log ;;
"oldgui") tail -n0 -f ~/install/tomcat/logs/assia_gui.log | tee "${2}"assia_gui.log ;;
"dbloader") tail -n0 -f ~/install/server/log/assia_dbloader.log | tee "${2}"assia_dbloader.log ;;
"pe") tail -n0 -f ~/install/server/log/assia_pe.log | tee "${2}"assia_pe.log ;;
"po") tail -n0 -f ~/install/server/log/assia_po.log | tee "${2}"assia_po.log ;;
"prov") tail -n0 -f ~/install/server/log/assia_prov.log | tee "${2}"assia_prov.log ;;
"reqgen") tail -n0 -f ~/install/server/log/assia_reqgen.log | tee "${2}"assia_reqgen.log ;;
"audit") tail -n0 -f ~/install/tomcat/logs/expresseAudit.log | tee "${2}"expresseAudit.log ;;
*) tail -n0 -f $1 | tee ${1##*/} ;;
esac
fi
}
# Watch for DcPc output files
alias dcpc_watch='while true; do clear; find ~/install{,2}/dcpc/data/out_temp/ -type f -exec cp {} . \;; sleep 1; ls; sleep 1; done'
# Make backup of file
cpp() {
cp -r --parent "$1" "${2:-.}"
}
# Place configured files in their places
push_config() {
rsync -Krvh "${1:-./}" / --exclude='*.swp' --exclude='*~*'
}
template_test() {
template="$1"
tname="$2"
mkdir $tname && cd $tname && cp ../$template/setup.sh . && cp -r ../$template/config .
}
template_setup() {
echo -e "#!/bin/bash\nsource /tmp/.pganuza.sshrc.*/sshrc.bashrc 2> /dev/null\npush_config config/" > setup.sh
chmod +x setup.sh
}
# Modules management
module_management() {
if [[ $# < 2 ]]; then
>&2 echo "Usage: $(basename 0) dcpc|dcpc2|tomcat|server|sim|simcli action"
else
case $1 in
'dcpc') ant -f ~/install/dcpc/build.xml $2 ;;
'dcpc2') ant -f ~/install2/dcpc/build.xml $2 ;;
'tomcat') ant -f ~/install/tomcat/build.xml $2 ;;
'server') ant -f ~/install/server/build.xml $1 $2 ;;
'sim') ant -f ~/simulator/build.xml $2 ;;
'simcli') ant -f ~/cli_simulator/build.xml $2 ;;
*) echo 'ERROR';;
esac
fi
}
alias mm='module_management'
mock_server_restart() {
~/installAdditional/mock_server/tomcat/bin/shutdown.sh
~/installAdditional/mock_server/tomcat/bin/startup.sh
}
alias collect_all_true="sed -E 's/([^=]=\s+)false/\1true/'"
#########################################################
# SOURCES
# [1] https://opensource.com/article/18/5/advanced-use-less-text-file-viewer
# [2] https://stackoverflow.com/questions/317127/cvsroot-environment