-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash_aliases
67 lines (60 loc) · 1.44 KB
/
bash_aliases
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
alias ..="cd .."
alias sudo=/usr/bin/sudo
function sed-cpp {
find . -iname \*.cpp -exec sed -i "$1" {} \;
find . -iname \*.hpp -exec sed -i "$1" {} \;
}
function sed-test {
find . -iname \*.test -exec sed -i "$1" {} \;
find . -iname \*.loadtest -exec sed -i "$1" {} \;
}
function sed-rename {
if [ $# -gt 1 ]; then
sed_pattern=$1
shift
for file in $(ls $@); do
new=`sed $sed_pattern <<< $file`
if [[ "$new" != "$file" ]]; then
mv -v "$file" "$new"
fi
done
else
echo "usage: $0 sed_pattern files..."
fi
}
function cpp-move-file {
local from=$1
local to=$2
echo move $from "->" $to
mkdir -p -- "${to%/*}"
mv "$from" "$to"
if [[ "$to" == *.cpp ]]; then
sed -i "/.* const char tc\[\] =/c\static const char tc[] = \"${to%.cpp}\";" "$to"
fi
if [[ "$from" == *.hpp ]]; then
sed-cpp "s|#include \"$1\"|#include \"$2\"|"
fi
}
function move-folder {
local from=$1
local to=$2
for entry in $(ls "$from"); do
path="$from/$entry"
if [ -f "$path" ]; then
move-file "$path" "$to/$entry"
elif [ -d "$path" ]; then
move-folder "$path" "$to/$entry"
else
echo "unsupported file type \"$path\""
fi
done
}
function move-hpp-cpp {
move-file "$1.hpp" "$2.hpp"
if [ -f "$1.cpp" ]; then
move-file "$1.cpp" "$2.cpp"
fi
if [ -f "$1.proxy.hpp" ]; then
move-file "$1.proxy.hpp" "$2.proxy.hpp"
fi
}