-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zsh_aliases
81 lines (73 loc) · 1.7 KB
/
.zsh_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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
alias u='cd ..'
alias v='vim'
alias gs='git status'
alias cp='cp -v'
alias mv='mv -v'
alias rm='rm -v'
alias mkdir='mkdir -v'
# Prompt formatting
PROMPT="%n %d $ "
# Terminal colors
export LSCOLORS="GxFxCxDxBxegedabagaced"
alias ls='ls -lGH'
find_and_replace() {
if [ $# -ne 2 ]
then
echo "usage: find_and_replace <TEXT_TO_REPLACE> <REPLACEMENT>"
else
find . -name ".git" -prune -o -type f -exec sed -i "s/$1/$2/g" {} +
fi
}
find_and_delete() {
if [ $# -ne 1 ]
then
echo "usage: find_and_delete <PATTERN>"
else
find . -name ".git" -prune -o -type f -exec sed -i "/$1/g" {} +
fi
}
format_cpp_code() {
if [ $# -ne 0 ]
then
echo "usage: format_cpp_code"
else
find . \
-name ".git" -prune -o \
-name "build" -prune -o \
-name "thirdparty" -prune -o \
-name "*.h" -type f -exec clang-format -i --verbose {} + -o \
-name "*.cpp" -type f -exec clang-format -i --verbose {} +
fi
}
format_python_code() {
if [ $# -ne 0 ]
then
echo "usage: format_python_code"
else
find . \
-name ".git" -prune -o \
-name "build" -prune -o \
-name "thirdparty" -prune -o \
-name "*.py" -type f -exec black -l 120 {} +
fi
}
prepend_env()
{
if [ $# -ne 2 ]
then
echo "usage: prepend_env <ENV_VAR> <ENV_VALUE>"
else
ENV_VALUE=`printenv $1`
export $1="$2${ENV_VALUE:+${ENV_VALUE}:}"
fi
}
append_env()
{
if [ $# -ne 2 ]
then
echo "usage: append_env <ENV_VAR> <ENV_VALUE>"
else
ENV_VALUE=`printenv $1`
export $1="${ENV_VALUE:+${ENV_VALUE}:}$2"
fi
}