-
Notifications
You must be signed in to change notification settings - Fork 2
/
functions
executable file
·154 lines (134 loc) · 3.5 KB
/
functions
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
function informacao()
{
echo "${txtund}$1${txtrst}"
}
function sucesso()
{
echo "${txtbld}${txtgrn}$1${txtrst}"
}
function aviso()
{
echo "${txtbld}${txtred}$1${txtrst}"
}
function workOnTTY()
{
exec fbterm -- bash -c 'TERM=fbterm screen'
}
function pergunta()
{
echo "${txtbld}${txtylw}$1${txtrst}"
}
function fgit() {
if [ -n "$1" ]; then
git config diff.renameLimit 0 && git config merge.renameLimit 0 && git log -S"${1}" --source --all --decorate
else
echo "No parameter provided"
fi
}
# List bash possible colors
function cores()
{
echo
echo -e "$(tput bold) reg bld und tput-command-colors$(tput sgr0)"
for i in $(seq 1 7); do
echo " $(tput setaf $i)Text$(tput sgr0) $(tput bold)$(tput setaf $i)Text$(tput sgr0) $(tput sgr 0 1)$(tput setaf $i)Text$(tput sgr0) \$(tput setaf $i)"
done
echo ' Bold $(tput bold)'
echo ' Underline $(tput sgr 0 1)'
echo ' Reset $(tput sgr0)'
echo
}
# change permissions recurssively
function permitir()
{
aviso "Changing permissions.."
if [ $1 ]; then
sudo chmod -R 775 $1
else
sudo chmod -R 775 .
fi
sucesso "Done!"
}
function br()
{
echo "${txtred} Opening bashrc.. ${txtrst}"
sudo vim ~/.bashrc
}
# source this file
function sr()
{
echo "${txtred} Reading bashrc.. ${txtrst}"
source ~/.bashrc
}
# search and rename files, ignore svn
function renomear()
{
aviso "Searching all folders for for word: ${txtwht}'$1'${txtred} and renaming to ${txtwht}'$2'${txtred}"
# first rename folders
find . -depth -path '*/.svn' -prune -o -type d -execdir rename "s/$1/$2/g" {} \;
# rename files
find . -depth -path '*/.svn' -prune -o -type f -exec rename "s/$1/$2/g" {} \;
sucesso "Done!"
}
# search and replace files, ignore svn
function mudar()
{
aviso "Searching all files and replacing all instances of word: ${txtwht}'$1'${txtred} to ${txtwht}'$2'${txtred}"
find . -depth -path '*/.svn' -prune -o -type f -exec sed -i "s/$1/$2/g" {} +
sucesso "Done!"
}
function refatora()
{
informacao "You are about to rename Directories, Files recurrsivelly for the any instance of word $1 to $2"
pergunta "Are you sure about that ?"
read a
if [[ $a == "Y" || $a == "y" || $a == "yes" || $a == "Yes" ]]; then
echo "Starting..."
mudar $1 $2
renomear $1 $2
else
aviso "No changes were made"
fi
}
# find files and print output
function achar()
{
aviso "Searching for ${txtwht}'$1'${txtred}"
find . -depth -path '*/.svn' -prune -o -type f -exec grep "$1" {} \; -print
sucesso "Done!"
}
# list files or grep and highlight match
function l()
{
if [ $1 ]; then
ls -laGph | grep "$1"
else
ls -laGph
fi
}
function svnRemover()
{
aviso "Removing all ${txtwht}'.svn'${txtred} folders..."
find . -depth -name ".svn" -type d -exec rm -rf {} \;
sucesso "Done!"
}
function gitRemover()
{
aviso "Removing all ${txtwht}'.git'${txtred} folders..."
find . -depth -name ".git" -type d -exec rm -rf {} \;
sucesso "Done!"
}
function svnIgnorar()
{
aviso "Adding to svn ignore list file ${txtwht} $1 ${txtred} ..."
svn propset svn:ignore $1 .
svn ci -m"Adding to ignore list file '$1'" $1
informacao "Displaying current ignored files.."
svn propget svn:ignore .
sucesso "Done!"
}
function svnFora()
{
aviso "The following files are currently ${txtwht} NOT IN svn ${txtred}:"
svn st | grep ^\? | awk '{print $2}'
}