Skip to content

Commit 1e78258

Browse files
committed
added a couple of bash scripts
1 parent af93afd commit 1e78258

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

bash/cleanout

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
TARGET_DIR=("$@")
3+
[ "x$1" == "x" ] && TARGET_DIR=(".")
4+
function confirmDeletion() {
5+
local confirm=""
6+
until [ "x$confirm" == 'xy' ] || [ "x$confirm" == 'xn' ]
7+
do
8+
read -ep " Delete [y/n]: " confirm
9+
confirm=$(echo "$confirm" | tr [:upper:] [:lower:])
10+
done
11+
[ "x$confirm" == 'xy' ]
12+
}
13+
function deleteWithConfirmation() {
14+
for file in "${@}"
15+
do
16+
if rm "$file"; then
17+
echo " OK: $file"
18+
else
19+
echo " FAIL: $file"
20+
fi
21+
done
22+
}
23+
for i in {'*~','a.out','*.o','*.gch','*nppdf32Log*'}
24+
do
25+
echo "Files matching: $i"
26+
FILES=()
27+
while read -rd '' file
28+
do
29+
FILES+=("$file")
30+
echo " $file"
31+
done < <(find "${TARGET_DIR[@]}" -depth -iname "$i" -print0)
32+
if [ "x${FILES[*]}" != "x" ]; then
33+
if confirmDeletion; then
34+
deleteWithConfirmation "${FILES[@]}"
35+
else
36+
echo " Skipping"
37+
fi
38+
fi
39+
done
40+

bash/colors.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
3+
# ANSI Color -- use these variables to easily have different color
4+
# and format output. Make sure to output the reset sequence after
5+
# colors (f = foreground, b = background), and use the 'off'
6+
# feature for anything you turn on.
7+
8+
initializeANSI()
9+
{
10+
esc=""
11+
12+
blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m"
13+
yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m"
14+
cyanf="${esc}[36m"; whitef="${esc}[37m"
15+
16+
blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m"
17+
yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m"
18+
cyanb="${esc}[46m"; whiteb="${esc}[47m"
19+
20+
boldon="${esc}[1m"; boldoff="${esc}[22m"
21+
italicson="${esc}[3m"; italicsoff="${esc}[23m"
22+
ulon="${esc}[4m"; uloff="${esc}[24m"
23+
invon="${esc}[7m"; invoff="${esc}[27m"
24+
25+
reset="${esc}[0m"
26+
}
27+
28+
# note in this first use that switching colors doesn't require a reset
29+
# first - the new color overrides the old one.
30+
31+
initializeANSI
32+
33+
cat << EOF
34+
${yellowf}This is a phrase in yellow${redb} and red${reset}
35+
${boldon}This is bold${ulon} this is italics${reset} bye bye
36+
${italicson}This is italics${italicsoff} and this is not
37+
${ulon}This is ul${uloff} and this is not
38+
${invon}This is inv${invoff} and this is not
39+
${yellowf}${redb}Warning I${yellowb}
40+
${redf}Warning II${reset}
41+
EOF
42+

participants.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)