-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc
More file actions
executable file
·102 lines (85 loc) · 2.23 KB
/
bashrc
File metadata and controls
executable file
·102 lines (85 loc) · 2.23 KB
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
#!/bin/bash
# bash routines for development
#create a combined diff of changed CVS files in the current dir
cvsdiff() {
local filename=$1
if [ -z "${filename}" ]
then
showError "usage : cvsdiff <id> [files]"
showError ' files will be created in $DIFFS if available'
exit 1
fi
shift
local filepath=$(getDiffFilePath ${filename})
cvs diff $* 2>/dev/null 1>${filepath}
showInfo "Diff file created at ${filepath}"
openfile ${filepath}
}
gitdiff() {
local filename=$1
if [ -z "${filename}" ]
then
showError "usage : gitdiff <id> [files]"
showError ' files will be created in $DIFFS if available'
exit 1
fi
shift
local filepath=$(getDiffFilePath ${filename})
git diff origin $* 2>/dev/null 1>${filepath}
showInfo "Diff file created at ${filepath}"
openfile ${filepath}
}
createDiffFile() {
local filename=$1
if [ ! -d "${DIFFS}" ]; then
DIFFS=.
fi
# if diff file exists, create new file by appending date
local DATE=`date +%d%h%y_%H%M`
if [ -e "${DIFFS}/${filename}.txt" ]
then
filename=${filename}-${DATE}.txt
fi
echo "${DIFFS}/${filename}"
}
#create a backup of changed CVS files from the current dir
cvsbackup() {
local filename=$1
local files=`cvs up 2>/dev/null $*| sed -e "/^R/d" -e "s/^[M?A] //"`
createBackupFile ${filename} "cvsbackup" ${files}
}
createBackupFile() {
local filename=$1
local commandName=$2
shift
shift
local files=$@
if [ -z "${filename}" ]
then
showError "usage : ${commandName} <id> [files]"
showError ' files will be created in $BACKUPS if available'
exit 1
fi
shift
if [ -z "${BACKUPS}" ]; then
BACKUPS=.
fi
local DATE=`date +%d.%h.%Y_%H-%M`
filename=${filename}-${DATE}.jar
filepath=${BACKUPS}/$filename
jar cfM ${filepath} ${files}
showInfo "Backup file created at ${filepath}"
}
#opens a given file
openfile() {
local file=$1
if [ -n "${EDITOR}" ];then
$EDITOR ${file}
fi
}
showInfo() {
echo -e '\033[1;34m'"\033[1m$1\033[0m"
}
showError() {
echo -e '\033[1;31m'"\033[1mERROR: $1\033[0m"
}