forked from bcaddy/dotfiles-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash_functions.sh
90 lines (69 loc) · 2.49 KB
/
bash_functions.sh
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
################################################################################
# This file contains all the bash functions that are specific to $HOSTNAME
################################################################################
# ==============================================================================
set-tab () {
#this function sets the iterm2 tab to be whatever you want. Defaults to
#${HOSTNAME}
#new we declare and assign an array with all paths to the repos in it
if [[ ${1} ]] ; then
title="${1}"
export PROMPT_COMMAND='echo -ne "\033]0;${title}\007"'
else
export PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAME}\007"'
fi
}
# ==============================================================================
# ==============================================================================
remake () {
# function for remaking
# check for GNU time
if hash gtime 2>/dev/null; then
TIME="gtime"
else
TIME="/usr/bin/time"
fi
# set the format that GNU time prints out
format="
Compile complete
Wall time = %es
User time = %Us
System time = %Ss
"
#Max Memory Usage = %MKB
rm -iv compile.log
echo -e "\nCleaning..."
make clean
echo -e "\nCompiling..."
"${TIME}" -f "${format}" make > compile.log
it2attention start
it2attention fireworks
}
# ==============================================================================
# ==============================================================================
function replace_C() {
# This function replaces C and c comment characters in Fortran with !
# Usage
# $1: the file(s) to do the find and replace in
file=$1
sed -i '' 's/^[cC]/!/' $file
}
# ==============================================================================
# ==============================================================================
function find-and-replace() {
# This function finds strings and replaces them with other strings recursively
# Usage
# $1: the directory to do the find and replace in
# $2: the string to find
# $3: the string to replace with
directory=$1
find=$2
replace=$3
grep -rl "${find}" $directory | xargs sed -i "s/${find}/${replace}/g"
}
# ==============================================================================
# ==============================================================================
function iterm2_print_user_vars() {
it2git
}
# ==============================================================================